Skip to content

Instantly share code, notes, and snippets.

@Euphillya
Created March 29, 2020 00:50
Show Gist options
  • Save Euphillya/c76e9c6f3e22c67b291a4ea4e9316f3b to your computer and use it in GitHub Desktop.
Save Euphillya/c76e9c6f3e22c67b291a4ea4e9316f3b to your computer and use it in GitHub Desktop.
package net.minecraft.server;
public class BlockEnderChest extends BlockChestAbstract<TileEntityEnderChest> implements IBlockWaterlogged {
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
public static final BlockStateBoolean c = BlockProperties.C;
protected static final VoxelShape d = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 14.0D, 15.0D);
public static final ChatMessage e = new ChatMessage("container.enderchest", new Object[0]);
protected BlockEnderChest(Block.Info block_info) {
super(block_info, () -> {
return TileEntityTypes.ENDER_CHEST;
});
this.p((IBlockData) ((IBlockData) ((IBlockData) this.blockStateList.getBlockData()).set(BlockEnderChest.FACING, EnumDirection.NORTH)).set(BlockEnderChest.c, false));
}
@Override
public VoxelShape a(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition, VoxelShapeCollision voxelshapecollision) {
return BlockEnderChest.d;
}
@Override
public EnumRenderType c(IBlockData iblockdata) {
return EnumRenderType.ENTITYBLOCK_ANIMATED;
}
@Override
public IBlockData getPlacedState(BlockActionContext blockactioncontext) {
Fluid fluid = blockactioncontext.getWorld().getFluid(blockactioncontext.getClickPosition());
return (IBlockData) ((IBlockData) this.getBlockData().set(BlockEnderChest.FACING, blockactioncontext.f().opposite())).set(BlockEnderChest.c, fluid.getType() == FluidTypes.WATER);
}
@Override
public EnumInteractionResult interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) {
InventoryEnderChest inventoryenderchest = entityhuman.getEnderChest();
TileEntity tileentity = world.getTileEntity(blockposition);
if (inventoryenderchest != null && tileentity instanceof TileEntityEnderChest) {
BlockPosition blockposition1 = blockposition.up();
if (world.getType(blockposition1).isOccluding(world, blockposition1)) {
return EnumInteractionResult.SUCCESS;
} else if (world.isClientSide) {
return EnumInteractionResult.SUCCESS;
} else {
TileEntityEnderChest tileentityenderchest = (TileEntityEnderChest) tileentity;
inventoryenderchest.a(tileentityenderchest);
entityhuman.openContainer(new TileInventory((i, playerinventory, entityhuman1) -> {
// Purpur Suggest by Docta
if (net.pl3x.purpur.PurpurConfig.enderChestSixRows) {
String ender_container = hasEnderChestPermission(entityhuman);
if (ender_container.equalsIgnoreCase("EnderChest6")) {
return ContainerChest.Ender6(i, playerinventory, inventoryenderchest);
} else if (ender_container.equalsIgnoreCase("EnderChest5")) {
return ContainerChest.Ender5(i, playerinventory, inventoryenderchest);
} else if (ender_container.equalsIgnoreCase("EnderChest4")) {
return ContainerChest.Ender4(i, playerinventory, inventoryenderchest);
} else if (ender_container.equalsIgnoreCase("EnderChest3")) {
return ContainerChest.Ender3(i, playerinventory, inventoryenderchest);
} else if (ender_container.equalsIgnoreCase("EnderChest2")) {
return ContainerChest.Ender2(i, playerinventory, inventoryenderchest);
} else if (ender_container.equalsIgnoreCase("EnderChest1")) {
return ContainerChest.Ender1(i, playerinventory, inventoryenderchest);
} else {
return ContainerChest.b(i, playerinventory, inventoryenderchest); // Purpur (max slot)
}
}
return ContainerChest.a(i, playerinventory, inventoryenderchest);
}, BlockEnderChest.e));
entityhuman.a(StatisticList.OPEN_ENDERCHEST);
return EnumInteractionResult.SUCCESS;
}
} else {
return EnumInteractionResult.SUCCESS;
}
}
@Override
public TileEntity createTile(IBlockAccess iblockaccess) {
return new TileEntityEnderChest();
}
@Override
public IBlockData a(IBlockData iblockdata, EnumBlockRotation enumblockrotation) {
return (IBlockData) iblockdata.set(BlockEnderChest.FACING, enumblockrotation.a((EnumDirection) iblockdata.get(BlockEnderChest.FACING)));
}
@Override
public IBlockData a(IBlockData iblockdata, EnumBlockMirror enumblockmirror) {
return iblockdata.a(enumblockmirror.a((EnumDirection) iblockdata.get(BlockEnderChest.FACING)));
}
@Override
protected void a(BlockStateList.a<Block, IBlockData> blockstatelist_a) {
blockstatelist_a.a(BlockEnderChest.FACING, BlockEnderChest.c);
}
@Override
public Fluid a_(IBlockData iblockdata) {
return (Boolean) iblockdata.get(BlockEnderChest.c) ? FluidTypes.WATER.a(false) : super.a_(iblockdata);
}
@Override
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
if ((Boolean) iblockdata.get(BlockEnderChest.c)) {
generatoraccess.getFluidTickList().a(blockposition, FluidTypes.WATER, FluidTypes.WATER.a((IWorldReader) generatoraccess));
}
return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
}
@Override
public boolean a(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition, PathMode pathmode) {
return false;
}
// Suggestion DoctaEnkoda for Purpur
// HasPermissionforNumberRows
private String hasEnderChestPermission(EntityHuman entityhuman) {
// Just for TEST add to Config
if (entityhuman.getBukkitEntity().hasPermission(net.pl3x.purpur.PurpurConfig.enderChest.SixRows)) {
return "EnderChest6";
} else if (entityhuman.getBukkitEntity().hasPermission(net.pl3x.purpur.PurpurConfig.enderChest.FiveRows)) {
return "EnderChest5";
} else if (entityhuman.getBukkitEntity().hasPermission(net.pl3x.purpur.PurpurConfig.enderChest.FourRows)) {
return "EnderChest4";
} else if (entityhuman.getBukkitEntity().hasPermission(net.pl3x.purpur.PurpurConfig.enderChest.ThreeRows)) {
return "EnderChest3";
} else if (entityhuman.getBukkitEntity().hasPermission(net.pl3x.purpur.PurpurConfig.enderChest.TwoRows)) {
return "EnderChest2";
} else if (entityhuman.getBukkitEntity().hasPermission(net.pl3x.purpur.PurpurConfig.enderChest.OneRows)) {
return "EnderChest1";
} else {
return "EnderChest3"; // return vanilla
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment