0.0.9
All checks were successful
EnergonRelics/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-08-16 09:43:06 -04:00
parent 9096dbd53a
commit dfe547c34b
7 changed files with 42 additions and 24 deletions

View File

@ -1,5 +1,8 @@
# Changelog # Changelog
**Beta 0.0.9**
* Fix Interaction Bug With Phase Shifter Block
**Beta 0.0.8** **Beta 0.0.8**
* Add Phase Shifter Block * Add Phase Shifter Block
* Fix Bugs * Fix Bugs

View File

@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
fabric_loader_version = 0.9.0+build.204 fabric_loader_version = 0.9.0+build.204
# Mod Properties # Mod Properties
mod_version = 0.0.8 mod_version = 0.0.9
maven_group = com.thebrokenrail maven_group = com.thebrokenrail
# Dependencies # Dependencies

View File

@ -14,13 +14,17 @@ public interface EnergyTickable {
*/ */
@ApiStatus.OverrideOnly @ApiStatus.OverrideOnly
List<EnergyTickable> startTick(); List<EnergyTickable> startTick();
/** /**
* Logic Tick * Logic Tick
*/ */
@ApiStatus.OverrideOnly @ApiStatus.OverrideOnly
void logicTick(); void logicTick();
/** /**
* Get ID * Get ID
*
* Used By The Debug Profiler
* @return ID * @return ID
*/ */
@ApiStatus.OverrideOnly @ApiStatus.OverrideOnly

View File

@ -17,11 +17,17 @@ import java.util.Objects;
@ApiStatus.Internal @ApiStatus.Internal
public class EnergyTicker { public class EnergyTicker {
private static final List<EnergyTickable> scheduled = new ArrayList<>(); private static final List<EnergyTickable> scheduled = new ArrayList<>();
private static List<EnergyTickable> allLoaded = Collections.emptyList();
/** /**
* List of All Loaded Energy Tickers * Get All Loaded Energy Tickers
*
* Only Usable In {@link EnergyTickable#logicTick()}
* @return List Of All Loaded Energy Tickers
*/ */
public static List<EnergyTickable> allLoaded = Collections.emptyList(); public static List<EnergyTickable> getAllLoaded() {
return allLoaded;
}
/** /**
* Schedule For Next Energy Tick * Schedule For Next Energy Tick

View File

@ -3,7 +3,7 @@ package com.thebrokenrail.energonrelics.api.item;
import net.minecraft.text.MutableText; import net.minecraft.text.MutableText;
/** /**
* Implement To provide Extra Information In Multimeter * Implement To Provide Extra Information In Multimeter
*/ */
public interface MultimeterExtra { public interface MultimeterExtra {
/** /**

View File

@ -82,28 +82,33 @@ public class PhaseShifterBlock extends EnergyBlock {
@Override @Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
ItemStack stack = player.getStackInHand(hand); ActionResult result = super.onUse(state, world, pos, player, hand, hit);
BlockEntity entity = world.getBlockEntity(pos); if (result != ActionResult.PASS) {
return result;
if (stack.getItem() instanceof DyeItem) {
DyeColor newColor = ((DyeItem) stack.getItem()).getColor();
if (state.get(COLOR) != newColor) {
world.setBlockState(pos, state.with(COLOR, newColor));
if (!player.isCreative()) {
stack.decrement(1);
}
return ActionResult.SUCCESS;
} else {
return ActionResult.PASS;
}
} else { } else {
if (entity instanceof Inventory) { ItemStack stack = player.getStackInHand(hand);
if (!world.isClient()) { BlockEntity entity = world.getBlockEntity(pos);
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, inv, player2) -> new HopperScreenHandler(i, inv, (Inventory) entity), new TranslatableText("block." + EnergonRelics.NAMESPACE + ".phase_shifter")));
if (stack.getItem() instanceof DyeItem && player.shouldCancelInteraction()) {
DyeColor newColor = ((DyeItem) stack.getItem()).getColor();
if (state.get(COLOR) != newColor) {
world.setBlockState(pos, state.with(COLOR, newColor));
if (!player.isCreative()) {
stack.decrement(1);
}
return ActionResult.SUCCESS;
} else {
return ActionResult.PASS;
} }
return ActionResult.SUCCESS;
} else { } else {
return ActionResult.FAIL; if (entity instanceof Inventory) {
if (!world.isClient()) {
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, inv, player2) -> new HopperScreenHandler(i, inv, (Inventory) entity), new TranslatableText("block." + EnergonRelics.NAMESPACE + ".phase_shifter")));
}
return ActionResult.SUCCESS;
} else {
return ActionResult.FAIL;
}
} }
} }
} }

View File

@ -161,7 +161,7 @@ public class PhaseShifterBlockEntity extends EnergyReceiverBlockEntity implement
if (getCachedState().get(PhaseShifterBlock.POWERED) && !getCachedState().get(PhaseShifterBlock.IS_OUTPUT)) { if (getCachedState().get(PhaseShifterBlock.POWERED) && !getCachedState().get(PhaseShifterBlock.IS_OUTPUT)) {
List<PhaseShifterBlockEntity> outputs = new ArrayList<>(); List<PhaseShifterBlockEntity> outputs = new ArrayList<>();
for (EnergyTickable tickable : EnergyTicker.allLoaded) { for (EnergyTickable tickable : EnergyTicker.getAllLoaded()) {
if (tickable instanceof PhaseShifterBlockEntity && ((PhaseShifterBlockEntity) tickable).getCachedState().get(PhaseShifterBlock.IS_OUTPUT) && Objects.requireNonNull(((PhaseShifterBlockEntity) tickable).getWorld()).getRegistryKey() == getWorld().getRegistryKey() && ((PhaseShifterBlockEntity) tickable).cooldown == 0 && ((PhaseShifterBlockEntity) tickable).getCachedState().get(PhaseShifterBlock.COLOR) == getCachedState().get(PhaseShifterBlock.COLOR)) { if (tickable instanceof PhaseShifterBlockEntity && ((PhaseShifterBlockEntity) tickable).getCachedState().get(PhaseShifterBlock.IS_OUTPUT) && Objects.requireNonNull(((PhaseShifterBlockEntity) tickable).getWorld()).getRegistryKey() == getWorld().getRegistryKey() && ((PhaseShifterBlockEntity) tickable).cooldown == 0 && ((PhaseShifterBlockEntity) tickable).getCachedState().get(PhaseShifterBlock.COLOR) == getCachedState().get(PhaseShifterBlock.COLOR)) {
outputs.add((PhaseShifterBlockEntity) tickable); outputs.add((PhaseShifterBlockEntity) tickable);
} }