package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate; import de.ellpeck.naturesaura.blocks.tiles.render.RenderEnderCrate; import de.ellpeck.naturesaura.reg.ITESRProvider; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Random; public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider { public BlockEnderCrate() { super(Material.ROCK, "ender_crate", TileEntityEnderCrate.class, "ender_crate"); this.setSoundType(SoundType.STONE); this.setHardness(5F); this.setLightLevel(0.75F); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { TileEntity tile = worldIn.getTileEntity(pos); if (tile instanceof TileEntityEnderCrate) { TileEntityEnderCrate crate = (TileEntityEnderCrate) tile; if (crate.canOpen()) playerIn.openGui(NaturesAura.MOD_ID, 0, worldIn, pos.getX(), pos.getY(), pos.getZ()); } } return true; } @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { for (int i = 0; i < 3; ++i) { int j = rand.nextInt(2) * 2 - 1; int k = rand.nextInt(2) * 2 - 1; double d0 = (double) pos.getX() + 0.5D + 0.25D * (double) j; double d1 = (double) ((float) pos.getY() + rand.nextFloat()); double d2 = (double) pos.getZ() + 0.5D + 0.25D * (double) k; double d3 = (double) (rand.nextFloat() * (float) j); double d4 = ((double) rand.nextFloat() - 0.5D) * 0.125D; double d5 = (double) (rand.nextFloat() * (float) k); worldIn.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5); } } @Override @SideOnly(Side.CLIENT) public Tuple getTESR() { return new Tuple<>(TileEntityEnderCrate.class, new RenderEnderCrate()); } }