Infusion starts by placing ingredients at any pedestals.

This commit is contained in:
Aleksey 2021-01-23 13:08:29 +03:00
parent f62f88e4bd
commit 482dcc1638
3 changed files with 34 additions and 67 deletions

View file

@ -38,39 +38,32 @@ public class EternalPedestal extends PedestalBlock {
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
ActionResult result = super.onUse(state, world, pos, player, hand, hit);
if (result.equals(ActionResult.SUCCESS)) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof EternalPedestalEntity) {
EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
BlockState updatedState = world.getBlockState(pos);
if (pedestal.isEmpty() && updatedState.get(ACTIVATED)) {
public void checkRitual(World world, BlockPos pos) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof EternalPedestalEntity) {
EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
BlockState updatedState = world.getBlockState(pos);
if (pedestal.isEmpty() && updatedState.get(ACTIVATED)) {
if (pedestal.hasRitual()) {
EternalRitual ritual = pedestal.getRitual();
ritual.removePortal();
}
world.setBlockState(pos, updatedState.with(ACTIVATED, false));
} else {
ItemStack itemStack = pedestal.getStack(0);
if (itemStack.getItem() == EndItems.ETERNAL_CRYSTAL) {
world.setBlockState(pos, updatedState.with(ACTIVATED, true));
if (pedestal.hasRitual()) {
EternalRitual ritual = pedestal.getRitual();
ritual.removePortal();
}
world.setBlockState(pos, updatedState.with(ACTIVATED, false));
} else {
ItemStack itemStack = pedestal.getStack(0);
if (itemStack.getItem() == EndItems.ETERNAL_CRYSTAL) {
world.setBlockState(pos, updatedState.with(ACTIVATED, true));
if (pedestal.hasRitual()) {
pedestal.getRitual().checkStructure();
} else {
EternalRitual ritual = new EternalRitual(world, pos);
ritual.checkStructure();
}
pedestal.getRitual().checkStructure();
} else {
EternalRitual ritual = new EternalRitual(world, pos);
ritual.checkStructure();
}
}
}
}
return result;
}
@Override
protected void activate(World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
BlockState updated = super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);