112 lines
4 KiB
Java
112 lines
4 KiB
Java
package techreborn.blocks;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.BlockPos;
|
|
import net.minecraft.util.EnumFacing;
|
|
import net.minecraft.util.EnumParticleTypes;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
import reborncore.common.blocks.BlockMachineBase;
|
|
import reborncore.common.blocks.IRotationTexture;
|
|
import techreborn.Core;
|
|
import techreborn.client.GuiHandler;
|
|
import techreborn.client.TechRebornCreativeTab;
|
|
import techreborn.tiles.TileIronFurnace;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
public class BlockIronFurnace extends BlockMachineBase implements IRotationTexture {
|
|
|
|
public BlockIronFurnace() {
|
|
super();
|
|
setUnlocalizedName("techreborn.ironfurnace");
|
|
setCreativeTab(TechRebornCreativeTab.instance);
|
|
}
|
|
|
|
@Override
|
|
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
|
|
return new TileIronFurnace();
|
|
}
|
|
|
|
@Override
|
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
|
if (!player.isSneaking())
|
|
player.openGui(Core.INSTANCE, GuiHandler.ironFurnace, world, x, y, z);
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
|
List<ItemStack> items = new ArrayList<ItemStack>();
|
|
items.add(new ItemStack(this));
|
|
return items;
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
@SuppressWarnings("incomplete-switch")
|
|
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
|
|
{
|
|
if (this.isActive(state))
|
|
{
|
|
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
|
double d0 = (double)pos.getX() + 0.5D;
|
|
double d1 = (double)pos.getY() + rand.nextDouble() * 6.0D / 16.0D;
|
|
double d2 = (double)pos.getZ() + 0.5D;
|
|
double d3 = 0.52D;
|
|
double d4 = rand.nextDouble() * 0.6D - 0.3D;
|
|
|
|
switch (enumfacing)
|
|
{
|
|
case WEST:
|
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
|
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
|
break;
|
|
case EAST:
|
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
|
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
|
break;
|
|
case NORTH:
|
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]);
|
|
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]);
|
|
break;
|
|
case SOUTH:
|
|
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]);
|
|
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]);
|
|
}
|
|
}
|
|
}
|
|
|
|
private final String prefix = "techreborn:blocks/machine/";
|
|
|
|
@Override
|
|
public String getFrontOff() {
|
|
return prefix + "iron_furnace_front_off";
|
|
}
|
|
|
|
@Override
|
|
public String getFrontOn() {
|
|
return prefix + "iron_furnace_front_on";
|
|
}
|
|
|
|
@Override
|
|
public String getSide() {
|
|
return prefix + "iron_furnace_side";
|
|
}
|
|
|
|
@Override
|
|
public String getTop() {
|
|
return prefix + "iron_furnace_top";
|
|
}
|
|
|
|
@Override
|
|
public String getBottom() {
|
|
return prefix + "iron_furnace_bottom";
|
|
}
|
|
}
|