Jump to content

gegy1000

Members
  • Posts

    47
  • Joined

  • Last visited

Posts posted by gegy1000

  1. Hello,

     

    I am trying to harvest annotation data from mods to do a similar thing to what @Mod.Instance and @SidedProxy do. I am doing this by subscribing to the FMLConstructionEvent, and using the ASM harvested data to inject the values.

     

    This has been working great in the development environment, but when in a release build, it crashes with a NPE. ModContainer#getMod() returns null for other mods, causing the crash. I'm not sure if this is caused by the fact that they are ordered differently in the development environment or if it's something else.

     

    You can view the source here: https://github.com/iLexiconn/LLibrary/blob/1.9.4/src/main/java/net/ilexiconn/llibrary/LLibrary.java

    It crashes here: https://github.com/iLexiconn/LLibrary/blob/1.9.4/src/main/java/net/ilexiconn/llibrary/server/config/ConfigHandler.java#L54

     

    Thanks in advance.

  2. Hello,

     

    I am trying to harvest annotation data from mods to do a similar thing to what @Mod.Instance and @SidedProxy do. I am doing this by subscribing to the FMLConstructionEvent, and using the ASM harvested data to inject the values.

     

    This has been working great in the development environment, but when in a release build, it crashes with a NPE. ModContainer#getMod() returns null for other mods, causing the crash. I'm not sure if this is caused by the fact that they are ordered differently in the development environment or if it's something else.

     

    You can view the source here: https://github.com/iLexiconn/LLibrary/blob/1.9.4/src/main/java/net/ilexiconn/llibrary/LLibrary.java

    It crashes here: https://github.com/iLexiconn/LLibrary/blob/1.9.4/src/main/java/net/ilexiconn/llibrary/server/config/ConfigHandler.java#L54

     

    Thanks in advance.

  3. Sorry about that. :/ Would there be another way be to detect those annotations?

    Handle
    FMLConstructionEvent

    in the

    ModContainer

    for the coremod part of the library. It provides you with the ASMDataTable.

    Also, I got it wrong. The crash is different. (Sorry D:) This is the crash http://pastebin.com/f4fFfvH1

    How did you think that crash was related to your packets? :o

    Put a breakpoint in the erroring method and check what is null there.

    Okay, thanks! I'll have a go at it. :)

  4. So, now I have to learn how that stupid @NetworkWrapper annotation works...

    Apart from the implementation being horrid (why in gods name are you classtransforming FML... please stop...), you just register every message blindly for client & server. With different IDs for each.

    This is designed to blow up.

    Sorry about that. :/ Would there be another way be to detect those annotations?

    Also, I got it wrong. The crash is different. (Sorry D:) This is the crash http://pastebin.com/f4fFfvH1

    • Do not use
      getEffectiveSide

      for mission-critical things. It is meant solely for debugging or quick tests. If you want to check the logical side, you must check

      World#isRemote

      .

    • You should not be sending the message to all players. Not every player's client knows about the entity. To get all players, whose client's know about the entity (i.e. the player can see the entity) use
      WorldServer#getEntityTracker().getTrackingPlayers

      .

    • Why is there a client-to-server message at all? That sounds like a horrible idea, the client should not have any say in this.

    Oh, yeah, I should probably not send it from the client. Not sure why I thought of doing it like that.

    I was only using

    getEffectiveSide

    for debugging, I'm not using it for this.

    I'm also having the same crash, however, for a different packet. It is being sent to the server from inside my GUI class, so it definitely is on the client-side.

    Thanks.

  5. I am trying to send a packet to the server, and I am experiencing a crash.

     

    http://pastebin.com/6uqpJGCr

     

    While researching this crash, all the problems seemed to be from sending a packet to the server, while on the server-side. I am checking the side with worldObj.isRemote on my entity, that the packet is being sent from. FMLCommonHandler#getEffectiveSide() will also have the same outcome as world.isRemote, however FMLCommonHandler#getSide() will have a different output, but using that results in a different error when using sendToAll: http://pastebin.com/vMPK9cUH

     

    This is my message sending code in my entity class:

     

      if (worldObj.isRemote)
                {
                    JurassiCraft.NETWORK_WRAPPER.sendToServer(new UpdateAnimationMessage(this));
                }
                else
                {
                    AnimationHandler.INSTANCE.sendAnimationMessage(this, newAnimation); // This calls sendToAll
                }

     

    You can view sendAnimationMessage here https://github.com/iLexiconn/LLibrary/blob/1.9/src/main/java/net/ilexiconn/llibrary/server/animation/AnimationHandler.java#L30.

     

    Thanks in advance.

     

  6. Hi

     

    When I try to use gradle build, it gives me this error:

     

    "java.util.zip.ZipException: duplicate entry: mcmod.info"

     

    I decided to check if there was an actual duplicate in the build jar, and there was. I checked some more, and found all the files were duplicated. So I removed the build.gradle, and got the error on another file. We have recently updated to the latest forge, this might be the problem but I'm not sure.

     

    Here is the build.gradle:

     

    "buildscript {

      repositories {

        maven {

          url "https://plugins.gradle.org/m2/"

        }

      }

      dependencies {

        classpath "gradle.plugin.net.minecraftforge.gradle:ForgeGradle:2.0.2"

      }

    }

     

    apply plugin: "net.minecraftforge.gradle.forge"

     

    version = "2.0.0-pre"

    group = "net.timeless.jurassicraft"

    archivesBaseName = "JurassiCraft"

     

    sourceCompatibility = targetCompatibility = "1.7"

     

    minecraft {

        version = "11.14.3.1552"

        runDir = "minecraft"

        replace '${version}', project.version

        mappings = "snapshot_20151107"

    }

     

    processResources {

        inputs.property "version", project.version

        inputs.property "mcversion", project.minecraft.version

     

        from(sourceSets.main.resources.srcDirs) {

            include 'mcmod.info'

            expand 'version': project.version, 'mcversion': project.minecraft.version

        }

     

        from(sourceSets.main.resources.srcDirs) {

            exclude 'mcmod.info'

        }

    }

     

    sourceSets {

        main { output.resourcesDir = output.classesDir }

    }"

     

  7. ItemStack.getStackTagCompound gives you an NBTTagCompound where you can put your data.

    Yes - I know that, but I was wondering if Minecraft had something built into it that copies data from tileentity to itemstack. Anyway, I'll just write that code manually then. :)

  8. In 1.7.10 you would solve this using IItemRenderer. In 1.8 there is currently no way to do this as far as I'm aware.

    Okay, I'll leave out the rendering for now. But I still need to keep the data in the ItemStack NBT from the TileEntity.

  9. I am currently making a block similar to a mob spawner, it renders an entity inside it. I am using a TESR, just like the mob spawner and everything renders fine. However, I want it to save the entity that is inside it, and still render it while it is an ItemStack. I looked through the MC code and found that mob spawners actually use an ItemBlock. So I have set my block to use an ItemBlock too. This didn't change anything, not that I expected it to. So I looked some more into the MC code and I can't find anything that may be of use to this, so I've come here.

     

    Here is some of my code:

     

    package net.timeless.jurassicraft.common.block;
    
    import net.minecraft.block.material.Material;
    import net.minecraft.item.ItemBlock;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.BlockPos;
    import net.minecraft.util.EnumFacing;
    import net.minecraft.util.EnumWorldBlockLayer;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    import net.minecraftforge.fml.relauncher.Side;
    import net.minecraftforge.fml.relauncher.SideOnly;
    import net.timeless.jurassicraft.common.api.ISubBlocksBlock;
    import net.timeless.jurassicraft.common.creativetab.JCCreativeTabs;
    import net.timeless.jurassicraft.common.item.ItemCage;
    import net.timeless.jurassicraft.common.tileentity.TileCage;
    
    public class BlockCage extends BlockOriented
    {
        public BlockCage()
        {
            super(Material.iron);
            this.setUnlocalizedName("cage_small");
            this.setHardness(1.0F);
            this.setResistance(1.0F);
            this.setCreativeTab(JCCreativeTabs.blocks);
        }
    
        @SideOnly(Side.CLIENT)
        public EnumWorldBlockLayer getBlockLayer()
        {
            return EnumWorldBlockLayer.CUTOUT;
        }
    
        @Override
        public boolean isOpaqueCube()
        {
            return false;
        }
    
        @Override
        public boolean isFullCube()
        {
            return false;
        }
    
        @SideOnly(Side.CLIENT)
        public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
        {
            return true;
        }
    
        @Override
        public TileEntity createNewTileEntity(World world, int meta)
        {
            return new TileCage();
        }
    }
    

     

    BlockRegistry:

     

     GameRegistry.registerBlock(cage_small, ItemCage.class, "cage_small");
      GameRegistry.registerTileEntity(TileCage.class, "cage_small");

     

    ItemCage:

     

    package net.timeless.jurassicraft.common.item;
    
    import net.minecraft.block.Block;
    import net.minecraft.item.ItemBlock;
    
    public class ItemCage extends ItemBlock
    {
        public ItemCage(Block block)
        {
            super(block);
            this.setUnlocalizedName("cage_small"); 
        }
    }
    

     

    TileCage:

     

    package net.timeless.jurassicraft.common.tileentity;
    
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityList;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.tileentity.TileEntity;
    
    public class TileCage extends TileEntity
    {
        private Entity entity;
    
        public void setEntity(Entity entity)
        {
            this.entity = entity;
        }
    
        public Entity getEntity()
        {
            return entity;
        }
    
        @Override
        public void readFromNBT(NBTTagCompound compound)
        {
            super.readFromNBT(compound);
    
            int entityID = compound.getInteger("EntityID");
    
            if(entityID != -1)
            {
                NBTTagCompound entityTag = compound.getCompoundTag("Entity");
    
                entity = EntityList.createEntityByID(entityID, worldObj);
    
                entity.readFromNBT(entityTag);
            }
        }
    
        @Override
        public void writeToNBT(NBTTagCompound compound)
        {
            super.writeToNBT(compound);
    
            NBTTagCompound entityTag = new NBTTagCompound();
    
            if(entity != null)
            {
                entity.writeToNBT(entityTag);
    
                compound.setInteger("EntityID", EntityList.getEntityID(entity));
            }
            else
            {
                compound.setInteger("EntityID", -1);
            }
    
            compound.setTag("Entity", entityTag);
        }
    }
    

     

    TESR:

     

    package net.timeless.jurassicraft.client.render.tileentity;
    
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.renderer.GlStateManager;
    import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.passive.EntityCow;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.EnumFacing;
    import net.timeless.jurassicraft.common.entity.*;
    import net.timeless.jurassicraft.common.tileentity.TileCage;
    
    public class TileEntityRendererCage extends TileEntitySpecialRenderer
    {
        private static final Minecraft mc = Minecraft.getMinecraft();
    
        @Override
        public void renderTileEntityAt(TileEntity tile, double posX, double posY, double posZ, float partialTicks, int p_180535_9_)
        {
            GlStateManager.pushMatrix();
    
            TileCage cage = (TileCage) tile;
    
            Entity entity = cage.getEntity();
    
            if(entity == null)
            {
                entity = new EntityGallimimus(tile.getWorld());
                cage.setEntity(entity);
            }
    
            GlStateManager.translate((float)posX + 0.5F, (float)posY, (float)posZ + 0.5F);
    
            float f1 = 0.5F;
            GlStateManager.translate(0.0F, 0.4F, 0.0F);
            EnumFacing front = EnumFacing.getFront(tile.getBlockMetadata());
    
            if(front == EnumFacing.EAST)
                front = EnumFacing.WEST;
            else if(front == EnumFacing.WEST)
                front = EnumFacing.EAST;
    
            GlStateManager.rotate((front.getHorizontalIndex()) * 90, 0, 1, 0);
            GlStateManager.translate(0.0F, -0.4F, 0.0F);
            entity.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
            mc.getRenderManager().renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
    
            GlStateManager.popMatrix();
        }
    }
    

     

    RenderingRegistry:

     

     ClientRegistry.bindTileEntitySpecialRenderer(TileCage.class, new TileEntityRendererCage());

     

    Thanks

     

    - gegy1000

  10. Thank you very much for the replies!

     

    Okay, so upon searching for onRightClick in Item class, I discovered that it didn't exist.  I scrolled down and found onItemRightClick.  Quite a silly blunder!  :o  I bet you guys saw it and were just waiting to see how long it would take me.  ;)  I also commented out the part TrashCaster mentioned.  The rock is mostly throw-able now.

     

    However, now my rock isn't rendering properly.  It's just a black and purple checker box when it leaves the character's hands.  It probably has something to do with the Entities class.  I suspect I'm registering the renders wrong.  It also could very well have something to do with the way my proxies relate to the Main class.

     

    Either way, somehow RenderStoneRock isn't being called right.  I'm troubleshooting, but will have more time this coming weekend to really look into it if I don't solve it tonight.

    If it's rendering a purple and black checker box, that means it cannot find the texture..
  11. Nothing you can do about it unfortunately.

    I was thinking about sending packets from the client to the server, but firstly that would be quite inefficient and secondly the client could have some mods that the server doesn't.. (Although you could check on the server)
  12. So, I have a mod where you get an item that you can put in your crafting table and get a random item. As the game starts, it goes through all the registered items and adds them and their sub items to a list that the game looks through when you put the item in the crafting table. My current problem is that getSubItems doesn't exist server side, so it crashes the server. I can't think of any way around this, and help would be greatly appreciated. :)

     

    Here is the code that finds all registered items:

     

    try
            {
                Field creativeTabField = null;
                
                for (Field field : Item.class.getDeclaredFields()) //Since getCreativeTab() is @SideOnly(Side.CLIENT)
                {
                    if(field.getType() == CreativeTabs.class)
                    {
                        field.setAccessible(true);
                        creativeTabField = field;
                        break;
                    }
                }
                
                for (Object object : Item.itemRegistry.getKeys())
                {
                    Item item = (Item) Item.itemRegistry.getObject((String) object);
                    
                    CreativeTabs tab = (CreativeTabs) creativeTabField.get(item);
                    
                    if(tab != null)
                    {
                        List<ItemStack> subtypes = new ArrayList<ItemStack>();
                        
                        if(item.getHasSubtypes())
                        {
                            try
                            {
                                item.getSubItems(item, tab, subtypes);
                            }
                            catch (Exception e)
                            {
                                System.err.println("Error while finding subitems for " + item.getUnlocalizedName() + "!");
                                e.printStackTrace();
                            }
                        }
                        else
                        {
                            subtypes.add(new ItemStack(item, 1, 0));
                        }
                        
                        for (ItemStack subtype : subtypes)
                        {
                            possibleItems.add(new RandomItem(subtype.getItem(), subtype.getItemDamage()));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }

    And here is the mod: http://www.planetminecraft.com/mod/randomite-mod/

     

  13. getSubItems is getting called for each of your armor pieces because all of the armor pieces you have registered are an instance of your class that is adding the subitems. Each armor piece is adding a full set to the game. Try only adding one sub item to the list. So it would be something like this:

     

    ItemStack stack = new ItemStack(this);
    stack.addEnchantment(enchantmenthere);
    list.add(stack);

×
×
  • Create New...

Important Information

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