Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Toblexson

Members
  • Joined

  • Last visited

  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. Ah, of course. Didn't see that method. Thanks.
  10. 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
  11. 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
  12. 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
  13. 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;
  14. I thought that might be the only solution. Thanks for the verification.
  15. 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?

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.