
statphantom
Members-
Posts
118 -
Joined
-
Last visited
Everything posted by statphantom
-
I have checked greyminecraftcoder and been looking at those examples but still cant figure out where to put my textures. I register my item here.... @EventHandler public void preInit (FMLPreInitializationEvent event) { System.out.println("Loading " + MODNAME + "!"); System.out.println("Version " + VERSION + "!"); sharpstick = new SharpStick(); MinecraftForge.EVENT_BUS.register(new LevelEventHandler()); if (event.getSide() == Side.CLIENT) { regTexture(sharpstick); <------ calling here } GameRegistry.addRecipe(new ItemStack(sharpstick), "A ", " A", 'A', Items.stick); } I have tried various places to put the texture files but I have put it in src/main/resources/assets/ModName/textures/items and my .json files in src/main/resources/assets/ModName/models/item
-
I am trying to register a texture but keep getting a nullpointer exception. Maybe it's because I'm using the forge eclipse environment it is not registering it in the right place? help anyone? I am using this.... public static void regTexture(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(MODID + ":" + item.getUnlocalizedName().substring(5), "inventory")); }
-
THANK YOU! Light bulb moment, I am such an idiot I completely forget it is a static variable in the mod class. I knew there was something wrong with my calling my item constructor but had no idea how to get around it, it is working now thanks!!!!
-
I still can't figure out this item spawning thing. I have added maxStackSize(64). however it still wont stack, maybe it's because I am creating a new ItemStack() and a new Item(). however I can get it to work without recalling the constructors, any help on what I am doing wrong? my code is on my previous post, thanks.
-
Finally got it working! the problem was is anouther coder told me to add the registry add inside of the constructor for my item so when I created a new item it was registering the item twice.... or am I supposed to do this in a way that I dont create a new SharkStick() object? I will post all 3 of my classes so anyone can tell me if anything is wrong, thanks Main Mod Class Event Handler Class My Item Class Thanks again for all your help guys! PS: also need to make the item stackable
-
That's great! I also knew mostly c and c++ before going into this. One thing to note is that some actions that you want to happen would probably be better inside the blocks themselves. Example from within a block that can be created public class testBlock extends Block{ private IBlockState state; public testBlock(Material material, IBlockState state){ super(material); this.state = state; //This could be the block you want it to be changed to when it is right Clicked } //When the block is right clicked, basically. @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ){ //This will be called when the block is right clicked. So it's changed to the state you passed in the constructor. //Also, only make changes with blocks on the server. To check, do this. if(!worldIn.isRemote){ worldIn.setBlockState(pos, this.state); //You could also have the player drop items from here, but I'll let you figure that out (You already did in the event handler!) } I have not tested the above code, but I am pretty sure it would work! I know you're messing around with events for the most part, but I thought that this would help you some how. Events are definitely good when working with vanilla blocks, but if you do end up creating new items, know that this is an option! Either way, good luck with everything! I hope this helps you. Thanks! any information is helpful since I'm starting out, I am messing with vanilla blocks right now but when I do custom blocks I will DEFINITELY come back here and re-read this
-
What do I use to get the itemStack of a custom item? Items class only contains vanilla items, do I need to do a search for name?
-
I can force an item to spawn at my feet, however how do I spawn this item at the event.world.loc? also this only worlds for vanilla items, how do I spawn in a custom made item? lets call it 'sharpStick' current code is: @SubscribeEvent public void onPlayerClickEvent(PlayerInteractEvent event) { if (event.action == Action.RIGHT_CLICK_BLOCK) { if (event.entityPlayer.getCurrentEquippedItem() == null) { if (event.world.getBlockState(event.pos).getBlock() == Blocks.grass && event.face == event.face.UP) { if (!event.world.isRemote) { event.world.setBlockState(event.pos, Blocks.dirt.getDefaultState()); event.entity.dropItem(Items.stick, 1); } } } } } I would like to replace event.entity.dropItem(Items.stick, 1); with a line that can drop my custom item on top of the block I right clicked on. my Item class just incase you want to see it.
-
another snag now I created an Item fine, added to the registry, can craft the item fine, but how do I spawn it without adding it to a block break drop? e.g. right clicking grass at the top with change the grass into dirt and then spawn a stick (mimics searching through the grass for a branch)?
-
understood, so basically anything @SideOnly(side.SERVER) wouldn't even compile in the clients code? PS: got 'face' checking working really well really quickly, getting the hang of this but ItemStacks will be a bit harder I think.
-
Yep that worked perfectly, i got a bit confused with the @SideOnly annotation, I think I am understanding it correctly that it basically does the same thing as the isRemote check however it is for a full method, so you don't need both of them.
-
Got it working right-clicking on grass with an empty hand replaces it with dirt please let me know if something is wrong either way. @SubscribeEvent public void onPlayerClickEvent(PlayerInteractEvent event) { if (event.action == Action.RIGHT_CLICK_BLOCK) { if (event.entityPlayer.getCurrentEquippedItem() == null) { if (event.world.getBlockState(event.pos).getBlock() == Blocks.grass) { if (!event.world.isRemote) { event.world.setBlockState(event.pos, Blocks.dirt.getDefaultState()); } } } } } now I will focus on item drops, and so only facing the top of the grass blocks works
-
does this mean that both client and server will read this but only the client will pass the test?
-
Thanks, I got confused between the Block and Blocks classes so have fixed this (if (event.world.getBlockState(event.pos).getBlock() == Blocks.grass)) also how do I make the code server side only? do I create a new method called 'swapGrassForDirt'? or can I add @sideonly(side.SERVER) just before the manipulation. @SubscribeEvent @SideOnly(side.SERVER) <------- here? public void onPlayerMineEvent(PlayerEvent.BreakSpeed event) { if (event.state.getBlock() == Blocks.log) { @SideOnly(side.SERVER) <------- or here? event.newSpeed = -1; } else { } } also, sadly the ONE thing I never learnt in java was thread handling so while I can read and understand that link, don't entirely know how to implement them on a VERY related topic, where would I add the !world.isRemote check?
-
Thanks! the API changes a lot so I find a lot of outdated information, I do know coding (C and C++ mostly) and am very interested in coding / gaming so learning minecraft is a perfect middle ground, At RMIT university to learn code. But anywho I won't go to the extreme of bothering you via skype calls and I just need pushes in the right direction, I have this so far... @SubscribeEvent public void onPlayerClickEvent(PlayerInteractEvent event) { if (event.action == Action.RIGHT_CLICK_BLOCK) { if (event.entityPlayer.getCurrentEquippedItem() == null) { if (event.world.getBlockState(event.pos).getBlock() == Block.getBlockById(2)) { } } } } seems to be happy, now lets learn about item and block replacements Thanks a lot for your help, it is not going unnoticed
-
How would you do this for PlayerInteractionEvent? as another example, right click a grass block and it will replace it with a dirt block? so far I have this... @SubscribeEvent public void onPlayerClickEvent(PlayerInteractEvent event) { if (event.action == Action.RIGHT_CLICK_BLOCK) { } }
-
Thanks! May I ask why this needs PlayerEvent instead of PlayerInteractEvent? has the latter been depreciated?
-
Hello, amateur coder, complete novice minecrafter here. I am doing some home projects to understand all the events, how they interact etc etc. I decided to change the Topic / Title of this thread since it has kind of become my HUB for help / progression on my Mod(s). I will post any ideas / problems / progressions I have and people can help me out develop my mod, I am using 1.8 as a pure learning curve, get something done that is playable to me and then come 1.9 I will adapt everything into 1.9 and then release it to the public My Idea is create a 'leveling from scratch mod' where you start from nothing but everything is harder to get and realistic (well as realistic as it can be), and also have to level up a various number of skills. e.g. you wake up, you gain the perception skill. you take your first step you gain the strength and agility skills ETC. Please post ANYTHING you like here, any ideas, any problems you can foresee, or any advice / help Remember I am very new to minecraft modding so this will take a while and I will need a lot of help also, Thanks! ~ Statphantom NEW VIDEO: 18/10/15 To Do: Add some fibrous plans (Jute Cotton etc.) to world gen. Get some good textures Add panning for metals Add camp fires Add bark building blocks for homes Create skills / levels GUI Done: Added string / rope from tensile weeds tall grass drops tensile weeds on occation Saved skills variables through death Created 3 skills for testing Crafting table New wood axe mechanics Add bark from trees Sticks can only be gathered from grass that has leaves above it Language file Learned texture placement Remove tree punching Add sticks from grass