Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Alphafox_13

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by Alphafox_13

  1. Thanks, where would i find an example of this? Cuase i already have a ItemBlock however i am not sure how to use onItemUse() [glow=red,2,300]ItemBlockMast[/glow] public class ItemMast extends ItemBlock{ private final Block Mast; public ItemMast(Block block) { super(block); this.Mast = block; this.setHasSubtypes(true); } public String getUnlocalizedName(ItemStack item){ int i = item.getItemDamage(); if(i<0||i>=BlockMast.subBlocks.length){ i=i-BlockMast.subBlocks.length; } return super.getUnlocalizedName()+"."+BlockMast.subBlocks[i]; } public int getMetadata(int meta){ return meta; } @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int meta) { return this.Mast.getIcon(0, meta); } } Yes Im in 1.7.10
  2. So i have some code that adds a NBT tag to a block when i pass it through a shapeless crafting reciepe MastStack.setTagCompound(new NBTTagCompound()); NBTTagCompound tags = MastStack.stackTagCompound; tags.setBoolean("Upright", true); GameRegistry.addShapelessRecipe(MastStack, new Object[] {MastUp,MastUp,MastUp}); however it doesn't preserve the data when it is placed as a block/tileentity. The data will be stored in the TE as i have set up several setters/getters and am already storing most of my data there anyway, however i have no idea how to pass the data form Item to TE [glow=green,2,300]TEmast[/glow] package ships.addon.blocks_items; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; public class TEmast extends TileEntity { private byte Direction; private byte Dye; private boolean Upright; private boolean Connected; @Override public AxisAlignedBB getRenderBoundingBox() { return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); } //---- Setters and Getters ----\\ public byte getValue() { return Direction; } public void setValue(byte value) { Direction = value; } public byte getDye() { return Dye; } public void setDye(byte value) { Dye = value; } public boolean getBoolean() { return Upright; } public void setBoolean(boolean value) { Upright = value; } public boolean getBool() { return Connected; } public void setBool(boolean value) { Connected = value; } //---- Read and Write ----\\ public void writeToNBT(NBTTagCompound nbt){ super.writeToNBT(nbt); nbt.setBoolean("Connected", this.Connected); nbt.setBoolean("Upright", this.Upright); nbt.setByte("Direction", this.Direction); nbt.setByte("Dye", this.Dye); markForUpdate(); } public void readFromNBT(NBTTagCompound nbt){ super.readFromNBT(nbt); this.Connected = nbt.getBoolean("Connected"); this.Upright = nbt.getBoolean("Upright"); this.Direction = nbt.getByte("Direction"); this.Dye = nbt.getByte("Dye"); } //---- Packets ----\\ @Override public Packet getDescriptionPacket(){ NBTTagCompound tileTag = new NBTTagCompound(); this.writeToNBT(tileTag); return new S35PacketUpdateTileEntity(this.xCoord,this.yCoord,this.zCoord,0,tileTag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); } //---- Mark for Update ----\\ public void markForUpdate() { this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } [glow=red,2,300]Crafting with the For loops and Items stacks[/glow] for(int i=0; i<12; i++){ //Iterate Item Stacks ItemStack MastStack = new ItemStack(Registry.Mast, 3, i); ItemStack MastUp = new ItemStack(Registry.Mast, 1, i); ItemStack WoodStack = new ItemStack(Blocks.log, 3, 0); if(i<4){WoodStack = new ItemStack(Blocks.log, 3, i);} else if(i<6){WoodStack = new ItemStack(Blocks.log2, 3, i-4);} else{WoodStack = new ItemStack(Blocks.planks, 3, i-6);} GameRegistry.addShapedRecipe(MastStack, new Object[]{ "LLL", "WWW", 'L',WoodStack,'W',Registry.Sail }); MastStack.setTagCompound(new NBTTagCompound()); NBTTagCompound tags = MastStack.stackTagCompound; tags.setBoolean("Upright", true); GameRegistry.addShapelessRecipe(MastStack, new Object[] {MastUp,MastUp,MastUp}); }
  3. How do i add a mod to my development environment so I can test compatibility. I am using Eclipse and the mod i wanna add is Ships Mod by Cuchaz. As I am currently adding a mod which adds cosmetic blocks and implements his propusion API I tried adding it to DevEnviroment/Eclipse/mods it gave errors I aslso tried adding it to Build path in Referenced Libraries.
  4. actually i don't think the problem is the ulocalised name its actually this: you have the images in assets/sa/blocks where as java/minecraft is looking for them at assets/sa/textures/blocks well actually there is a small thing with the unlocalised name your missing .substring(5) PS. i noramally add public static final String DIR = "sa"; just below the final String MODID and change it to this.setBlockTextureName(SignificantAdvancements.DIR + ":" + this.getUnlocalizedName().substring(5)); that way my file structure is independant of my ModID
  5. https://github.com/mnn/jaffas/blob/b05d038e7c30c3c3fc9ea0783c640bdd76129a09/src/minecraft/monnef/jaffas/power/client/BlockRenderingHandler.java that is some code i attempted to code/depict but it made no sense and TileEntityRenderer.instance.renderTileEntityAt(generator, POSITION_FIX, POSITION_FIX, POSITION_FIX, 0.0F); didn't work
  6. I am creating a mod with an block Sail it is rendered with a TE using a model i created in Techne, the block uses all 16 metadata states for colors, i have been able to get the colors to work while it a block and all the names display correctly, however i cant get the icon to work properly. I briefly attempted to render the TE in inventory rather than a 2D icon however i could get that to work either, I don't really care which one we get working just so long as it works. My fourm post on MC fourms pictures and a download can be found there if u need them http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/2384775 [glow=purple,2,300]Registry[/glow] for GameRegistry.registerBlock() etc package ships.addon.baseclass; import ships.addon.blocks_items.BlockMast; import ships.addon.blocks_items.BlockSail; import ships.addon.blocks_items.ItemSail; import ships.addon.blocks_items.TestItem; import ships.addon.blocks_items.TEmast; import ships.addon.blocks_items.TEsail; import net.minecraft.item.Item; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraftforge.client.MinecraftForgeClient; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; public class Registry { public static Item TestItem; public static void initItems(){ TestItem = new TestItem(); GameRegistry.registerItem(TestItem, "test"); } public static Block Sail; public static Item sail; public static Block Mast; //private static PropulsionDiscoverer TEsailDiscoverer; public static void initBlocks(){ Sail = new BlockSail(Material.cloth); sail = new ItemSail(Sail); GameRegistry.registerBlock(Sail,ItemSail.class ,Sail.getUnlocalizedName().substring(5)); GameRegistry.registerTileEntity(TEsail.class, "sailTile"); //MinecraftForgeClient.registerItemRenderer(Registry.sail, new ItemSailRenderer()); //PropulsionDiscovererRegistry.addDiscoverer(TEsailDiscoverer); Mast = new BlockMast(Material.wood); GameRegistry.registerBlock(Mast, "mast"); GameRegistry.registerTileEntity(TEmast.class, "mastTile"); } } [glow=blue,2,300]Block[/glow] package ships.addon.blocks_items; import java.util.List; import org.lwjgl.input.Keyboard; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ships.addon.baseclass.Registry; import ships.addon.models.SailModel; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemDye; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; public class BlockSail extends Block implements ITileEntityProvider{ @SideOnly(Side.CLIENT) private IIcon[] texture = new IIcon[16]; final static String[] subBlocks = new String[]{"black", "red", "green", "brown", "blue", "purple", "cyan", "silver", "gray", "pink", "lime", "yellow", "lightBlue", "magenta", "orange", "white"}; public BlockSail(Material material){ super(material); this.isBlockContainer = false; this.setBlockName("sail"); this.setCreativeTab(CreativeTabs.tabTransport); this.setHardness(0.5F); this.setBlockTextureName("sailsaddon"+":"+(this.getUnlocalizedName().substring(5))); } @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta){ return texture[meta % subBlocks.length]; } @SideOnly(Side.CLIENT) public void getSubBlocks(Item item, CreativeTabs ct, List list){ for (int i = 0; i < subBlocks.length; ++i){ list.add(new ItemStack(item, 1, i)); } } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister register) { for (int i = 0; i < subBlocks.length; ++i){ texture[i] = register.registerIcon("sailsaddon"+":"+"sail_"+ subBlocks[~i&15]); } } public void setBlockBoundsForItemRender(){ this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public int getRenderType(){ return -1; } public boolean isOpaqueCube(){ return false; } public int damageDropped(int meta){ return meta; } public boolean renderAsNormalBlock(){ return false; } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) { updateSail(world,x,y,z,(EntityPlayer)player); } //Determine the correct rotation for block public void updateSail(World world, int x, int y, int z, EntityPlayer player){ if (!world.isRemote && world.getTileEntity(x,y,z) != null && world.getTileEntity(x,y,z) instanceof TEsail) { byte Direction = 0; int dir = MathHelper.floor_double((double)((player.rotationYaw * 4F) / 360F) + 0.5D) & 3; if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)){dir = dir+1;} if(dir==0||dir==2||dir==4){Direction = 1; TileEntity blk; //---- check Below ----\\ blk = loc(world,x,y-1,z-1); // Z - Below if(blk!=null&&blk instanceof TEsail){Direction = 5; ((TEsail) blk).setValue((byte)9);world.markBlockForUpdate(x, y-1, z-1);} else if(blk!=null&& blk instanceof TEmast){Direction = 5; ((TEmast)blk).setValue((byte)9);world.markBlockForUpdate(x, y-1, z-1);} blk = loc(world,x,y-1,z+1); // Z + Below if(blk!=null&& blk instanceof TEsail){Direction = 3; ((TEsail)blk).setValue((byte)7);world.markBlockForUpdate(x, y-1, z+1);} else if(blk!=null&& blk instanceof TEmast){Direction = 3; ((TEmast)blk).setValue((byte)7);world.markBlockForUpdate(x, y-1, z+1);} //---- check Above ----\\ blk = loc(world,x,y+1,z-1); // Z - Above if(blk!=null&& blk instanceof TEsail){Direction = 7; ((TEsail)blk).setValue((byte)3);world.markBlockForUpdate(x,y+1,z-1);} else if(blk!=null&& blk instanceof TEmast){Direction = 7; ((TEmast)blk).setValue((byte)3);world.markBlockForUpdate(x,y+1,z-1);} blk = loc(world,x,y+1,z+1); // Z + Above if(blk!=null&&blk instanceof TEsail){Direction = 9; ((TEsail)blk).setValue((byte)5);world.markBlockForUpdate(x,y+1,z+1);} else if(blk!=null&&blk instanceof TEmast){Direction = 9; ((TEmast)blk).setValue((byte)5);world.markBlockForUpdate(x,y+1,z+1);} } else{Direction = 0; TileEntity blk; //---- check Below ----\\ blk = loc(world,x-1,y-1,z); // X - Below if(blk!=null&&blk instanceof TEsail){Direction = 2; ((TEsail) blk).setValue((byte)6);world.markBlockForUpdate(x-1, y-1, z);} else if(blk!=null&& blk instanceof TEmast){Direction = 2; ((TEmast)blk).setValue((byte)6);world.markBlockForUpdate(x-1, y-1, z);} blk = loc(world,x+1,y-1,z); // X + Below if(blk!=null&& blk instanceof TEsail){Direction = 4; ((TEsail)blk).setValue((byte);world.markBlockForUpdate(x+1, y-1, z);} else if(blk!=null&& blk instanceof TEmast){Direction = 4; ((TEmast)blk).setValue((byte);world.markBlockForUpdate(x+1, y-1, z);} //---- check Above ----\\ blk = loc(world,x-1,y+1,z); // X - Above if(blk!=null&& blk instanceof TEsail){Direction = 8; ((TEsail)blk).setValue((byte)4);world.markBlockForUpdate(x-1,y+1,z);} else if(blk!=null&& blk instanceof TEmast){Direction = 8; ((TEmast)blk).setValue((byte)4);world.markBlockForUpdate(x-1,y+1,z);} blk = loc(world,x+1,y+1,z); // X + Above if(blk!=null&&blk instanceof TEsail){Direction = 6; ((TEsail)blk).setValue((byte)2);world.markBlockForUpdate(x+1,y+1,z);} else if(blk!=null&&blk instanceof TEmast){Direction = 6; ((TEmast)blk).setValue((byte)2);world.markBlockForUpdate(x+1,y+1,z);} } TileEntity tileloc = world.getTileEntity(x, y, z); if (tileloc != null && tileloc instanceof TEsail) { ((TEsail)tileloc).setValue(Direction); world.markBlockForUpdate(x, y, z); } } } private TileEntity loc(World world,int x, int y, int z) { return world.getTileEntity(x, y, z); } /**---- Block Bounding Box ----**/ public void setBlockBoundsBasedOnState(IBlockAccess block, int x, int y, int z) { byte Direction = 0; Direction = (byte)((TEsail) block.getTileEntity(x,y,z)).getValue(); if (Direction==0){ //---- X X X X this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F); } else if (Direction==1){// Z Z Z Z this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F); } //---- Above ----\\ else if (Direction==2){ //x- this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F); } else if (Direction==3){ //z+ this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 1.0F); } else if (Direction==4){ //x+ this.setBlockBounds(0.4375F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else if (Direction==5){ //z- this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.5625F); } //---- Below ----\\ else if (Direction==6){ //x+ this.setBlockBounds(0.4375F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else if (Direction==7){ //z- this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.5625F); } else if (Direction=={ //x- this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F); } else if (Direction==9){ //z+ this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 1.0F); } else{ this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } } @Override public TileEntity createNewTileEntity(World var1, int var2) { return new TEsail(); } public void breakBlock(World world, int x, int y, int z, int i, int j) { world.removeTileEntity(x, y, z); } } [glow=yellow,2,300]ItemSail[/glow] package ships.addon.blocks_items; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; public class ItemSail extends ItemBlock{ public ItemSail(Block block) { super(block); this.setHasSubtypes(true); } public String getUnlocalizedName(ItemStack item){ int i = item.getItemDamage(); if(i<0||i>=BlockSail.subBlocks.length){ i=0; } return super.getUnlocalizedName()+"."+BlockSail.subBlocks[~i&15]; } public int getMetadata(int meta){ return meta; } } [glow=green,2,300]TileEnity[/glow] package ships.addon.blocks_items; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; public class TEsail extends TileEntity { private byte Direction; @Override public AxisAlignedBB getRenderBoundingBox() { return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); } //---- Setters and Getters ----\\ public byte getValue() { return Direction; } public void setValue(byte value) { Direction = value; } //---- Read and Write ----\\ public void writeToNBT(NBTTagCompound nbt) { nbt.setByte("Direction", this.Direction); super.writeToNBT(nbt); markForUpdate(); } public void readFromNBT(NBTTagCompound nbt) { this.Direction = nbt.getByte("Direction"); super.readFromNBT(nbt); } //---- Packets ----\\ @Override public Packet getDescriptionPacket(){ NBTTagCompound tileTag = new NBTTagCompound(); this.writeToNBT(tileTag); return new S35PacketUpdateTileEntity(this.xCoord,this.yCoord,this.zCoord,0,tileTag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); } //---- Mark for Update ----\\ public void markForUpdate() { this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } [glow=red,2,300]Render[/glow] I tried to get it to render in the inventory by adding implements ISimpleBlockRenderingHandler to the class but it hasn't worked package ships.addon.blocks_items; import net.minecraft.block.Block; import net.minecraft.block.BlockAnvil; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.Entity; import net.minecraft.world.IBlockAccess; import ships.addon.baseclass.Registry; import ships.addon.blocks_items.BlockSail; import org.lwjgl.opengl.GL11; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import ships.addon.lib.Ref; import ships.addon.models.AcendingSailModel; import ships.addon.models.MastModel; import ships.addon.models.SailModel; public class RenderSail extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler{ private static ResourceLocation textureSail = new ResourceLocation("sailsaddon"+":"+"textures/blocks/sail_white.png"); private SailModel sail; private AcendingSailModel acending; public static final double POSITION_FIX = -0.5D; private static TEsail TEsail = new TEsail(); public RenderSail(){ this.sail = new SailModel(); this.acending = new AcendingSailModel(); } @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f){ GL11.glPushMatrix(); TileEntity loc = tileentity.getWorldObj().getTileEntity(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord); textureSail = new ResourceLocation("sailsaddon"+":"+"textures/blocks/sail_"+BlockSail.subBlocks[~loc.getBlockMetadata()&15]+".png"); GL11.glTranslatef((float)x+0.5F,(float)y-0.5F,(float)z+0.5F); this.bindTexture(textureSail); byte Direction = ((TEsail)loc).getValue(); int dir = 0; dir = Direction; if(Direction>1&&Direction<=5){dir = Direction-2;} else if(Direction>5){dir = Direction-6;} GL11.glRotatef((float)dir*90, 0.0F, 1.0F, 0.0F); if(Direction>5){GL11.glTranslatef(0.5F,0.0F,0.0F);} if(Direction<=1){this.sail.renderModel(0.0625F);} else if(Direction>1){this.acending.renderModel(0.0625F);} GL11.glPopMatrix(); } @Override public void renderInventoryBlock(Block block, int metadata, int modelId,RenderBlocks renderer) { renderTileEntityAt(TEsail, POSITION_FIX, POSITION_FIX, POSITION_FIX, 0.0F); } @Override public int getRenderId() { return Registry.Sail.getRenderType(); } @Override public boolean shouldRender3DInInventory(int sail) { return true; } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { return false; } }
  7. Oh u mean put getRenderBoundingBox() in the TE class as sugested here: http://www.minecraftforge.net/forum/index.php?topic=14475.0 thanks i would have gotten that otherwise @Override public AxisAlignedBB getRenderBoundingBox() { return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); }
  8. Ok well i have solved half the problem //Shape1.mirror = true; http://www.minecraftforge.net/forum/index.php/topic,29024.0.html pointed me in the right direction. What is Shape1.mirror supposed to do anyway? however i am still getting the disapearing TE problem http://prntscr.com/6mrtsl whenever i tun my screen to far it seems to assume i cant see the block anymore then it hides it.
  9. sorry i am new to bitbucket and modding in general. It is now public this is the TileEntitySpecialRenderer package ships.addon.blocks_items; import net.minecraft.block.Block; import net.minecraft.block.BlockAnvil; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.Entity; import net.minecraft.world.IBlockAccess; import ships.addon.blocks_items.BlockSail; import org.lwjgl.opengl.GL11; import ships.addon.lib.Ref; import ships.addon.models.AcendingSailModel; import ships.addon.models.MastModel; import ships.addon.models.SailModel; public class RenderSail extends TileEntitySpecialRenderer{ private static final ResourceLocation textureSail = new ResourceLocation(Ref.MODID+":"+"textures/blocks/sail.png"); private SailModel modelSail; private AcendingSailModel acendingSail; public RenderSail(){ this.modelSail = new SailModel(); this.acendingSail = new AcendingSailModel(); } @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f){ GL11.glPushMatrix(); GL11.glTranslatef((float)x+0.5F,(float)y-0.5F,(float)z+0.5F); this.bindTexture(textureSail); byte Direction = ((TEsail)tileentity.getWorldObj().getTileEntity(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord)).getValue(); int dir = 0; dir = Direction; if(Direction>1&&Direction<=5){dir = Direction-2;} else if(Direction>5){dir = Direction-6;} GL11.glRotatef((float)dir*90, 0.0F, 1.0F, 0.0F); if(Direction>5){GL11.glTranslatef(0.5F,0.0F,0.0F);} if(Direction<=1){this.modelSail.renderModel(0.0625F);} else if(Direction>1){this.acendingSail.renderModel(0.0625F);} GL11.glPopMatrix(); } } package ships.addon.blocks_items; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; public class TEsail extends TileEntity { private byte Direction; //---- Setters and Getters ----\\ public byte getValue() { return Direction; } public void setValue(byte value) { Direction = value; } //---- Read and Write ----\\ public void writeToNBT(NBTTagCompound nbt) { nbt.setByte("Direction", this.Direction); super.writeToNBT(nbt); markForUpdate(); } public void readFromNBT(NBTTagCompound nbt) { this.Direction = nbt.getByte("Direction"); super.readFromNBT(nbt); } //---- Packets ----\\ @Override public Packet getDescriptionPacket(){ NBTTagCompound tileTag = new NBTTagCompound(); this.writeToNBT(tileTag); return new S35PacketUpdateTileEntity(this.xCoord,this.yCoord,this.zCoord,0,tileTag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); } //---- Mark for Update ----\\ public void markForUpdate() { this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } }
  10. Just a quick quick Question have you registered the recipes and all the BS? @EventHandler public void preInit(FMLInitializationEvent event){ log.info("Mod Load pre run started"); //name of you recipes class . whatever your Init funtion for recipes is called (); Recipes.initShaplessRecipes(); }
  11. it happens randomly idk what causes it java.lang.NullPointerException: Rendering Block Entity at ships.addon.blocks_items.RenderMast.func_147500_a(RenderMast.java:29) at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.func_147549_a(SourceFile:100) at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.func_147544_a(SourceFile:92) at net.minecraft.client.renderer.RenderGlobal.func_147589_a(RenderGlobal.java:483) at net.minecraft.client.renderer.EntityRenderer.func_78471_a(EntityRenderer.java:1224) at net.minecraft.client.renderer.EntityRenderer.func_78480_b(EntityRenderer.java:1015) at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:989) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:887) at net.minecraft.client.main.Main.main(SourceFile:148) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) Also it wont let me launch debug it just highlights this line of code The tileentities stop rendering when they think i cant see them? Here is my bitbucket: https://bitbucket.org/AlphaFox/shipsaddon/src and here is the compiled version download: http://www.mediafire.com/download/h2quv5hqxfuq2ah/Sails.zip And lastly here is the forum thread on MC forums if u want it: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/2384775-sails-masts-addon-for-ships-mod-90-complete
  12. out of curiosity is it better to extends BlockContainer or extends Block implements ITileEntityProvider like which is kinder to the cpu
  13. Direction = (boolean)((TEmast) tileentity.getWorldObj().getTileEntity(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord)).getValue(); well that fixed it works perfectly thanks for getting me to double check my code
  14. Umm just a though but if you don't know how to update forge u probably wont have much joy modding 1.8 as they have changed the entire render system, in someways its better as u no longer need tile entities but for basic blocks its worse. but on the note of updating just download this http://files.minecraftforge.net/#Downloads then install it using gradle if u cant figure it out look up a tutorial on installing forge
  15. um ok its wrong, i wouldnt be here if it wasn't, that just happened to the most recent attempt to get it working. So you gonna tell me what i should be doing, cause i really dont get it. Or u just gonna laugh at my attempts to figure it out on my own. (yes i read ur signature)
  16. well as i understand it for MC1.7 u have two options 1. load it as a CustomBlock.java http://www.instructables.com/id/Using-Blender-To-Create-Java3D-Models/ 2. load it as a CustomBlock.obj http://www.minecraftforge.net/wiki/Using_wavefront_model For MC1.8 u need to use json files example CustomBlock.json http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-tools/2124573-blender2minecraft-create-minecraft-blockmodels-in
  17. we need to know if your modding 1.7 or 1.8 cause in 1.8 u export to a CustomBlock.json and in 1.7 its a CustomBlock.java PS: if u add the mc version as [ver] in the subjectline then its infinitely more helpful
  18. So i have been trying to get this working for about 2 weeks now but it just wont communicate between the TileEntity and the renderer properly someone said i needed to use Setters and Getters Read and Write nbt Packeting However i have no idea which one is supposed to talk to the render class or how to do it [glow=red,2,300]TileEntityMast[/glow] public class TEmast extends TileEntity { private boolean Direction; //---- Setters and Getters ----\\ public boolean getValue() { return Direction; } public void setValue(boolean value) { Direction = value; } //---- Read and Write ----\\ public void writeToNBT(NBTTagCompound nbt) { nbt.setBoolean("Direction", this.Direction); super.writeToNBT(nbt); markForUpdate(); } public void readFromNBT(NBTTagCompound nbt) { this.Direction = nbt.getBoolean("Direction"); super.readFromNBT(nbt); } //---- Packets ----\\ @Override public Packet getDescriptionPacket(){ NBTTagCompound tileTag = new NBTTagCompound(); this.writeToNBT(tileTag); return new S35PacketUpdateTileEntity(this.xCoord,this.yCoord,this.zCoord,0,tileTag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); } //---- Mark for Update ----\\ public void markForUpdate() { this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } [glow=blue,2,300]RenderMast[/glow] public class RenderMast extends TileEntitySpecialRenderer{ private static final ResourceLocation textureMast = new ResourceLocation(Ref.MODID+":"+"textures/blocks/mast.png"); private MastModel mast; public RenderMast(){this.mast = new MastModel();} @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { boolean Direction = true; //---- this appears to be the problem ----\\ Direction = ((TEmast)tileentity.getWorldObj().getTileEntity(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord)).getValue(); GL11.glPushMatrix(); GL11.glTranslatef((float)x+0.5F,(float)y-0.5F,(float)z+0.5F); //GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); if(Direction==true){GL11.glRotatef(90, 0.0F, 1.0F, 0.0F);} if(Direction==false){GL11.glRotatef(180, 0.0F, 1.0F, 0.0F);} this.bindTexture(textureMast); this.mast.renderModel(0.0625F); GL11.glPopMatrix(); } } If you have Skype that would be awesome live:alphafox13 (the guy from NZ)
  19. cool just one thing could u add the mc version to the tread title as i am somewhat confused about that
  20. Can u link me to a tutorial or something that explains this cause i understand Iblockstate but thats of no use since i am targeting 1.7, u said "change its shape." as in it only gets run x amount of Time often?
  21. Can someone please explain how the Metadata aspect works, cause the 16 different metadata states are used for colors (right?) but then how is the connections of the panes stored/worked out? My first though was with a TileEntity, but that doesn't make sense either, cause they are push-able by pistons
  22. I dont really want to render it a different way as it sounds harder also are you sure i should be extending TileEntity http://www.minecraftforge.net/wiki/Tile_Entities say i need to Extend either BlockContainer or ITileEntityProvider "You do not have to do it by extending BlockContainer (Despite it giving some useful methods); instead you could implement ITileEntityProvider into your block class." public class BlockSail extends TileEntity{ public BlockSail(){ /**super(material); this.isBlockContainer = false; this.setBlockName("sail"); this.setCreativeTab(CreativeTabs.tabTransport); this.setHardness(0.5F); this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F); this.setBlockTextureName("sailsaddon"+":"+"sail");*/ } /*public void setBlockBoundsForItemRender(){ this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); }*/ public int getRenderType(){ return -1; } public boolean isOpaqueCube(){ return false; } public boolean renderAsNormalBlock(){ return true; } //** public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player){ int dir = MathHelper.floor_double((double)((player.rotationYaw * 4F) / 360F) + 0.5D) & 3; switch (dir){ case 0: world.setBlockMetadataWithNotify(x, y, z, dir, 0); break; case 1: world.setBlockMetadataWithNotify(x, y, z, dir, 1); break; case 2: world.setBlockMetadataWithNotify(x, y, z, dir, 0); break; case 3: world.setBlockMetadataWithNotify(x, y, z, dir, 1); break; } }//*/ /*@Override public TileEntity createNewTileEntity(World var1, int var2) { return new TEsail(); }*/ } That is the block class the problem is that it doesn't allow me to use the createNewTileEntity() do i need to change public class BlockSail extends TileEntity so that it implements something? also i had to change the register type public class RegisterBlocksItems { public static Item TestItem; public static void initItems(){ TestItem = new ItemTestItem(); GameRegistry.registerItem(TestItem, "test"); } public static TileEntity Sail; public static Block Mast; public static void initBlocks(){ Sail = new BlockSail(); GameRegistry.registerTileEntity(BlockSail.class, "sail"); Mast = new BlockMast(Material.wood); GameRegistry.registerBlock(Mast, "mast"); } } however that has caused my Recipies to fail GameRegistry.addShapedRecipe(new ItemStack(RegisterBlocksItems.Sail,9), new Object[]{ "C", "C", 'C',new ItemStack(Blocks.carpet) }); Download: http://www.mediafire.com/download/h2quv5hqxfuq2ah/Sails.zip What i plan to achieve: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/2384775-sails-masts-addon-for-ships-mod-help-needed
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.