Fixed hopper & dropper pedestal iteraction, added comparator ouytput for pedestals

This commit is contained in:
Aleksey 2020-11-22 22:24:36 +03:00
parent d9aa50fe1c
commit 0180fcf11e
3 changed files with 33 additions and 9 deletions

View file

@ -109,7 +109,7 @@ public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvid
if (pedestal.isEmpty()) { if (pedestal.isEmpty()) {
ItemStack itemStack = player.getStackInHand(hand); ItemStack itemStack = player.getStackInHand(hand);
if (itemStack.isEmpty()) return ActionResult.CONSUME; if (itemStack.isEmpty()) return ActionResult.CONSUME;
pedestal.setStack(world, state, itemStack.split(1)); pedestal.setStack(0, itemStack.split(1));
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} else { } else {
ItemStack itemStack = pedestal.getStack(0); ItemStack itemStack = pedestal.getStack(0);
@ -305,6 +305,17 @@ public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvid
return new PedestalBlockEntity(); return new PedestalBlockEntity();
} }
@Override
public boolean hasComparatorOutput(BlockState state) {
return state.getBlock() instanceof BlockPedestal;
}
@Override
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
System.out.println(state.get(HAS_ITEM));
return state.get(HAS_ITEM) ? 15 : 0;
}
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
String texture = Registry.BLOCK.getId(this).getPath(); String texture = Registry.BLOCK.getId(this).getPath();

View file

@ -62,6 +62,11 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
return this.removeStack(slot); return this.removeStack(slot);
} }
@Override
public boolean isValid(int slot, ItemStack stack) {
return this.isEmpty();
}
@Override @Override
public ItemStack removeStack(int slot) { public ItemStack removeStack(int slot) {
ItemStack stored = this.activeItem; ItemStack stored = this.activeItem;
@ -82,13 +87,21 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
this.markDirty(); this.markDirty();
} }
public void setStack(World world, BlockState state, ItemStack stack) { @Override
state = state.with(BlockPedestal.HAS_ITEM, true); public void markDirty() {
if (stack.getItem() == EndItems.ETERNAL_CRYSTAL) { if (world != null && !world.isClient) {
state = state.with(BlockPedestal.HAS_LIGHT, true); BlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockPedestal) {
state = state.with(BlockPedestal.HAS_ITEM, !isEmpty());
if (activeItem.getItem() == EndItems.ETERNAL_CRYSTAL) {
state = state.with(BlockPedestal.HAS_LIGHT, true);
} else {
state = state.with(BlockPedestal.HAS_LIGHT, false);
}
world.setBlockState(pos, state);
}
} }
world.setBlockState(pos, state); super.markDirty();
this.setStack(0, stack);
} }
@Override @Override

View file

@ -107,7 +107,7 @@ public class InfusionRitual implements Inventory {
if (progress == time) { if (progress == time) {
BlockState inputState = world.getBlockState(input.getPos()); BlockState inputState = world.getBlockState(input.getPos());
this.input.removeStack(world, inputState); this.input.removeStack(world, inputState);
this.input.setStack(world, inputState, activeRecipe.craft(this)); this.input.setStack(0, activeRecipe.craft(this));
for (PedestalBlockEntity catalyst : catalysts) { for (PedestalBlockEntity catalyst : catalysts) {
catalyst.removeStack(world, world.getBlockState(catalyst.getPos())); catalyst.removeStack(world, world.getBlockState(catalyst.getPos()));
} }