Portal fixes and optimization

This commit is contained in:
Aleksey 2020-10-30 21:19:02 +03:00
parent 81e4098a72
commit 31f057eca5
11 changed files with 151 additions and 471 deletions

View file

@ -7,14 +7,9 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.PortalFrameHelper;
public class RunedFlavolite extends BlockBase {
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVATED;
@ -30,20 +25,4 @@ public class RunedFlavolite extends BlockBase {
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(ACTIVATED);
}
@Override
public void onBroken(WorldAccess world, BlockPos pos, BlockState state) {
BlockPos bottom = PortalFrameHelper.findBottomCorner((World) world, pos, this);
BlockPos top = PortalFrameHelper.findTopCorner((World) world, pos, this);
if (bottom == null || top == null) return;
for (BlockPos position : BlockPos.iterate(bottom, top)) {
if (position.equals(pos)) continue;
BlockState posState = world.getBlockState(position);
if (posState.getBlock() instanceof RunedFlavolite && posState.get(ACTIVATED)) {
BlocksHelper.setWithoutUpdate(world, position, posState.with(ACTIVATED, false));
} else if (posState.isOf(EndBlocks.END_PORTAL_BLOCK)) {
world.removeBlock(position, false);
}
}
}
}