2019-02-17 22:51:05 +01:00
|
|
|
package de.ellpeck.naturesaura.blocks;
|
|
|
|
|
|
|
|
import de.ellpeck.naturesaura.NaturesAura;
|
|
|
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
|
2019-02-18 12:15:18 +01:00
|
|
|
import de.ellpeck.naturesaura.blocks.tiles.render.RenderEnderCrate;
|
|
|
|
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
2019-02-17 22:51:05 +01:00
|
|
|
import net.minecraft.block.SoundType;
|
|
|
|
import net.minecraft.block.material.Material;
|
2019-02-18 12:15:18 +01:00
|
|
|
import net.minecraft.block.state.BlockFaceShape;
|
2019-02-17 22:51:05 +01:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2019-02-18 12:15:18 +01:00
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
2019-02-17 22:51:05 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
import net.minecraft.util.EnumHand;
|
2019-02-18 12:15:18 +01:00
|
|
|
import net.minecraft.util.EnumParticleTypes;
|
|
|
|
import net.minecraft.util.Tuple;
|
2019-02-17 22:51:05 +01:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2019-02-18 12:15:18 +01:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2019-02-17 22:51:05 +01:00
|
|
|
import net.minecraft.world.World;
|
2019-02-18 12:15:18 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2019-02-17 22:51:05 +01:00
|
|
|
|
2019-02-18 12:15:18 +01:00
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider {
|
2019-02-17 22:51:05 +01:00
|
|
|
public BlockEnderCrate() {
|
|
|
|
super(Material.ROCK, "ender_crate", TileEntityEnderCrate.class, "ender_crate");
|
|
|
|
this.setSoundType(SoundType.STONE);
|
|
|
|
this.setHardness(5F);
|
2019-02-18 12:15:18 +01:00
|
|
|
this.setLightLevel(0.75F);
|
2019-02-17 22:51:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@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;
|
|
|
|
}
|
2019-02-18 12:15:18 +01:00
|
|
|
|
|
|
|
@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<Class, TileEntitySpecialRenderer> getTESR() {
|
|
|
|
return new Tuple<>(TileEntityEnderCrate.class, new RenderEnderCrate());
|
|
|
|
}
|
2019-02-17 22:51:05 +01:00
|
|
|
}
|