Jump to content

LazerBeans

Members
  • Posts

    48
  • Joined

  • Last visited

Posts posted by LazerBeans

  1. So what changes should I make to the json model? Sorry about all of the issues, I'm new to Minecraft's TileEntities and rendering.

     

     

    EDIT: Somehow it's working now. First issue I just had while running was missing textures and wrong models for everything, so I just reinput the model call into the variants (the ModelLoader was complaining that there was no model for them, even though I set the default.) When I fixed that, after all other changes, the z-fighting went away. Thank you all for your help, now I'm going to get started on making the GUI work!

  2. Block#createTileEntity()

     

    It doesn't seem to like that, claiming that TileEntityCardboardBox() is not a TileEntity, and it's trying to get me to change the return type. which is false. It won't let me override without the Block# notation either.

     

    Block#createTileEntity()

    is notation for the method called

    createTileEntity

    in the class

    Block

    . It has parameters, but I didn't specify them as it has no overloads(methods with the same name but different parameters). If you type a method name in a class and press the autocomplete keybind(Ctrl+Space in Eclipse), your IDE will display all methods with that name that you can override.

     

    Great, that's fixed now. Thanks!

     

    As for your rendering issue: That is because you are rendering both a normal block model and a TESR-based model. Why?

     

    I was following a TileEntity with GUI tutorial (I can't remember which, it was a while ago, and I ported the code over. I recall it not working then either.) Is the normal block model just in the json? Because the TESR uses the ModelCardboardBox class for itself.

  3.  

    3) Use removedByPlayer() instead of breakBlock().  removedByPlayer() is called before the block is actually set to air, avoiding problems of trying to get a blockstate from air (actually it is set to air by the base implementation of removedByPlayer(), so remember to call super).

     

     

    Thanks! Only issue is I can't figure out which methods to call in order to get the required EntityPlayer and boolean parameters. All other changes are accounted for. (I can't believe I missed that I was calling cube_all ><)

     

    EDIT: It seems that I have another issue now: createNewTileEntity was implemented earlier and isn't replaced by Block. Is there a replacement function?

  4. Of course, here it is:

     

    ArborCraftBlocks:

     

     

    package com.Noxilus.arborcraft.registry;

     

    import com.Noxilus.arborcraft.block.BlockCardboardBox;

    import com.Noxilus.arborcraft.tileentity.TileEntityCardboardBox;

     

    import net.minecraft.block.Block;

    import net.minecraft.block.material.Material;

    import net.minecraft.client.Minecraft;

    import net.minecraft.client.renderer.block.model.ModelResourceLocation;

    import net.minecraft.item.Item;

    import net.minecraft.item.ItemBlock;

    import net.minecraftforge.fml.common.registry.GameRegistry;

     

    public class ArborCraftBlocks {

    public static Block cardboardBox;

    public static ItemBlock cardboardBox_itemblock;

     

    public static void setup() {

    init();

    register();

    }

     

    public static void init() {

    cardboardBox = new BlockCardboardBox(Material.CLOTH, "cardboard_box", 0.3F, 0.3F).setRegistryName("cardboard_box");

    cardboardBox_itemblock = (ItemBlock) new ItemBlock(cardboardBox).setRegistryName("cardboard_box");

    }

     

    public static void register() {

    GameRegistry.register(cardboardBox);

    GameRegistry.register(cardboardBox_itemblock);

    GameRegistry.registerTileEntity(TileEntityCardboardBox.class, "tile_entity_cardboard_box");

    }

     

    public static void registerRenders() {

    registerRender(cardboardBox);

    }

     

    public static void registerRender(Block block) {

    Item item = Item.getItemFromBlock(block);

    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));

    }

    }

     

     

     

    BlockCardboardBox:

     

     

    package com.Noxilus.arborcraft.block;

     

    import com.Noxilus.arborcraft.ArborCraft;

    import com.Noxilus.arborcraft.gui.CardboardBoxGuiHandler;

    import com.Noxilus.arborcraft.tileentity.TileEntityCardboardBox;

     

    import net.minecraft.block.Block;

    import net.minecraft.block.ITileEntityProvider;

    import net.minecraft.block.material.Material;

    import net.minecraft.block.state.IBlockState;

    import net.minecraft.entity.EntityLivingBase;

    import net.minecraft.entity.player.EntityPlayer;

    import net.minecraft.inventory.InventoryHelper;

    import net.minecraft.item.ItemStack;

    import net.minecraft.tileentity.TileEntity;

    import net.minecraft.util.EnumFacing;

    import net.minecraft.util.math.BlockPos;

    import net.minecraft.world.World;

     

    public class BlockCardboardBox extends Block implements ITileEntityProvider

    {

     

    public BlockCardboardBox(Material materialIn, String name, float hardness, float resistance)

    {

    super(materialIn);

    this.setUnlocalizedName(name);

    this.setHardness(hardness);

    this.setResistance(resistance);

    this.setCreativeTab(ArborCraft.tabArborCraft);

    }

     

    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)

    {

    if(!world.isRemote)

    {

    player.openGui(ArborCraft.MODID, CardboardBoxGuiHandler.CARDBOARD_BOX_GUI, world, pos.getX(), pos.getY(), pos.getZ());

    }

    return true;

    }

     

    public int getRenderType()

    {

    return 3;

    }

     

    @Override

    public void breakBlock(World world, BlockPos pos, IBlockState state)

    {

    TileEntityCardboardBox te = (TileEntityCardboardBox)world.getTileEntity(pos);

    InventoryHelper.dropInventoryItems(world, pos, te);

    super.breakBlock(world, pos, state);

    }

     

    @Override

    public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack)

    {

    if (stack.hasDisplayName())

    {

    ((TileEntityCardboardBox)world.getTileEntity(pos)).setCustomName(stack.getDisplayName());

    }

    }

     

    @Override

    public TileEntity createNewTileEntity(World worldIn, int meta) {

    return new TileEntityCardboardBox();

    }

     

    }

     

     

  5. Yes, here is the TESR file:

     

     

     

    package com.Noxilus.arborcraft.render;

     

    import org.lwjgl.opengl.GL11;

     

    import com.Noxilus.arborcraft.model.ModelCardboardBox;

     

    import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;

    import net.minecraft.tileentity.TileEntity;

    import net.minecraft.util.ResourceLocation;

     

    public class TileEntityCardboardBoxRenderer extends TileEntitySpecialRenderer

    {

     

    ResourceLocation texture = new ResourceLocation("mineboard:textures/entity/cardboard_box.png");

    private ModelCardboardBox model;

     

    public TileEntityCardboardBoxRenderer()

    {

    this.model = new ModelCardboardBox();

    }

    @Override

    public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage)

    {

    GL11.glPushMatrix();

    GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);

    GL11.glRotatef(180, 0F, 0F, 1F);

    this.bindTexture(texture);

    GL11.glPushMatrix();

    this.model.renderModel(0.0625F);

    GL11.glPopMatrix();

    GL11.glPopMatrix();

    }

     

    }

     

     

     

    and the ModelCardboardBox class:

     

     

    package com.Noxilus.arborcraft.model;

     

    import net.minecraft.client.model.ModelBase;

    import net.minecraft.client.model.ModelRenderer;

    import net.minecraft.entity.Entity;

     

    public class ModelCardboardBox extends ModelBase

    {

        ModelRenderer Shape1;

     

      public ModelCardboardBox()

      {

        textureWidth = 64;

        textureHeight = 32;

       

          Shape1 = new ModelRenderer(this, 0, 0);

          Shape1.addBox(0F, 0F, 0F, 16, 16, 16);

          Shape1.setRotationPoint(-8F, 8F, -8F);

          Shape1.setTextureSize(64, 32);

          Shape1.mirror = true;

          setRotation(Shape1, 0F, 0F, 0F);

      }

     

      public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)

      {

        super.render(entity, f, f1, f2, f3, f4, f5);

        setRotationAngles(f, f1, f2, f3, f4, f5, entity);

        Shape1.render(f5);

      }

     

      public void renderModel(float f5)

      {

      Shape1.render(f5);

      }

     

      private void setRotation(ModelRenderer model, float x, float y, float z)

      {

        model.rotateAngleX = x;

        model.rotateAngleY = y;

        model.rotateAngleZ = z;

      }

     

      public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)

      {

        super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);

      }

     

    }

     

     

     

    Hope those help.

  6. Hello,

     

    I've been working on modding for some time now (very basic, nothing special) but I've decided to upgrade to 1.10 and try working with TileEntities. I have a cardboard box which has some issues (not opening GUI) but I'll get that solved later. For now, my block model is rendering weirdly, with odd black scratches that show up based on the direction I'm facing. Here is an album of the images: http://imgur.com/a/eTKQ2

     

    And now the .jsons:

     

    block.cardboard_box.json

     

     

    {

        "parent": "block/cube_all",

        "textures": {

            "up": "arborcraft:blocks/cardboard_box_top",

            "north": "arborcraft:blocks/cardboard_box_front",

            "south": "arborcraft:blocks/cardboard_box_front",

            "east": "arborcraft:blocks/cardboard_box_front",

            "west": "arborcraft:blocks/cardboard_box_front",

            "down": "arborcraft:blocks/cardboard_box_side",

            "particle": "arborcraft:blocks/cardboard_box_side"

        }

    }

     

     

     

    item.cardboard_box.json

     

     

    {

        "parent": "arborcraft:block/cardboard_box"

        "display": {

            "thirdperson": {

                "rotation": [ 10, -45, 170 ],

                "translation": [ 0, 1.5, -2.75 ],

                "scale": [ 0.375, 0.375, 0.375 ]

            }

        }

    }

     

     

     

    blockstates.cardboard_box.json

     

     

    {

        "variants": {

            "normal" : {

                "model": "arborcraft:cardboard_box"

            },

            "inventory" : {

                "model": "arborcraft:cardboard_box"

            }

        }

    }

     

     

     

    NOTE: The inventory variant in the blockstate is the same because Forge needed one, so I just used the same as the normal. It doesn't do anything special when it opens.

     

    Any help is appreciated, I can supply any other files as necessary. Sorry if it's a stupid issue that I just don't see  :-\.

  7. If I had to guess, I'd say the problem originates at line 24 in MineBoardBlocks.java:

     

    GameRegistry.register(cardboard_block.setRegistryName("cardboard_block"));

     

    Maybe this is a 1.9 thing (I'm currently using 1.8.9) but don't you need to set an ItemBlock when you register any block? In 1.8.9 the line would be something like:

     

    GameRegistry.registerBlock(cardboard_block, ItemBlockCardboard.class, "cardboard_block");

     

    I'm actually updating my mod to 1.9 right now so I'll go see how it works in that version, but I think this might be why you're getting errors with the block but not the items.

     

    Thanks! This worked. Now I just need to get the inventory model working... :/

  8. Was cardboard_block ever initialized? I see a method to do so, but I can't see that method being called.

     

    Show MineBoard.java

     

    Yes it is, in my main PreInit().

     

    MineBoard.java: http://pastebin.com/KLjKhLBY

     

    I can show my ClientProxy as well, but it calls MineBoardBlocks.init() as well.

     

    Another important thing to note is that the code is virtually identical to the code for items, which works, with the key difference being that I needed to change the Item parameter to a Block in the registerRender() function. And in my main mod file, init() is being called before registerRenders(), so there really shouldn't be any issue there.

  9. Hi all,

     

        I've been delving into 1.9 modding and am trying to create a simple cardboard block. Everything seems fine, except when I run my eclipse setup I get a null pointer exception during initialization. I can see that `item` is apparently null, is there a different way to do this render call? I've been following ChampionAsh5357's tutorial, and have noticed some issues earlier (namely with registry, but I've got that sorted out) if that helps any. Provided below are the error and the file in which the error occurs.

     

    Error:

    http://pastebin.com/uLGLwyrz

     

    MineBoardBlocks.java:

    http://pastebin.com/RJ5FU6Kq

     

    Thanks in advance!

  10. Maybe the texture itself is bad. Check Techne and you file to make sure that you've textured your mob properly (in the texture, and even in Techne). Other than that, perhaps the file is corrupt. Can you open it? Try opening in GIMP, Photoshop, etc.

  11. Here's a look at my RenderPenguin class:

     

    package ArctiCraftMob;
    
    import org.lwjgl.opengl.GL11;
    
    import com.LazerBeanz.LazerCraft.ArctiCraft.ArctiCraft;
    
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import net.minecraft.client.model.ModelBase;
    import net.minecraft.client.renderer.entity.RenderLiving;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityLiving;
    import net.minecraft.entity.EntityLivingBase;
    import ArctiCraftMob.EntityPenguin;
    import net.minecraft.util.MathHelper;
    import net.minecraft.util.ResourceLocation;
    
    @SideOnly(Side.CLIENT)
    public class RenderPenguin extends RenderLiving
    {
    private static final ResourceLocation penguinTexture = new ResourceLocation("arcticraft" + ":" + "textures/entity/arcticpenguin.png");
        private static final String __OBFID = "CL_00000983";
    
        public RenderPenguin(ModelBase modelbase, float f)
        {
            super(modelbase, f);
        }
        
    
        protected void preRenderCallback(EntityLivingBase entitylivingbase, float f) {
      	  GL11.glRotatef(270, 0, 1, 0);
        }
    
        
        public void doRender(EntityPenguin entitypenguin, double d1, double d2, double d3, float f1, float f2)
        {
            super.doRender((EntityLiving)entitypenguin, d1, d2, d3, f1, f2);
        }
    
        
        protected ResourceLocation getEntityTexture(EntityPenguin entitypenguin)
        {
            return penguinTexture;
        }
    
       
        protected float handleRotationFloat(EntityPenguin entitypenguin, float f)
        {
            float f1 = entitypenguin.field_70888_h + (entitypenguin.field_70886_e - entitypenguin.field_70888_h) * f;
            float f2 = entitypenguin.field_70884_g + (entitypenguin.destPos - entitypenguin.field_70884_g) * f;
            return (MathHelper.sin(f1) + 1.0F) * f2;
        }
    
       
        public void doRender(EntityLiving entityliving, double d1, double d2, double d3, float f1, float f2)
        {
            this.doRender((EntityPenguin)entityliving, d1, d2, d3, f1, f2);
        }
    
       
        protected float handleRotationFloat(EntityLivingBase entitylivingbase, float f)
        {
            return this.handleRotationFloat((EntityPenguin)entitylivingbase, f);
        }
    
      
        public void doRender(EntityLivingBase entitylivingbase, double d1, double d2, double d3, float d4, float f)
        {
            this.doRender((EntityPenguin)entitylivingbase, d1, d2, d3, d4, f);
        }
    
       
        protected ResourceLocation getEntityTexture(Entity entity)
        {
            return this.getEntityTexture((EntityPenguin)entity);
        }
    
       
        public void doRender(Entity entity, double d1, double d2, double d3, float f1, float f2)
        {
            this.doRender((EntityPenguin)entity, d1, d2, d3, f1, f2);
        }
    }
    

     

    What you need to look at are the ResourceLocation parts. That should help you out!

  12. My preRenderCallback method is now as follows:

     

        protected void preRenderCallback(EntityLivingBase par1, float par2) {
      	  GL11.glRotatef(90, 0, 1, 0);
        }
    

     

    Should I be calling for the method anywhere?

     

    Here is my full ModelPenguin:

    
    package ArctiCraftMob;
    
    import org.lwjgl.opengl.GL11;
    
    import net.minecraft.client.model.ModelBase;
    import net.minecraft.client.model.ModelRenderer;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.util.MathHelper;
    
    public class ModelPenguin extends ModelBase
    {
      //fields
        ModelRenderer Leg1;
        ModelRenderer Leg2;
        ModelRenderer Body;
        ModelRenderer Arm1;
        ModelRenderer Arm2;
        ModelRenderer Head; 
        ModelRenderer Foot1;
        ModelRenderer Foot2;
      
        protected void preRenderCallback(EntityLivingBase par1, float par2) {
      	  GL11.glRotatef(90, 0, 1, 0);
        }
        
      public ModelPenguin()
      {
        textureWidth = 64;
        textureHeight = 32;
        	
        
          Leg1 = new ModelRenderer(this, 42, 12);
          Leg1.addBox(0F, 0F, 0F, 1, 7, 1);
          Leg1.setRotationPoint(0F, 17F, -2F);
          Leg1.setTextureSize(64, 32);
          Leg1.mirror = true;
          setRotation(Leg1, 0F, 0F, 0F);
          Leg2 = new ModelRenderer(this, 42, 12);
          Leg2.addBox(0F, 0F, 0F, 1, 7, 1);
          Leg2.setRotationPoint(0F, 17F, 1F);
          Leg2.setTextureSize(64, 32);
          Leg2.mirror = true;
          setRotation(Leg2, 0F, 0F, 0F);
          Body = new ModelRenderer(this, 46, 12);
          Body.addBox(0F, 0F, 0F, 3, 11, 6);
          Body.setRotationPoint(-1F, 6F, -3F);
          Body.setTextureSize(64, 32);
          Body.mirror = true;
          setRotation(Body, 0F, 0F, 0F);
          Arm1 = new ModelRenderer(this, 32, 0);
          Arm1.addBox(0F, 0F, 0F, 3, 11, 1);
          Arm1.setRotationPoint(2F, 6F, -3F);
          Arm1.setTextureSize(64, 32);
          Arm1.mirror = true;
          setRotation(Arm1, 0.2617994F, 3.141593F, 0F);
          Arm2 = new ModelRenderer(this, 32, 0);
          Arm2.addBox(0F, 0F, 0F, 3, 11, 1);
          Arm2.setRotationPoint(-1F, 6F, 3F);
          Arm2.setTextureSize(64, 32);
          Arm2.mirror = true;
          setRotation(Arm2, 0.2617994F, 0F, 0F);
          Head = new ModelRenderer(this, 42, 0);
          Head.addBox(0F, -2F, -3F, 5, 6, 6);
          Head.setTextureOffset(24, 0); //beak
          Head.setRotationPoint(-2F, 2F, 0F);
          Head.setTextureSize(64, 32);
          Head.mirror = true;
          setRotation(Head, 0F, 0F, 0F);
          Foot1 = new ModelRenderer(this, 36, 26);
          Foot1.addBox(0F, 0F, -3F, 2, 0, 3);
          Foot1.setRotationPoint(0F, 24F, 0F);
          Foot1.setTextureSize(64, 32);
          Foot1.mirror = true;
          setRotation(Foot1, 0F, 0F, 0F);
          Foot2 = new ModelRenderer(this, 36, 26);
          Foot2.addBox(0F, 0F, 0F, 2, 0, 3);
          Foot2.setRotationPoint(0F, 24F, 0F);
          Foot2.setTextureSize(64, 32);
          Foot2.mirror = true;
          setRotation(Foot2, 0F, 0F, 0F);
          
      }
      
      public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
      {
        super.render(entity, f, f1, f2, f3, f4, f5);
        setRotationAngles(f, f1, f2, f3, f4, f5, entity);
        
        if (this.isChild) {
        	float f6 = 2.0F;
        	GL11.glPushMatrix();
        	GL11.glTranslatef(0.0F, 5.0F * f5, 2.0F * f5);
        	this.Head.renderWithRotation(f5);
        	GL11.glPopMatrix();
        	GL11.glPushMatrix();
        	GL11.glScalef(1.0F / f6,  1.0F / f6, 1.0F / f6);
        	GL11.glTranslatef(0.0F, 24.0F * f5, 0.0F);
        	this.Body.render(f5);
        	this.Leg1.render(f5);
        	this.Leg2.render(f5);
        	this.Arm1.render(f5);
        	this.Arm2.render(f5);
        	this.Foot1.render(f5);
        	this.Foot2.render(f5);
        	GL11.glPopMatrix();
        } else {
        	this.Leg1.render(f5);
            this.Leg2.render(f5);
            this.Body.render(f5);
            this.Arm1.render(f5);
            this.Arm2.render(f5);
            this.Head.renderWithRotation(f5);
            this.Foot1.render(f5);
            this.Foot2.render(f5);
        }
      }
      
      private void setRotation(ModelRenderer model, float x, float y, float z)
      {
        model.rotateAngleX = x;
        model.rotateAngleY = y;
        model.rotateAngleZ = z;
      }
      
      public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7)
      {
    float f6 = (180F / (float)Math.PI);
    this.Head.rotateAngleX = par5 / (180F / (float)Math.PI);
    this.Head.rotateAngleY = par4 / (180F / (float)Math.PI);
    this.Body.rotateAngleY = par5 / (180F / (float)Math.PI);
    this.Leg1.rotateAngleZ = MathHelper.cos(par1 * 0.3331F) * 1.4F * par2;
    this.Leg2.rotateAngleZ = MathHelper.cos(par1 * 0.3331F + (float)Math.PI) * 1.4F * par2;
    this.Arm1.rotateAngleZ = MathHelper.cos(par1 * 0.3331F) * 1.4F * par2;
    this.Arm2.rotateAngleZ = MathHelper.cos(par1 * 0.3331F + (float)Math.PI) * 1.4F * par2;
      }
    
    }
    

     

  13. Hm... I added a new preRenderCallback method, with the glRotatef, but it doesn't seem to be working.

     

    protected void preRenderCallback() {
      GL11.glRotatef(90, 0, 1, 0);
      }
    

     

    Should this be before the ModelPenguin() method? It's currently between ModelPenguin() and render().

     

    EDIT: Tried and does not work

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.