-
Posts
84 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Rohzek
-
Right now, I have them all declared at the top of my main class, just like in the op, which probably isn't the correct way to do it. public static final CustomCreativeTab CUSTOM_TAB = new CustomCreativeTab("myCustomTab", Items.APPLE); public static final CustomCreativeTab CUSTOM_TAB_ONE = new CustomCreativeTab("myCustomTab1", Items.STICK); ... etc As for how I "apply" them my items, I have the different types separated by classes (Food, ingots, tools, etc) But in each, I just call setCreativeTab in their constructors, and tell it which tab it belongs in. public CustomItems(String names) { setNames(names); setCreativeTab(Main.CUSTOM_TAB); } private void setNames(String name) { setUnlocalizedName(name); setRegistryName(name); } Which works for the first two tabs, but not any more, which is weird. I'm assuming either the items, or the tabs are being initialized in an order that stops one of them from seeing the other. Not sure which way. Yeah. This is what I have: public class CustomCreativeTab extends CreativeTabs { private ItemStack iconItem; private ItemSorter itemSorter = new ItemSorter(); public CustomCreativeTab(String label, Item item) { super(label); iconItem = new ItemStack(item); } @Override public ItemStack getTabIconItem() { return iconItem; } @Override public void displayAllRelevantItems(NonNullList<ItemStack> items) { super.displayAllRelevantItems(items); Collections.sort(items, itemSorter); } // Sorts items in alphabetical order using their display names, blocks on top private static class ItemSorter implements Comparator<ItemStack> { @Override public int compare(ItemStack o1, ItemStack o2) { Item item1 = o1.getItem(); Item item2 = o2.getItem(); // If item1 is a block and item2 isn't, sort item1 before item2 if (((item1 instanceof ItemBlock)) && (!(item2 instanceof ItemBlock))) { return -1; } // If item2 is a block and item1 isn't, sort item1 after item2 if (((item2 instanceof ItemBlock)) && (!(item1 instanceof ItemBlock))) { return 1; } String displayName1 = o1.getDisplayName(); String displayName2 = o2.getDisplayName(); int result = displayName1.compareToIgnoreCase(displayName2); return result; } } }
-
What is the proper way of registering Creative Tabs? Right now, I have them at the top of my main class between declaring the instance, and the preinit event just, like this: public static final CustomCreativeTabs SP_TAB = new CustomCreativeTabs("myTab", Items.APPLE); Which works fine if I only have one of them. For some reason, though, If I try to make more than 2, not all of my items and blocks will show up in the last one. If I make 4 or more. no items or blocks show up in the 4th+
-
(Solved) [1.11] Replacing block with another block
Rohzek replied to Rohzek's topic in Modder Support
Okay, yeah thanks. I made my own WorldGenPumpkin to spawn my mod block, and dropped it in with that, and it worked. (You sort of need it for the pumpkins. The event pos replaces this.chunkpos in that generation command) -
(Solved) [1.11] Replacing block with another block
Rohzek replied to Rohzek's topic in Modder Support
You know what? It needed to be registered on the terrain event bus, not the event bus. Now, it's working but my attempt at placing my own block in it's place crashes. World world = event.getWorld(); BlockPos pos = event.getPos(); EventType type = event.getType(); if(type == EventType.PUMPKIN) { event.setResult(Result.DENY); if(!world.isRemote) { LogHelper.debug("I blocked a pumpkin spawn"); world.setBlockState(pos, SPBlocks.PUMPKIN_SP.getDefaultState()); } } EDIT: Because the pos it always spits out, is at y level 0. I'm quite confused here. -
[1.10.2] [SOLVED] Event stops working after relog
Rohzek replied to bongotezz's topic in Modder Support
Ah. That explains then. I wasn't thinking, and only looked in TileEntity. The NBT is pretty simple, for both items and tile entities. You would do something like: NBTTagCompound myCompound = tileEntity.getTileData(); myCompound.setString("keyToSave", "valueToSave"); Keep in mind TileEntity#getTileData (in 1.11 anyway) specifically checks to see if the NBTTagCompound is null, and if it is, sets it to a new one. You should probably check to make sure it's not null before reading it or writing to it, anyway though. and to retrieve it later, you would do this: String myName = myCompound.getString("keyToSave"); -
[1.10.2] [SOLVED] Event stops working after relog
Rohzek replied to bongotezz's topic in Modder Support
I don't know much in the way of what's wrong with your current issue, but as an alternative you could try saving and loading the String you want in the tile entity's NBT, instead of using TileEntity#setCustomName, which seems to be more future proof, as I went to investigate that method, and couldn't find it in the TileEntity class for 1.11 (which is what I am currently working with). -
(Solved) [1.11] Replacing block with another block
Rohzek replied to Rohzek's topic in Modder Support
@Mod.EventBusSubscriber public class DecorateBiomeEventSP { @SubscribeEvent public static void onDecorateBiome(DecorateBiomeEvent.Decorate event) { World world = event.getWorld(); BlockPos pos = event.getPos(); EventType type = event.getType(); if(type == EventType.PUMPKIN) { event.setResult(Result.DENY); world.setBlockState(pos, SPBlocks.PUMPKIN_SP.getDefaultState()); } } } I'm only replacing the melons and pumpkins. The melons use the same texture so I just changed the drop you get with the harvest drops event to my custom one, but my custom pumpkin removes the face (and will make you carve one on, to get the vanilla pumpkin... unless I can make a custom block work to spawn the snow golem) so I'm trying to replace them. -
(Solved) [1.11] Replacing block with another block
Rohzek replied to Rohzek's topic in Modder Support
So, I can block the spawn with: setResult(Result.DENY); That actually didn't seem to block them from spawning, for some reason. -
How would one go about stopping the spawn of a vanilla block, say, the Pumpkin and replacing it with a modded block? On world generation, that is, not on growing.
-
That's what I would have thought. But either I messed this up hard, or I don't seem to have that option.
-
What's exactly is the new way to check for a block when mining it? It used to be if(event.block == Block.whateverblock) {} and it now seems it has to be... if(event.getclass() == whateverblock.class) {} ...is that it?
-
(SOLVED) [1.11] Changing Texture/Model file on right click?
Rohzek replied to Rohzek's topic in Modder Support
Registering my item this way, worked perfectly. I now have textures in the game, and can cycle between the different textures no problem. Thank you all, so much. -
(SOLVED) [1.11] Changing Texture/Model file on right click?
Rohzek replied to Rohzek's topic in Modder Support
I was calling it during the preinit of my main class public static void PreInit(FMLPreInitializationEvent PreEvent) { MinecraftForge.EVENT_BUS.register(new LoadModelEvent()); } I also tried (after reading through Choonster's link) making it static, and making that public static void PreInit(FMLPreInitializationEvent PreEvent) { MinecraftForge.EVENT_BUS.register(LoadModelEvent.class); } Which also didn't work. I then tried removing that, and using: @Mod.EventBusSubscriber public class LoadModelEvent { ... } Which runs, and gets a nullpointerexception because the items aren't loaded yet... Attempting to load the items by registering them in the event too instead of normal fixes that, but then they get initialized as being from minecraft instead of being from my MODID Exception loading model for variant minecraft:testitemstage0#inventory for item "minecraft:testitem", normal location exception: Sorry, I am 100% thoroughly lost and confused. -
(SOLVED) [1.11] Changing Texture/Model file on right click?
Rohzek replied to Rohzek's topic in Modder Support
I seem to be failing to properly register my ModelRegistryEvent, as it seems it doesn't complain because that method never runs? I've tried registering it with the forge event bus in both my Main, and ClientProxy and neither works... ...This is probably all wrong? MinecraftForge.EVENT_BUS.register(new LoadModelEvent()); LoadModelEvent: ... @SubscribeEvent public void onModelRegistry(ModelRegistryEvent event) { testItems.registerRenders(); } TestItems: ... public static void registerRenders() { registerRender(testItem, 0, "Stage0"); registerRender(testItem, 1, "Stage1"); registerRender(testItem, 2, "Stage2"); } public static void registerRender(Item item, int meta, String addon) { ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName() + addon, "inventory")); LogHelper.debug("I should be loading the json file for: " + item.getRegistryName() + addon + " and setting metadata: " + meta); } -
(SOLVED) [1.11] Changing Texture/Model file on right click?
Rohzek replied to Rohzek's topic in Modder Support
Hmm. That sounded easy until I managed to confuse myself. I was originally using and it could find my original json file just fine, and it showed in game. I tried changing that to take a string to seperate them, making it: And that didn't complain about not being able to find my new json files, but it was broken texture in game. After switching that to ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName() + addon, "inventory")); Now it also can't find my json files. After remembering to register my event, same problem as above. It doesn't complain that it can't find the json files... ...it just doesn't load the textures in game. -
(SOLVED) [1.11] Changing Texture/Model file on right click?
Rohzek replied to Rohzek's topic in Modder Support
Just the easiest way. Preferably if it doesn't involve just removing the item, and adding in another one. -
Is there an easy way to change the texture of an item in say, an overridden onItemRightClick, by changing which layer, or which model file is being loaded?
-
In your item class. You'll have to create a new item class and extend either sword or bow... or item. Yep it's Item#getDamageVsEntity—at least it's the same in 1.7.10 anyway.
-
Depends on if you want the "drawing" animation or not. Either as Failender said with a bow which will have the animation or by making a normal sword and overriding onItemRightClick and make it spawn an arrow on right click to fire without an animation
-
I know that much. As I said (the quick buttons don't seem to be working right now so... improvise) "which is the spawn block in world under onupdate.. taken straight from the vanilla code for melons..." Line 120 is world.setBlock(j1, y, k1, this.block); but I can't even begin to imagine why that could be null. The stem works fine on it's own... as does the melon block... it's when it tries to spawn a melon that it breaks.. and the code is literally copy pasted from the vanilla code. I don't understand why it's not working. EDIT: Out of curiosity.. I just deleted that entire class and started over RE copypasta-ing and refactoring variables.... and this time it worked just fine.... I don't even know what was up but thats fixed. That just leaves the particles of my custom food being a weird color.
-
Are you making a new GUI for the player inventory or trying to change the vanilla one?
-
More custom food errors... but this time only halfway related to the spoiling food... Namely those foods have messed up particles So this was interesting to try and snap a picture for but: The food particles don't look anything like ANY of the textures I have registered for this... Is there a easy way to fix or remove them? and more pressingly: My custom block/stem crops are crashing with: java.lang.NullPointerException: Exception ticking world ... at com.Rohzek.food.crop.BlockStem.updateTick(BlockStem.java:120) ... which is the spawn block in world under onupdate.. taken straight from the vanilla code for melons... Not sure whats wrong with it?
-
Hmm. Interesting. I COULD compound things by adding checks to see how long it's been since the update function of the entityitem has ran similar to how I handled the chest..but I'm not sure I care THAT much, at least right now... I guess item frames are free safe storage for my foods then. Thanks.
-
[1.7.10] How change texture 'onItemRightClick'
Rohzek replied to goodmanalex's topic in Modder Support
You could save a number to the itemstack's nbt and change that number on right click. Then in your geticon method load the number from the nbt and say if the number is equal to whatever number, change the texture to another one -
EDIT: I still don't know how to deal with Item Frames.. but my problem my last problem was one number out of place messing the numbers up. Anyone have any ideas about how to work with item frames? Do I still have access to the entityItem / the itemstack's nbt or something somehow while it's on an item frame?