Bonjour j’ai creer un four il marche
mais j’ai 2 petits bugs
tout d’abord quand je pose le bloc il est orienté sa marche mais quand je commence a faire cuire quelque chose ( la texture de la facade change ) il s’oriente vers une autre direction que celle dans laquelle je l’ai posé ( je pense que c’est celle de base )
2eme probleme quand je fait cuire mes items il ne m’affiche pas la barre de progression de cuisson etc
je pense que l’orientation est liée a la classe du bloc donc :
| |
| package Universe.blocks; |
| |
| import java.util.Random; |
| |
| import Universe.common.UniverseMain; |
| import Universe.entity.TileEntityCompresseur; |
| |
| import net.minecraft.block.Block; |
| import net.minecraft.block.BlockContainer; |
| import net.minecraft.block.material.Material; |
| import net.minecraft.client.renderer.texture.IconRegister; |
| import net.minecraft.entity.EntityLivingBase; |
| import net.minecraft.entity.player.EntityPlayer; |
| import net.minecraft.inventory.Container; |
| import net.minecraft.inventory.IInventory; |
| import net.minecraft.item.ItemStack; |
| import net.minecraft.tileentity.TileEntity; |
| import net.minecraft.util.Icon; |
| import net.minecraft.util.MathHelper; |
| import net.minecraft.world.World; |
| import cpw.mods.fml.common.network.FMLNetworkHandler; |
| import cpw.mods.fml.relauncher.Side; |
| import cpw.mods.fml.relauncher.SideOnly; |
| |
| public class Compresseur extends BlockContainer { |
| |
| private final boolean isActive; |
| |
| @SideOnly(Side.CLIENT) |
| private Icon iconFront; |
| |
| private static boolean keepInventory; |
| |
| public Compresseur(int id, boolean isActive) { |
| super(id, Material.rock); |
| |
| this.isActive = isActive; |
| } |
| |
| @SideOnly(Side.CLIENT) |
| public void registerIcons(IconRegister iconRegister) |
| { |
| this.blockIcon = iconRegister.registerIcon(Universe.common.UniverseMain.UltimateUniverseMod + ":" + "Compresseur"); |
| this.iconFront = iconRegister.registerIcon(Universe.common.UniverseMain.UltimateUniverseMod + ":" + (this.isActive ? "CompresseurFront_on" : "CompresseurFront_off")); |
| } |
| |
| @SideOnly(Side.CLIENT) |
| public Icon getIcon(int side, int metadata){ |
| return side == metadata ? this.iconFront : this.blockIcon; |
| |
| } |
| |
| public int idDropped(int par1, Random random, int par3) |
| { |
| return UniverseMain.CompresseurOff.blockID; |
| } |
| |
| public void onBlockAdded(World world, int x,int y, int z) |
| { |
| super.onBlockAdded(world, x, y, z); |
| this.setDefaultDirection(world, x, y, z); |
| } |
| |
| private void setDefaultDirection(World world, int x, int y, int z) |
| { |
| if(!world.isRemote) |
| { |
| int l = world.getBlockId(x, y, z - 1); |
| int il = world.getBlockId(x, y, z + 1); |
| int jl = world.getBlockId(x - 1, y, z); |
| int kl = world.getBlockId(x + 1, y, z); |
| byte b0 = 3; |
| |
| if(Block.opaqueCubeLookup[1] && ! Block.opaqueCubeLookup[il]){ |
| b0 = 3; |
| } |
| |
| if(Block.opaqueCubeLookup[il] && !Block.opaqueCubeLookup[l]){ |
| b0 = 2; |
| } |
| |
| if(Block.opaqueCubeLookup[kl] && !Block.opaqueCubeLookup[jl]){ |
| b0 = 5; |
| } |
| |
| if(Block.opaqueCubeLookup[jl] && !Block.opaqueCubeLookup[kl]){ |
| b0 = 4; |
| } |
| |
| world.setBlockMetadataWithNotify(x, y, z, b0, 2); |
| } |
| |
| } |
| |
| public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) |
| { |
| if(!world.isRemote) { |
| FMLNetworkHandler.openGui(player, UniverseMain.instance, Universe.common.UniverseMain.guiIdCompresseur, world, x, y, z); |
| } |
| return true; |
| } |
| |
| public TileEntity createNewTileEntity(World world) { |
| |
| return new TileEntityCompresseur(); |
| } |
| |
| public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLivingBase, ItemStack itemStack) |
| { |
| int l = MathHelper.floor_double((double)(entityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5F) & 3; |
| |
| if(l == 0) { |
| world.setBlockMetadataWithNotify(x, y, z, 2, 2); |
| } |
| |
| if(l == 1) { |
| world.setBlockMetadataWithNotify(x, y, z, 5, 2); |
| } |
| |
| if(l == 2) { |
| world.setBlockMetadataWithNotify(x, y, z, 3, 2); |
| } |
| |
| if(l == 3) { |
| world.setBlockMetadataWithNotify(x, y, z,4, 2); |
| } |
| |
| if(itemStack.hasDisplayName()) { |
| ((TileEntityCompresseur)world.getBlockTileEntity(x, y, z)).setGuiDisplayName(itemStack.getDisplayName()); |
| } |
| } |
| |
| public static void updateCompresseurBlockState(boolean active, World worldObj, int xCoord, int yCoord, int zCoord) { |
| int i = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); |
| TileEntity tilentity = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord); |
| keepInventory = true; |
| |
| if (active) { |
| worldObj.setBlock(xCoord, yCoord, zCoord, Universe.common.UniverseMain.CompresseurOn.blockID); |
| } |
| else { |
| worldObj.setBlock(xCoord, yCoord, zCoord, Universe.common.UniverseMain.CompresseurOff.blockID); |
| } |
| |
| keepInventory = false; |
| |
| worldObj.setBlockMetadataWithNotify(zCoord, yCoord, zCoord, i, 2); |
| |
| if(tilentity != null) { |
| tilentity.validate(); |
| worldObj.setBlockTileEntity(xCoord, yCoord, zCoord, tilentity); |
| } |
| |
| } |
| |
| public boolean hasComparatorInputOverride() { |
| return true; |
| } |
| |
| public int getComparatorInputOverride(World world,int x,int y,int z, int i) { |
| return Container.calcRedstoneFromInventory((IInventory)world.getBlockTileEntity(x, y, z)); |
| } |
| |
| public int idPicked(World world, int x,int y,int z) { |
| return UniverseMain.CompresseurOff.blockID; |
| } |
| |
| } |
| |
mais pour la barre de cuisson je ne sais pas dans quelle classe c’est situé exactement