Jump to content

JoieNL

Members
  • Posts

    32
  • Joined

  • Last visited

Posts posted by JoieNL

  1. 14 minutes ago, diesieben07 said:

    At least use 1.8.9 then. And 1.8.x is not going to be supported much longer on this forum, just FYI.

    Well, I am using 1.8.9, I just figured the the topic pertained to the entirety of 1.8.

     

    1 hour ago, diesieben07 said:

    MobSpawnerBaseLogic::getRandomEntity returns the WeightedRandomMinecart (that's what you get for using an outdated version, stupid names) instance, which stores the information about the entity to be spawned.

    So by configuring the NBT of this WeightedRandomMinecart instance I can apply armour and potion effects to the spawned entity? Alright, but then how about the properties of the spawner itself?

  2. Quote

    Why are you using 1.8?

    I am using 1.8 mostly because I cannot stand the combat system introduced in 1.9. Either way, I do not plan to update.

     

    Quote

    The MobSpawnerBaseLogic of the spawner lets you modify what should be spawned.

    Right, but it only allows you to pass a String (that is, the mobID), which means you can only set what kind of creature you want it to spawn, not the specifics of both the spawner and the spawned creature.

  3. Hello fellow modders,

     

    Lately I found myself at an impasse when trying to generate mob spawners in my custom structure. The generation of the spawner itself is not the problem, but rather the specifics of the spawner and the mob spawned. For the spawner itself, I want to be able to set the initial spawn delay, spawned mob, number of mobs spawned each time, spawn range, minimum and maximum delay between spawns, maximum nearby entities and required player distance to the spawner. For the spawned mob, I would like to add equipment (i.e. a weapon and armour) and maybe give it some potion effects. Now, I know how to do the latter if I have an instance of an EntityLiving, but I cannot figure out how to get said instance (and then set it) for a spawner. Please let me know if what I want is even possible with Minecraft's default classes, and, if it's not, how I would go about making custom spawner classes. Thanks in advance!

     

    PS: Here is my code for reference:

    Spoiler
    
    public static void generateWaterTower(int x, int y, int z, Random random, World world) {
    	BlockPos origin = new BlockPos(x, getTopBlock(new BlockPos(x, y, z), world).getY(), z);
    	(...)
    	world.setBlockState(origin.add(11, 1, 11), Blocks.mob_spawner.getDefaultState());
    	TileEntityMobSpawner spawner = (TileEntityMobSpawner) world.getTileEntity(origin.add(11, 1, 11));
    	(...)
    }

     

     

  4. First of all, please excuse my recent absence. I've been quite busy lately.

     

    On ‎06‎/‎04‎/‎2017 at 7:06 PM, Draco18s said:

    All the libraries I use are my own.  They're in the same repository.

     

    In fact, my second link is in said library.  It shows how I use the interface I created in order to let the Item class dictate how it should handle its own NBT data for rendering, rather than having it externally.  It's not any different than vanilla's IItemPropertyGetter, really.  The only difference is that IItemPropertyGetter can only handle one type: floats.

    What I mean is that you are referencing some other classes and interfaces in your code (most notably IItemWithMeshDefinition and EasyRegistry) in your libraries. I cannot trace the data flow of your code so I can figure out what to do myself without these files (or I'm just being stupid, hell if I know).

     

    On ‎06‎/‎04‎/‎2017 at 7:57 PM, larsgerrits said:

    net.minecraft.item.IItemPropertyGetter. But this shouldn't be an issue to find, as you should be using 1.9+ already.

    Well, the title of this thread does say "[1.8]". That is, I'm modding in Minecraft version 1.8...

  5. On ‎02‎/‎04‎/‎2017 at 7:26 PM, TheMasterGabriel said:

    You can probably use an IItemPropertyGetter, which can be used to change item models based on certain criteria. They are used by bows to change the texture depending on how long you have been holding down right click, for example. You can see how to use them in ItemBow and its associated json files.

     

    Edit: Also this post if you want another example.

    I've looked around a bit, and I believe IItemPropertyGetter is a 1.9+ interface. Could you point me to the exact location of the interface so I can doublecheck?

     

    On ‎03‎/‎04‎/‎2017 at 2:44 AM, Draco18s said:

    I notice you are using libraries I do not have. I haven't much experience with using libraries myself, but I'm not sure this helps out.

     

    Still, I thank you both for the quick replies.

  6. Lately, I've been stuck trying to give certain 'energy' tools a different texture, depending on whether the player is holding the tool or not. The tools should how up in an 'active' state when held, and in a 'dormant' state otherwise. The code for the switching of states work jut fine, but I cannot figure out how to change the texture depending on the state. Either changing the texture altogether or adding a second layer onto an existing texture works for me. Thanks in advance!
    Here is all the (potentially) relevant code:

     

    Spoiler
    
    package items;
    
    
    import net.minecraft.entity.Entity;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.world.World;
    
    
    public class ItemModEnergyAxe extends ItemModAxe {
    
        ItemModEnergyAxe(String unlocalizedName, ToolMaterial material) {
            super(unlocalizedName, material);
        }
    
        ItemModEnergyAxe(String unlocalizedName, ToolMaterial material, String[] toolTip) {
            super(unlocalizedName, material, toolTip);
        }
    
        public String getUnlocalizedName(ItemStack stack) {
            if (stack.hasTagCompound()) {
                return "item.energy_axe_" + stack.getTagCompound().getString("state");
            }
            return "item.energy_axe_dormant";
        }
    
        public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
            if (stack.getTagCompound() == null) {
                stack.setTagCompound(new NBTTagCompound());
            }
            stack.getTagCompound().setString("state", isSelected ? "active" : "dormant");
        }
    }

     

     

    Spoiler
    
    package items;
    
    
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.ItemAxe;
    import net.minecraft.item.ItemStack;
    
    import java.lang.reflect.Array;
    import java.util.List;
    
    
    class ItemModAxe extends ItemAxe {
    
        private final String[] toolTip;
    
        ItemModAxe(String unlocalizedName, ToolMaterial material, String[] toolTip) {
            super(material);
            this.setUnlocalizedName(unlocalizedName);
            this.toolTip = toolTip;
        }
    
        ItemModAxe(String unlocalizedName, ToolMaterial material) {
            super(material);
            this.setUnlocalizedName(unlocalizedName);
            this.toolTip = null;
        }
    
        public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
            if (toolTip != null) {
                for (int i = 0; i < Array.getLength(toolTip); i++) {
                    tooltip.add("§5§o" + Array.get(toolTip, i));
                }
            }
        }
    }

     

     

    Spoiler
    
    package items;
    
    
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.item.EnumAction;
    import net.minecraft.item.Item;
    import net.minecraft.item.Item.ToolMaterial;
    import net.minecraft.item.ItemArmor.ArmorMaterial;
    import net.minecraft.potion.Potion;
    import net.minecraft.potion.PotionEffect;
    import net.minecraftforge.common.util.EnumHelper;
    import net.minecraftforge.fml.common.registry.GameRegistry;
    
    
    public final class ModItems {
      	
    	//Other stuff
        public static Item energyPickaxe;
        public static Item energyAxe;
        public static Item energySpade;
        public static Item energyHoe;
        public static Item energySword;
        public static Item energyShears;
    	//Other stuff
      	
    	public static void createItems() {
          	//Other stuff
            GameRegistry.registerItem(energyPickaxe = new ItemModEnergyPickaxe("energy_pickaxe", energy), "energy_pickaxe");
            GameRegistry.registerItem(energyAxe = new ItemModEnergyAxe("energy_axe", energy), "energy_axe");
            GameRegistry.registerItem(energySpade = new ItemModEnergySpade("energy_spade", energy), "energy_spade");
            GameRegistry.registerItem(energyHoe = new ItemModEnergyHoe("energy_hoe", energy), "energy_hoe");
            GameRegistry.registerItem(energySword = new ItemModEnergySword("energy_sword", energy), "energy_sword");
            GameRegistry.registerItem(energyShears = new ItemModEnergyShears("energy_shears", 999), "energy_shears");
          	//Other stuff
    	}
      	
      	//Other sstuff
        private static final ToolMaterial energy = EnumHelper.addToolMaterial("energy", 8, 199, 20.0F, 15.0F, 75);
    }

     

     

    Spoiler
    
    package joienl.elementalmadness.client.render.items;
    
    
    import items.ModItems;
    import joienl.elementalmadness.ElementalMadness;
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.resources.model.ModelResourceLocation;
    import net.minecraft.item.Item;
    
    
    public final class ItemRenderRegister {
    
    	public static void registerItemRenderer() {
          	//Other stuff
            reg(ModItems.energyAxe);
            reg(ModItems.energyPickaxe);
            reg(ModItems.energySpade);
            reg(ModItems.energyHoe);
            reg(ModItems.energySword);
            reg(ModItems.energyShears);
          	//Other stuff
         }
    
        private static void reg(Item item) {
            Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(ElementalMadness.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
    	}
    }

     

     

     

    Spoiler
    
    package joienl.elementalmadness;
    
    
    import joienl.elementalmadness.client.model.ModelCobaltKobold;
    import joienl.elementalmadness.client.render.blocks.BlockRenderRegister;
    import joienl.elementalmadness.client.render.entity.EntityRenderRegister;
    import joienl.elementalmadness.client.render.entity.RenderCobaltKobold;
    import joienl.elementalmadness.client.render.items.ItemRenderRegister;
    import joienl.elementalmadness.entity.EntityCobaltKobold;
    import net.minecraft.client.Minecraft;
    import net.minecraftforge.fml.client.registry.RenderingRegistry;
    import net.minecraftforge.fml.common.event.FMLInitializationEvent;
    import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
    import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
    
    
    @SuppressWarnings("unused")
    public class ClientProxy extends CommonProxy {
    
        @Override
        public void preInit(FMLPreInitializationEvent e) {
            super.preInit(e);
        }
    
        @Override
        @SuppressWarnings({"deprecation", "unchecked"})
        public void init(FMLInitializationEvent e) {
            super.init(e);
            BlockRenderRegister.registerBlockRenderer();
            BlockRenderRegister.preInit();
            ItemRenderRegister.registerItemRenderer();
            EntityRenderRegister.registerEntityRenderer();
    
            RenderingRegistry.registerEntityRenderingHandler(EntityCobaltKobold.class, new RenderCobaltKobold(Minecraft.getMinecraft().getRenderManager(), new ModelCobaltKobold()));
        }
    
        @Override
        public void postInit(FMLPostInitializationEvent e) {
            super.postInit(e);
        }
    }

     

    Spoiler
    
    package joienl.elementalmadness;
    
    
    import blocks.ModBlocks;
    import items.ModItems;
    import joienl.elementalmadness.crafting.ModCrafting;
    
    import joienl.elementalmadness.event.ModItemCraftedEvent;
    import joienl.elementalmadness.event.ModItemSmeltedEvent;
    import joienl.elementalmadness.event.ModPlayerTickEvent;
    import joienl.elementalmadness.network.ModGuiHandler;
    import joienl.elementalmadness.world.WorldGen;
    import net.minecraftforge.common.MinecraftForge;
    import net.minecraftforge.fml.common.event.FMLInitializationEvent;
    import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
    import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
    import net.minecraftforge.fml.common.network.NetworkRegistry;
    import net.minecraftforge.fml.common.registry.GameRegistry;
    
    
    class CommonProxy {
    
        public void preInit(FMLPreInitializationEvent e) {
            ModBlocks.createBlocks();
        	ModItems.createItems();
            ModBlocks.init();
        }
    
        public void init(FMLInitializationEvent e) {
            ModCrafting.initCrafting();
            GameRegistry.registerWorldGenerator(new WorldGen(), 0);
            NetworkRegistry.INSTANCE.registerGuiHandler(ElementalMadness.instance, new ModGuiHandler());
            MinecraftForge.EVENT_BUS.register(new ModPlayerTickEvent());
            MinecraftForge.EVENT_BUS.register(new ModItemSmeltedEvent());
            MinecraftForge.EVENT_BUS.register(new ModItemCraftedEvent());
            AchievementRegistry.registerAchievements();
        }
    
        public void postInit(FMLPostInitializationEvent e) {}
    }

     

     

×
×
  • Create New...

Important Information

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