Jump to content

Toblexson

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by Toblexson

  1. Okay, I've finally got back into modding and decided to rewrite my minimal work from scratch to learn stuff again. I've created a meta item with 11 (I think) subitems stored using damage. These are created. However, after trying to set them to have seperate models, the paths are not being followed and every subitem reverts to soundcontrol:discCore#inventory, rather than, say, soundcontrol:discCore_13#inventory (meta/dmg 0) package toblexson.soundcontrol.items; import toblexson.soundcontrol.info.SCInfo; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; /** * Created by toblexson on 16/09/2016. */ public class SCBaseItem extends Item { public SCBaseItem(String name, CreativeTabs creativeTab) { super(); setUnlocalizedName(SCInfo.MOD_ID + "." + name); setRegistryName(name); setCreativeTab(creativeTab); } } package toblexson.soundcontrol.items; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import java.util.List; /** * Created by toblexson on 17/09/2016. */ public class SCMetaItem extends SCBaseItem { private String[] altNames; private String[] regNames; public SCMetaItem(String name, String[] altNames, CreativeTabs creativeTab) { super(name, creativeTab); setHasSubtypes(true); this.altNames = altNames; setMaxDamage(0); setRegNames(); } private void setRegNames() { regNames = new String[altNames.length]; for (int i = 0; i < altNames.length; i++) { regNames[i] = getRegistryName() + "_" + altNames[i]; } } @Override public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) { for (int i = 0; i < altNames.length; i++) { subItems.add(new ItemStack(itemIn, 1, i)); } } @Override public String getUnlocalizedName(ItemStack stack) { return this.getUnlocalizedName() + "_" + altNames[stack.getItemDamage()]; } public int getNumberSubItem() { return altNames.length; } public String getRegistryName(int meta) { return regNames[meta]; } } package toblexson.soundcontrol.items; import toblexson.soundcontrol.info.SCNames; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import java.util.List; /** * Created by toblexson on 17/09/2016. */ public class ItemDiscCore extends SCMetaItem { public ItemDiscCore() { super(SCNames.Items.DISC_CORE, SCNames.Items.DISC_CORE_ALT, CreativeTabs.MISC); } @Override public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { tooltip.add(stack.getUnlocalizedName().substring(27)); } } package toblexson.soundcontrol.client.render; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemModelMesher; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraftforge.client.model.ModelLoader; import toblexson.soundcontrol.items.SCItems; import toblexson.soundcontrol.items.SCMetaItem; /** * Created by toblexson on 16/09/2016. */ public class ItemRenderRegister { private static ItemModelMesher modelMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher(); public static void registerItemRenderer() { register(SCItems.vinyl); registerMeta(SCItems.discCore); //defaulting to soundcontrol:disCore#inventory } public static void register(Item item) { modelMesher.register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); } public static void registerMeta(SCMetaItem item) { for (int i = 0; i < item.getNumberSubItem(); i++) { ModelLoader.setCustomModelResourceLocation(item, i, new ModelResourceLocation(item.getRegistryName(i), "inventory")); } } } It's probably a silly mistake, it almost always is. Thanks in advance.
  2. For testing, all I'm doing is printing event.pickedUp.getEntityItem() to the console. I get 0x... I'm probably misunderstanding EntityItem but I could not wrap my head round the entity item or pickup code.
  3. Okay, I appear to be having a difficulty with the EnitityItem, the item I get from it has a stack size of zero.
  4. I always forget that vanilla code is a thing, don't know how. Thanks
  5. I have a few ideas about how to implement the placing of the item in the inventory (using iteration to work with incomplete stacks, looping through the item inventory first and then through the player's inventory) but I am unsure about how to prevent duplication of the item due to the completion of the basic code. Before I start messing around and making it up as I go along, I thought I'd ask if there was a tutorial available, since I have been unable to find one. Also I am unsure about whether my intention for the placing is the right way to go. Thanks in advance.
  6. Oh, my fault for expecting names to make sense. Thanks.
  7. You're probably right, just didn't want to have to load another browser. Event Handler public class SCEventHandler { @SubscribeEvent public void HandleServerChat(ServerChatEvent event) { System.out.println("Running HandleServerChat"); ItemStack[] inventory = event.player.getInventory(); System.out.println(inventory); boolean hasMufflingCrystal = false; for (int i = 0; i < inventory.length; i++) { ItemStack item = inventory[i]; if (item != null )//&& item.getItem() instanceof ItemCrystal && item.getItemDamage() == SCNames.Items.CRYSTAL.length - 1) { System.out.println("item exists"); hasMufflingCrystal = true; } if (hasMufflingCrystal) break; } if (hasMufflingCrystal) { System.out.println("Cancelling event"); event.setCanceled(true); } } } Mod Class (part) @EventHandler public void preInit(FMLPreInitializationEvent event) { MinecraftForge.EVENT_BUS.register(new SCEventHandler()); SCItems.initItems(); SCBlocks.initBlocks(); SCTileEntities.initTileEntities(); if(event.getSide() == Side.CLIENT) { SCItems.initTextures(); } }
  8. I have subscribed to the ServerChatEvent and am searching the inventory for an item but the entire inventory appears to be empty. I can provide code if necessary but do not see how my code could have created this problem (for testing all I'm doing is looping through the inventory and printing to the console if an itemstack position is not null). Thanks in advance
  9. Okay, I thought I remembered that being a thing, but I can only find Block.DestroyedByPlayer and Block.DestroyedByExplosion (might just be being stupid or blind). I'm using forge 1.8.9 - 11.15.1.1722 and MCP mappings stable_22
  10. I have a tile entity which silences mobs within a certain radius and then unmutes them when they move outside the range. However, I am not sure how to unmute the mobs when the block is removed. What would be the best way to do this? Thanks in advance
  11. I have a normal item, texture and model wise, which renders correctly in my IDE but not in the complied version. My meta items all work fine in the compiled version, as do my blocks. here's my item initialisation class (couldn't insert code so using gist). I don't know where else the error could be but can't see it: https://gist.github.com/anonymous/902ba91d394afd3094ac And the actual class file (SCBaseItem just sets the name and creative tab): https://gist.github.com/anonymous/84e5698e47dfa2216bf9 Thanks in advance
  12. I have been implementing a configuration file for my mod. All but two are working properly. Both 'basalt redstone vein size' and 'basalt redstone attempts' are showing up with an incorrect default value. It's probably a silly error on behalf, but if it is, I cannot find it. The default for basalt redstone vein size is showing up as 5 (instead of 10) The default for basalt redstone attempts is also showing up as 5 (instead of 25) Here's the relevant code from the Configuration file (I think this is all of it): final String ORE_VEIN_SIZE = StoneBlind.config.CATEGORY_GENERAL + StoneBlind.config.CATEGORY_SPLITTER + "Ore Vein Sizes"; SBConfigValues.ActualValues.basaltRedstoneVeinSize = StoneBlind.config.getInt(SBConfigValues.Names.BASALT_REDSTONE_VEIN_SIZE, ORE_VEIN_SIZE, SBConfigValues.Defaults.BASALT_REDSTONE_VEIN_SIZE, 1, 100, ""); final String ORE_GEN_ATTEMPTS = StoneBlind.config.CATEGORY_GENERAL + StoneBlind.config.CATEGORY_SPLITTER + "Maximum Ore Veins Per Chunk"; SBConfigValues.ActualValues.basaltRedstoneAttempts = StoneBlind.config.getInt(SBConfigValues.Names.BASALT_REDSTONE_ATTEMPTS, ORE_GEN_ATTEMPTS, SBConfigValues.Defaults.BASALT_REDSTONE_ATTEMPTS, 1, 100, ""); And here's the relevant code from the SBConfigValues class (Once again, I think this is all of it): //Inside interior class Names public static final String BASALT_REDSTONE_VEIN_SIZE = "Basalt Redstone Vein public static final String BASALT_REDSTONE_ATTEMPTS = "Maximum Basalt Redstone Veins Per Chunk"; //Inside interior class Defaults public static final int BASALT_REDSTONE_VEIN_SIZE = 10; public static final int BASALT_REDSTONE_ATTEMPTS = 25; //Inside interior class ActualValues public static int basaltRedstoneVeinSize; public static int basaltRedstoneAttempts;
  13. I thought that might be the only solution. Thanks for the verification.
  14. I have already added stone types which are metadata blocks (like wool) and have them generating. I am now working on having ores generate in them, each stone type having set ore blocks. However, the WorldGenMinable method accepts a block parameter as a target and no metadata for said target. Is there a way I can generate a block in a specific metadata block?
  15. I have an item which I want to stop a player from sending a message when it is in their inventory. I have the item doing something whilst in a player's inventory but I don't know what to do past this. I presume I'll have to override a method somewhere but I'm not sure what to do. Any help would be appreciated. thanks in advance.
  16. I am trying to play mob sounds such as skeletons from a tile entity. I have looked in the resources and found the names such as "skeleton1" which is in the folder "mob" but using Minecraft.getMinecraft.sndManager.playSound("mob.skeleton1", xCoord, yCoord, zCoord, 1F, 1F); doesn't seem to work. I would be thankful for any help.
  17. Items are singletons and inherit from the class Item. Classes have instances called instance objects. itemID is a non-static public property of the Item class. Thanks I think I get what you mean, I needed to reference the item where I have initialised it rather than the actual class. I've done this and now it works. @Override public boolean isItemValid(ItemStack itemstack) { return itemstack.itemID == Items.disksleeve.itemID || itemstack.itemID == Item.record11.itemID || itemstack.itemID == Item.record13.itemID || itemstack.itemID == Item.record13.itemID || itemstack.itemID == Item.recordBlocks.itemID || itemstack.itemID == Item.recordCat.itemID || itemstack.itemID == Item.recordChirp.itemID || itemstack.itemID == Item.recordFar.itemID || itemstack.itemID == Item.recordMall.itemID || itemstack.itemID == Item.recordMellohi.itemID || itemstack.itemID == Item.recordStal.itemID || itemstack.itemID == Item.recordStrad.itemID || itemstack.itemID == Item.recordWait.itemID || itemstack.itemID == Item.recordWard.itemID; }
  18. Sorry, I am new to modding, but what is the item instance item id and how would I use it?
  19. I am making a block which holds music disks or my own special item. The music disks can be placed inside the inventory but my item cannot. Here is the 'isItemValidForSlot' method for the tile entity: @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return itemstack.itemID == soundcontrol.item.ItemInfo.DISKSLEEVE_ID || itemstack.itemID == Item.record11.itemID || itemstack.itemID == Item.record13.itemID || itemstack.itemID == Item.record13.itemID || itemstack.itemID == Item.recordBlocks.itemID || itemstack.itemID == Item.recordCat.itemID || itemstack.itemID == Item.recordChirp.itemID || itemstack.itemID == Item.recordFar.itemID || itemstack.itemID == Item.recordMall.itemID || itemstack.itemID == Item.recordMellohi.itemID || itemstack.itemID == Item.recordStal.itemID || itemstack.itemID == Item.recordStrad.itemID || itemstack.itemID == Item.recordWait.itemID || itemstack.itemID == Item.recordWard.itemID; } The first option, for the disksleeve item, is the one I am having trouble with. The code for the slot which is used in the container/inventory is identical. Please help because I cannot think of what could be wrong.
×
×
  • Create New...

Important Information

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