This commit is contained in:
Aleksey 2021-02-27 00:39:17 +03:00
parent db2a555ae9
commit 616c824257
6 changed files with 123 additions and 125 deletions

View file

@ -104,7 +104,7 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
@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) {
if (world.isClient || !state.isOf(this)) return ActionResult.CONSUME; if (world.isClient || !state.isOf(this)) return ActionResult.CONSUME;
if (!this.isPlaceable(state)) { if (!isPlaceable(state)) {
return ActionResult.PASS; return ActionResult.PASS;
} }
BlockEntity blockEntity = world.getBlockEntity(pos); BlockEntity blockEntity = world.getBlockEntity(pos);
@ -114,12 +114,12 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
ItemStack itemStack = player.getStackInHand(hand); ItemStack itemStack = player.getStackInHand(hand);
if (itemStack.isEmpty()) return ActionResult.CONSUME; if (itemStack.isEmpty()) return ActionResult.CONSUME;
pedestal.setStack(0, itemStack.split(1)); pedestal.setStack(0, itemStack.split(1));
this.checkRitual(world, pos); checkRitual(world, pos);
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} else { } else {
ItemStack itemStack = pedestal.getStack(0); ItemStack itemStack = pedestal.getStack(0);
if (player.giveItemStack(itemStack)) { if (player.giveItemStack(itemStack)) {
pedestal.removeStack(world, state); pedestal.removeStack(0);
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }
return ActionResult.FAIL; return ActionResult.FAIL;
@ -151,25 +151,25 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
boolean hasPedestalOver = upState.getBlock() instanceof PedestalBlock; boolean hasPedestalOver = upState.getBlock() instanceof PedestalBlock;
boolean hasPedestalUnder = downState.getBlock() instanceof PedestalBlock; boolean hasPedestalUnder = downState.getBlock() instanceof PedestalBlock;
if (!hasPedestalOver && hasPedestalUnder && upSideSolid) { if (!hasPedestalOver && hasPedestalUnder && upSideSolid) {
return this.getDefaultState().with(STATE, PedestalState.COLUMN_TOP); return getDefaultState().with(STATE, PedestalState.COLUMN_TOP);
} else if (!hasPedestalOver && !hasPedestalUnder && upSideSolid) { } else if (!hasPedestalOver && !hasPedestalUnder && upSideSolid) {
return this.getDefaultState().with(STATE, PedestalState.COLUMN); return getDefaultState().with(STATE, PedestalState.COLUMN);
} else if (hasPedestalUnder && hasPedestalOver) { } else if (hasPedestalUnder && hasPedestalOver) {
return this.getDefaultState().with(STATE, PedestalState.PILLAR); return getDefaultState().with(STATE, PedestalState.PILLAR);
} else if (hasPedestalUnder) { } else if (hasPedestalUnder) {
return this.getDefaultState().with(STATE, PedestalState.PEDESTAL_TOP); return getDefaultState().with(STATE, PedestalState.PEDESTAL_TOP);
} else if (hasPedestalOver) { } else if (hasPedestalOver) {
return this.getDefaultState().with(STATE, PedestalState.BOTTOM); return getDefaultState().with(STATE, PedestalState.BOTTOM);
} }
return this.getDefaultState(); return getDefaultState();
} }
@Override @Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
BlockState updated = this.getUpdatedState(state, direction, newState, world, pos, posFrom); BlockState updated = getUpdatedState(state, direction, newState, world, pos, posFrom);
if (!updated.isOf(this)) return updated; if (!updated.isOf(this)) return updated;
if (!this.isPlaceable(updated)) { if (!isPlaceable(updated)) {
this.moveStoredStack(world, updated, pos); moveStoredStack(world, updated, pos);
} }
return updated; return updated;
} }
@ -185,21 +185,27 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
if (direction == Direction.UP) { if (direction == Direction.UP) {
upSideSolid = newState.isSideSolidFullSquare(world, posFrom, Direction.DOWN) || newState.isIn(BlockTags.WALLS); upSideSolid = newState.isSideSolidFullSquare(world, posFrom, Direction.DOWN) || newState.isIn(BlockTags.WALLS);
hasPedestalOver = newState.getBlock() instanceof PedestalBlock; hasPedestalOver = newState.getBlock() instanceof PedestalBlock;
} else if (direction == Direction.DOWN) { } else {
hasPedestalUnder = newState.getBlock() instanceof PedestalBlock; hasPedestalUnder = newState.getBlock() instanceof PedestalBlock;
} }
BlockState updatedState;
if (!hasPedestalOver && hasPedestalUnder && upSideSolid) { if (!hasPedestalOver && hasPedestalUnder && upSideSolid) {
return state.with(STATE, PedestalState.COLUMN_TOP); updatedState = state.with(STATE, PedestalState.COLUMN_TOP);
} else if (!hasPedestalOver && !hasPedestalUnder && upSideSolid) { } else if (!hasPedestalOver && !hasPedestalUnder && upSideSolid) {
return state.with(STATE, PedestalState.COLUMN); updatedState = state.with(STATE, PedestalState.COLUMN);
} else if (hasPedestalUnder && hasPedestalOver) { } else if (hasPedestalUnder && hasPedestalOver) {
return state.with(STATE, PedestalState.PILLAR); updatedState = state.with(STATE, PedestalState.PILLAR);
} else if (hasPedestalUnder) { } else if (hasPedestalUnder) {
return state.with(STATE, PedestalState.PEDESTAL_TOP); updatedState = state.with(STATE, PedestalState.PEDESTAL_TOP);
} else if (hasPedestalOver) { } else if (hasPedestalOver) {
return state.with(STATE, PedestalState.BOTTOM); updatedState = state.with(STATE, PedestalState.BOTTOM);
} else {
updatedState = state.with(STATE, PedestalState.DEFAULT);
} }
return state.with(STATE, PedestalState.DEFAULT); if (!isPlaceable(updatedState)) {
updatedState = updatedState.with(HAS_ITEM, false).with(HAS_LIGHT, false);
}
return updatedState;
} }
@Override @Override
@ -208,7 +214,7 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
if (state.isOf(this)) { if (state.isOf(this)) {
if (isPlaceable(state)) { if (isPlaceable(state)) {
BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY); BlockEntity blockEntity = builder.getNullable(LootContextParameters.BLOCK_ENTITY);
if (blockEntity != null && blockEntity instanceof PedestalBlockEntity) { if (blockEntity instanceof PedestalBlockEntity) {
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity; PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
if (!pedestal.isEmpty()) { if (!pedestal.isEmpty()) {
drop.add(pedestal.getStack(0)); drop.add(pedestal.getStack(0));
@ -222,63 +228,61 @@ public class PedestalBlock extends BlockBaseNotFull implements BlockEntityProvid
} }
private void moveStoredStack(WorldAccess world, BlockState state, BlockPos pos) { private void moveStoredStack(WorldAccess world, BlockState state, BlockPos pos) {
ItemStack stack = ItemStack.EMPTY;
BlockEntity blockEntity = world.getBlockEntity(pos); BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof PedestalBlockEntity && state.isOf(this)) { if (blockEntity instanceof PedestalBlockEntity && state.isOf(this)) {
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity; PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
stack = pedestal.getStack(0); ItemStack stack = pedestal.removeStack(0);
pedestal.clear();
BlocksHelper.setWithoutUpdate(world, pos, state.with(HAS_ITEM, false));
}
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
BlockPos upPos = pos.up(); moveStoredStack(blockEntity, world, stack, pos.up());
this.moveStoredStack(world, stack, world.getBlockState(upPos), upPos); }
} }
} }
private void moveStoredStack(WorldAccess world, ItemStack stack, BlockState state, BlockPos pos) { private void moveStoredStack(BlockEntity blockEntity, WorldAccess world, ItemStack stack, BlockPos pos) {
BlockEntity blockEntity = world.getBlockEntity(pos); BlockState state = world.getBlockState(pos);
if (!state.isOf(this)) { if (!state.isOf(this)) {
this.dropStoredStack(blockEntity, stack, pos); dropStoredStack(blockEntity, stack, pos);
} else if (state.get(STATE).equals(PedestalState.PILLAR)) { } else if (state.get(STATE).equals(PedestalState.PILLAR)) {
BlockPos upPos = pos.up(); moveStoredStack(blockEntity, world, stack, pos.up());
this.moveStoredStack(world, stack, world.getBlockState(upPos), upPos); } else if (!isPlaceable(state)) {
} else if (!this.isPlaceable(state)) { dropStoredStack(blockEntity, stack, pos);
this.dropStoredStack(blockEntity, stack, pos);
} else if (blockEntity instanceof PedestalBlockEntity) { } else if (blockEntity instanceof PedestalBlockEntity) {
PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity; PedestalBlockEntity pedestal = (PedestalBlockEntity) blockEntity;
if (pedestal.isEmpty()) { if (pedestal.isEmpty()) {
pedestal.setStack(0, stack); pedestal.setStack(0, stack);
} else { } else {
this.dropStoredStack(blockEntity, stack, pos); dropStoredStack(blockEntity, stack, pos);
} }
} else { } else {
this.dropStoredStack(blockEntity, stack, pos); dropStoredStack(blockEntity, stack, pos);
} }
} }
private void dropStoredStack(BlockEntity blockEntity, ItemStack stack, BlockPos pos) { private void dropStoredStack(BlockEntity blockEntity, ItemStack stack, BlockPos pos) {
if (blockEntity != null && blockEntity.getWorld() != null) { if (blockEntity != null && blockEntity.getWorld() != null) {
World world = blockEntity.getWorld(); World world = blockEntity.getWorld();
Block.dropStack(world, this.getDropPos(world, pos), stack); Block.dropStack(world, getDropPos(world, pos), stack);
} }
} }
private BlockPos getDropPos(WorldAccess world, BlockPos pos) { private BlockPos getDropPos(WorldAccess world, BlockPos pos) {
BlockPos dropPos; BlockPos dropPos;
if (world.getBlockState(pos).isAir()) {
return pos;
}
if (world.getBlockState(pos.up()).isAir()) {
return pos.up();
}
for(int i = 2; i < Direction.values().length; i++) { for(int i = 2; i < Direction.values().length; i++) {
dropPos = pos.offset(Direction.byId(i)); dropPos = pos.offset(Direction.byId(i));
if (world.getBlockState(dropPos).isAir()) { if (world.getBlockState(dropPos).isAir()) {
return dropPos.toImmutable(); return dropPos.toImmutable();
} }
} }
if (world.getBlockState(pos.up()).isAir()) { return getDropPos(world, pos.up());
return pos.up();
}
return this.getDropPos(world, pos.up());
} }
protected boolean isPlaceable(BlockState state) { public boolean isPlaceable(BlockState state) {
if (!state.isOf(this)) return false; if (!state.isOf(this)) return false;
PedestalState currentState = state.get(STATE); PedestalState currentState = state.get(STATE);
return currentState != PedestalState.BOTTOM && return currentState != PedestalState.BOTTOM &&

View file

@ -9,7 +9,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.util.Tickable; import net.minecraft.util.Tickable;
import net.minecraft.world.World;
import ru.betterend.blocks.basis.PedestalBlock; import ru.betterend.blocks.basis.PedestalBlock;
import ru.betterend.registry.EndBlockEntities; import ru.betterend.registry.EndBlockEntities;
import ru.betterend.registry.EndItems; import ru.betterend.registry.EndItems;
@ -29,17 +28,11 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
} }
public int getAge() { public int getAge() {
return this.age; return age;
} }
public int getMaxAge() { public int getMaxAge() {
return this.maxAge; return maxAge;
}
@Override
public void clear() {
this.activeItem = ItemStack.EMPTY;
this.markDirty();
} }
@Override @Override
@ -49,42 +42,41 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
return this.activeItem.isEmpty(); return activeItem.isEmpty();
} }
@Override @Override
public ItemStack getStack(int slot) { public ItemStack getStack(int slot) {
return this.activeItem; return activeItem;
} }
@Override @Override
public ItemStack removeStack(int slot, int amount) { public ItemStack removeStack(int slot, int amount) {
return this.removeStack(slot); return removeStack(slot);
} }
@Override @Override
public boolean isValid(int slot, ItemStack stack) { public boolean isValid(int slot, ItemStack stack) {
return this.isEmpty(); return isEmpty();
}
@Override
public void clear() {
activeItem = ItemStack.EMPTY;
markDirty();
} }
@Override @Override
public ItemStack removeStack(int slot) { public ItemStack removeStack(int slot) {
ItemStack stored = this.activeItem; ItemStack stored = activeItem;
this.activeItem = ItemStack.EMPTY; clear();
this.markDirty();
return stored; return stored;
} }
public void removeStack(World world, BlockState state) {
world.setBlockState(pos, state.with(PedestalBlock.HAS_ITEM, false)
.with(PedestalBlock.HAS_LIGHT, false));
this.removeStack(0);
}
@Override @Override
public void setStack(int slot, ItemStack stack) { public void setStack(int slot, ItemStack stack) {
this.activeItem = stack; activeItem = stack;
this.markDirty(); markDirty();
} }
@Override @Override
@ -92,18 +84,19 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
if (world != null && !world.isClient) { if (world != null && !world.isClient) {
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof PedestalBlock) { if (state.getBlock() instanceof PedestalBlock) {
state = state.with(PedestalBlock.HAS_ITEM, !isEmpty()); BlockState trueState = state.with(PedestalBlock.HAS_ITEM, !isEmpty());
if (activeItem.getItem() == EndItems.ETERNAL_CRYSTAL) { if (activeItem.getItem() == EndItems.ETERNAL_CRYSTAL) {
state = state.with(PedestalBlock.HAS_LIGHT, true); trueState = trueState.with(PedestalBlock.HAS_LIGHT, true);
} else { } else {
state = state.with(PedestalBlock.HAS_LIGHT, false); trueState = trueState.with(PedestalBlock.HAS_LIGHT, false);
} }
world.setBlockState(pos, state); world.setBlockState(pos, trueState);
} }
} }
super.markDirty(); super.markDirty();
} }
@Override @Override
public boolean canPlayerUse(PlayerEntity player) { public boolean canPlayerUse(PlayerEntity player) {
return true; return true;
@ -111,12 +104,12 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
@Override @Override
public BlockEntityUpdateS2CPacket toUpdatePacket() { public BlockEntityUpdateS2CPacket toUpdatePacket() {
return new BlockEntityUpdateS2CPacket(pos, 32, this.toInitialChunkDataTag()); return new BlockEntityUpdateS2CPacket(pos, 32, toInitialChunkDataTag());
} }
@Override @Override
public CompoundTag toInitialChunkDataTag() { public CompoundTag toInitialChunkDataTag() {
return this.toTag(new CompoundTag()); return toTag(new CompoundTag());
} }
@Override @Override
@ -124,7 +117,7 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
super.fromTag(state, tag); super.fromTag(state, tag);
if (tag.contains("active_item")) { if (tag.contains("active_item")) {
CompoundTag itemTag = tag.getCompound("active_item"); CompoundTag itemTag = tag.getCompound("active_item");
this.activeItem = ItemStack.fromTag(itemTag); activeItem = ItemStack.fromTag(itemTag);
} }
} }
@ -138,9 +131,9 @@ public class PedestalBlockEntity extends BlockEntity implements Inventory, Ticka
@Override @Override
public void tick() { public void tick() {
if (!isEmpty()) { if (!isEmpty()) {
this.age++; age++;
if (age > maxAge) { if (age > maxAge) {
this.age = 0; age = 0;
} }
} }
} }

View file

@ -15,6 +15,7 @@ import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import ru.betterend.blocks.EternalPedestal; import ru.betterend.blocks.EternalPedestal;
import ru.betterend.blocks.basis.PedestalBlock; import ru.betterend.blocks.basis.PedestalBlock;
import ru.betterend.blocks.entities.PedestalBlockEntity; import ru.betterend.blocks.entities.PedestalBlockEntity;
@ -35,15 +36,16 @@ public class PedestalItemRenderer<T extends PedestalBlockEntity> extends BlockEn
public void render(T blockEntity, float tickDelta, MatrixStack matrices, public void render(T blockEntity, float tickDelta, MatrixStack matrices,
VertexConsumerProvider vertexConsumers, int light, int overlay) { VertexConsumerProvider vertexConsumers, int light, int overlay) {
if (blockEntity.isEmpty()) return; World world = blockEntity.getWorld();
if (blockEntity.isEmpty() || world == null) return;
BlockState state = blockEntity.getWorld().getBlockState(blockEntity.getPos()); BlockState state = world.getBlockState(blockEntity.getPos());
if (!(state.getBlock() instanceof PedestalBlock)) return; if (!(state.getBlock() instanceof PedestalBlock)) return;
ItemStack activeItem = blockEntity.getStack(0); ItemStack activeItem = blockEntity.getStack(0);
matrices.push(); matrices.push();
MinecraftClient minecraft = MinecraftClient.getInstance(); MinecraftClient minecraft = MinecraftClient.getInstance();
BakedModel model = minecraft.getItemRenderer().getHeldItemModel(activeItem, blockEntity.getWorld(), null); BakedModel model = minecraft.getItemRenderer().getHeldItemModel(activeItem, world, null);
Vector3f translate = model.getTransformation().ground.translation; Vector3f translate = model.getTransformation().ground.translation;
PedestalBlock pedestal = (PedestalBlock) state.getBlock(); PedestalBlock pedestal = (PedestalBlock) state.getBlock();
matrices.translate(translate.getX(), translate.getY(), translate.getZ()); matrices.translate(translate.getX(), translate.getY(), translate.getZ());

View file

@ -10,8 +10,8 @@ import me.shedaniel.rei.api.RecipeDisplay;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
public class REIAlloyingFuelDisplay implements RecipeDisplay { public class REIAlloyingFuelDisplay implements RecipeDisplay {
private EntryStack fuel; private final EntryStack fuel;
private int fuelTime; private final int fuelTime;
public REIAlloyingFuelDisplay(EntryStack fuel, int fuelTime) { public REIAlloyingFuelDisplay(EntryStack fuel, int fuelTime) {
this.fuel = fuel; this.fuel = fuel;

View file

@ -52,7 +52,6 @@ public class REIPlugin implements REIPluginV0 {
recipeHelper.registerRecipes(INFUSION, InfusionRecipe.class, REIInfusionDisplay::new); recipeHelper.registerRecipes(INFUSION, InfusionRecipe.class, REIInfusionDisplay::new);
FuelRegistryImpl.INSTANCE.getFuelTimes().forEach((item, time) -> { FuelRegistryImpl.INSTANCE.getFuelTimes().forEach((item, time) -> {
if (time >= 2000) { if (time >= 2000) {
System.out.println(item);
recipeHelper.registerDisplay(new REIAlloyingFuelDisplay(EntryStack.create(item), time)); recipeHelper.registerDisplay(new REIAlloyingFuelDisplay(EntryStack.create(item), time));
} }
}); });

View file

@ -48,7 +48,7 @@ public class InfusionRitual implements Inventory {
if (world == null || world.isClient || worldPos == null) return; if (world == null || world.isClient || worldPos == null) return;
BlockEntity inputEntity = world.getBlockEntity(worldPos); BlockEntity inputEntity = world.getBlockEntity(worldPos);
if (inputEntity instanceof InfusionPedestalEntity) { if (inputEntity instanceof InfusionPedestalEntity) {
this.input = (InfusionPedestalEntity) inputEntity; input = (InfusionPedestalEntity) inputEntity;
} }
int i = 0; int i = 0;
for(Point point : PEDESTALS_MAP) { for(Point point : PEDESTALS_MAP) {
@ -65,59 +65,59 @@ public class InfusionRitual implements Inventory {
public boolean checkRecipe() { public boolean checkRecipe() {
if (!isValid()) return false; if (!isValid()) return false;
InfusionRecipe recipe = this.world.getRecipeManager().getFirstMatch(InfusionRecipe.TYPE, this, world).orElse(null); InfusionRecipe recipe = world.getRecipeManager().getFirstMatch(InfusionRecipe.TYPE, this, world).orElse(null);
if (hasRecipe()) { if (hasRecipe()) {
if (recipe == null) { if (recipe == null) {
this.stop(); stop();
return false; return false;
} else if (recipe.getInfusionTime() != time) { } else if (recipe.getInfusionTime() != time) {
this.activeRecipe = recipe; activeRecipe = recipe;
this.time = this.activeRecipe.getInfusionTime(); time = activeRecipe.getInfusionTime();
this.progress = 0; progress = 0;
this.markDirty(); markDirty();
} else if (activeRecipe == null) { } else if (activeRecipe == null) {
this.activeRecipe = recipe; activeRecipe = recipe;
} }
return true; return true;
} }
if (recipe != null) { if (recipe != null) {
this.activeRecipe = recipe; activeRecipe = recipe;
this.time = this.activeRecipe.getInfusionTime(); time = activeRecipe.getInfusionTime();
this.hasRecipe = true; hasRecipe = true;
this.progress = 0; progress = 0;
this.markDirty(); markDirty();
return true; return true;
} }
return false; return false;
} }
public void stop() { public void stop() {
this.activeRecipe = null; activeRecipe = null;
this.hasRecipe = false; hasRecipe = false;
this.progress = 0; progress = 0;
this.time = 0; time = 0;
this.markDirty(); markDirty();
} }
public void tick() { public void tick() {
if (isDirty) { if (isDirty) {
this.configure(); configure();
this.isDirty = false; isDirty = false;
} }
if (!isValid() || !hasRecipe()) return; if (!isValid() || !hasRecipe()) return;
if (!checkRecipe()) return; if (!checkRecipe()) return;
this.progress++; progress++;
if (progress == time) { if (progress == time) {
BlockState inputState = world.getBlockState(input.getPos()); BlockState inputState = world.getBlockState(input.getPos());
this.input.removeStack(world, inputState); input.removeStack(0);
this.input.setStack(0, activeRecipe.craft(this)); input.setStack(0, activeRecipe.craft(this));
for (PedestalBlockEntity catalyst : catalysts) { for (PedestalBlockEntity catalyst : catalysts) {
catalyst.removeStack(world, world.getBlockState(catalyst.getPos())); catalyst.removeStack(0);
} }
this.stop(); stop();
} else { } else {
ServerWorld world = (ServerWorld) this.world; ServerWorld world = (ServerWorld) this.world;
BlockPos target = this.worldPos.up(); BlockPos target = worldPos.up();
double tx = target.getX() + 0.5; double tx = target.getX() + 0.5;
double ty = target.getY() + 0.5; double ty = target.getY() + 0.5;
double tz = target.getZ() + 0.5; double tz = target.getZ() + 0.5;
@ -137,7 +137,7 @@ public class InfusionRitual implements Inventory {
@Override @Override
public boolean isValid(int slot, ItemStack stack) { public boolean isValid(int slot, ItemStack stack) {
return this.isValid(); return isValid();
} }
public boolean isValid() { public boolean isValid() {
@ -149,7 +149,7 @@ public class InfusionRitual implements Inventory {
} }
public boolean hasRecipe() { public boolean hasRecipe() {
return this.hasRecipe; return hasRecipe;
} }
public void setLocation(World world, BlockPos pos) { public void setLocation(World world, BlockPos pos) {
@ -161,7 +161,7 @@ public class InfusionRitual implements Inventory {
@Override @Override
public void clear() { public void clear() {
if (!isValid()) return; if (!isValid()) return;
this.input.clear(); input.clear();
for (PedestalBlockEntity catalyst : catalysts) { for (PedestalBlockEntity catalyst : catalysts) {
catalyst.clear(); catalyst.clear();
} }
@ -181,24 +181,24 @@ public class InfusionRitual implements Inventory {
public ItemStack getStack(int slot) { public ItemStack getStack(int slot) {
if (slot > 8) return ItemStack.EMPTY; if (slot > 8) return ItemStack.EMPTY;
if (slot == 0) { if (slot == 0) {
return this.input.getStack(0); return input.getStack(0);
} else { } else {
return this.catalysts[slot - 1].getStack(0); return catalysts[slot - 1].getStack(0);
} }
} }
@Override @Override
public ItemStack removeStack(int slot, int amount) { public ItemStack removeStack(int slot, int amount) {
return this.removeStack(slot); return removeStack(slot);
} }
@Override @Override
public ItemStack removeStack(int slot) { public ItemStack removeStack(int slot) {
if (slot > 8) return ItemStack.EMPTY; if (slot > 8) return ItemStack.EMPTY;
if (slot == 0) { if (slot == 0) {
return this.input.removeStack(0); return input.removeStack(0);
} else { } else {
return this.catalysts[slot - 1].getStack(0); return catalysts[slot - 1].getStack(0);
} }
} }
@ -206,16 +206,16 @@ public class InfusionRitual implements Inventory {
public void setStack(int slot, ItemStack stack) { public void setStack(int slot, ItemStack stack) {
if (slot > 8) return; if (slot > 8) return;
if (slot == 0) { if (slot == 0) {
this.input.setStack(0, stack); input.setStack(0, stack);
} else { } else {
this.catalysts[slot - 1].setStack(0, stack); catalysts[slot - 1].setStack(0, stack);
} }
} }
@Override @Override
public void markDirty() { public void markDirty() {
if (isValid()) { if (isValid()) {
this.input.markDirty(); input.markDirty();
for (PedestalBlockEntity catalyst : catalysts) { for (PedestalBlockEntity catalyst : catalysts) {
catalyst.markDirty(); catalyst.markDirty();
} }
@ -229,15 +229,15 @@ public class InfusionRitual implements Inventory {
public void fromTag(CompoundTag tag) { public void fromTag(CompoundTag tag) {
if (tag.contains("recipe")) { if (tag.contains("recipe")) {
this.hasRecipe = tag.getBoolean("recipe"); hasRecipe = tag.getBoolean("recipe");
this.progress = tag.getInt("progress"); progress = tag.getInt("progress");
this.time = tag.getInt("time"); time = tag.getInt("time");
} }
} }
public CompoundTag toTag(CompoundTag tag) { public CompoundTag toTag(CompoundTag tag) {
if (hasRecipe()) { if (hasRecipe()) {
tag.putBoolean("recipe", this.hasRecipe); tag.putBoolean("recipe", hasRecipe);
tag.putInt("progress", progress); tag.putInt("progress", progress);
tag.putInt("time", time); tag.putInt("time", time);
} }