0.0.9
EnergonRelics/pipeline/head This commit looks good Details

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
**Beta 0.0.9**
* Fix Interaction Bug With Phase Shifter Block
**Beta 0.0.8**
* Add Phase Shifter Block
* Fix Bugs

View File

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

View File

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

View File

@ -17,11 +17,17 @@ import java.util.Objects;
@ApiStatus.Internal
public class EnergyTicker {
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

View File

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

View File

@ -82,28 +82,33 @@ public class PhaseShifterBlock extends EnergyBlock {
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
ItemStack stack = player.getStackInHand(hand);
BlockEntity entity = world.getBlockEntity(pos);
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;
}
ActionResult result = super.onUse(state, world, pos, player, hand, hit);
if (result != ActionResult.PASS) {
return result;
} else {
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")));
ItemStack stack = player.getStackInHand(hand);
BlockEntity entity = world.getBlockEntity(pos);
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 {
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)) {
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)) {
outputs.add((PhaseShifterBlockEntity) tickable);
}