Everything posted by WeiseGuy
-
[1.8]iinventory howto prevent a player to move certain slot in inventory<Solved>
IInventory has a "isUsableByplayer" method right? Or is that on Container? Either way, override it to false and/or some method to check if they can edit or not and you should be fine, no? By default its true, or its something like: @Override public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { return true; } Sometimes people use this to determine if player is within 8 blocks of the object: @Override public boolean isUseableByPlayer(EntityPlayer playerIn) { return worldObj.getTileEntity(pos) != this ? false : playerIn.getDistanceSq(pos.getX()+0.5D, pos.getY()+0.5D, pos.getZ()+0.5D) <= 64.0D; } Isn't that checking if the player is able to utilize the inventory, as in, modify it?
-
[1.7.10] Dual Input CRAFTING Table Help?
I GOT EVERYTHING WORKING! Except one part... Standard left/right click will call onCraftMatrixChanged which pulls my result from the crafting manager, I can click it to get said result and the input(s) decrements properly. However, Left click + drag into an input inventory Right click + drag into input inventory. These two functions do not seem to update the onCraftMatrixChanged and I am not sure where they are called. I checked the IInventory classes I created and the custom Slot Classes I made and don't see how to call onCraftMatrixChanged with these functions. It's only the "drag" functions whether its right or left click.
-
[1.7.10] Dual Input CRAFTING Table Help?
Well, tried that route, had some issues. I feel I was closer with another route. I also realized I don't need the tile entity since its insta-craft like a crafting table. The issue is vanilla's algorithms to take the addRecipe(Itemstack stack, Object ...) is COMPLEX and awesome, but hard for me to decipher. I'm working through that to see if I can emulate the addRecipe from vanilla into my mod to make recipe additions easier. Currently did fix the recipe issue I had, after removing tile entity, adding some more checks for null, etc. Working hard to get it done, so close!
-
[1.7.10] Checking if block is liquid or not
thank you, would it work with Material.Lava too? and would it do any difference between water and flowing water? Thanks! I know it works with flowing water as I've tested it myself to make some plants that check for water blocks nearby with getMaterial material.water. So source/flowing. I imagine lava works the same but haven't tested it yet. I will be soon though. Also, farmland (fertilized or hydrated soil in vanilla) does this code. Checks material water, that's how come your farmland hydrates even if flowing water is nearby.
-
[1.7.10] Dual Input CRAFTING Table Help?
I found it extremely difficult to try to figure out what the heck was going on. I will continue to look through and try to understand it though. I have like 15 tabs of code open from their GitHub. A couple modifier classes, some of the logic to determine whats modifiable, etc. Still trying to find where he says a 1x1 input (the tool) plus (in his case) a 2x2 (shapeless) input = 1x1 output so I can adopt to 1x1 + 1x3 (shapeless) = 1x1
-
[1.7.10] How to get harvest level from Tool? [RESOLVED]
You make great points, thanks. I removed the check for ItemSpade, but how do I get the harvest level of the held item without making it an itemstack? getHarvestLevel requires (itemStack. toolClass) parameters. This is where I am at so far, is that what you meant? Code functions fine, just want to ensure I don't break other mods (well, at least try not to break tinkers since its pretty widely used). @SubscribeEvent public void onBlockDropItems(BlockEvent.HarvestDropsEvent event) //This is overriding drop tables of vanilla blocks. { if (event.block == Blocks.gravel) { World world = event.world; EntityPlayer player = event.harvester; if(player.getHeldItem() != null) //If used an item. { ItemStack toolUsed = player.getHeldItem(); int toolUsedHarvestLevel = player.getHeldItem().getItem().getHarvestLevel(toolUsed, "shovel"); // Gets harvest level of said tool if (toolUsedHarvestLevel >= 2) //Iron or better, aka 2 or better. { if (world.rand.nextFloat() < 0.25f) //25% Chance to drop a RoughCrystalFragment if using the right shovel! { event.drops.add(new ItemStack(ModItems.itemRoughCrystalFragment, world.rand.nextInt(2) + 1)); //drops RoughCrystalFragment 1-2 } } } }
-
[1.7.10] Dual Input CRAFTING Table Help?
UPDATE: Well, I updated two classes: SocketStationContainer.java - Updated! - http://pastebin.com/UTtkLTea - Fixed shift clicking, items go into right slots, only allows to shift click into TE if its of the right item type. Fun fact, found out Hoe's don't extend ItemTool, weird, haha. Also fixed the onContainerClosed so it now spits my items back out when GUI closes. Still can't specify what goes into each slot when I click an drag the item to it. SlotSocketStation.java - Updated! - http://pastebin.com/f563JYhU - Attempted to make slots 1/2/3 only able to have a max stacksize of 1 with the new override. Didn't work, but realized I don't need to do that either so I've since removed the override. Fixed issue where now slots check for validation! TileEntitySocketStation.kava - Updated! - http://pastebin.com/xhuSuYLw - Changed to IInventory instead of ISidedInventory. Removed related methods that were implemented for it. Redid read/write NBT. Stuff still auto crafts on its own though.
-
[1.7.10] Dual Input CRAFTING Table Help?
UPDATE: I have been able to pretty much get all this done, but the original classes I posted here are EXTREMELY outdated at this point as I've rewritten almost everything from scratch. Once I'm completely done, I'll update the post with the current and working code for reference to anyone else. If you go to the last post by me in this topic, I have current issues I am working on there. I've been trying to make a multi-input crafting table, and I feel I'm REALLY close to completion, but I'm running into issues. I had followed a tutorial for a custom crafting table but it took the standard 3x3, or 5x5, or 1x3, not a dual input where its one column and another column to equal a new item. This time I followed a dual input furnace tutorial and took out any fuel code which is where I am now and associated code is below. I really can't seem to find anything to give this mechanic available in a tutorial and can't really think of a mod that has two separate craftMatrices. Most tutorials seem to say "copy the workbench's container code" but that code is assuming an array of 3x3 (which I can modify to make a 1x1 or a 1x3 of course, but not sure how to do a 1x1 + 1x3). I think the other issue I'm having is this dual input furnace stuff was having me copy some code from the vanilla furnace, which again lies the issue of This is an instant craft if fuel requirements met (which I took fuel out of the code), and instant eats them to give output. The concept: Inputs: I want to have a 1x1 input for tool/armor I want to have a 1x3 input for modifier items I'm calling sockets Output: I want a 1x1 output that will take the inputs, look for a recipe, craft said item like a crafting table does, instantly, no need to wait, but not until player clicks on the output to get the result. What I have working: Currently have my gui displaying properly, the container seems good and holds items though I need to figure out how to limit which items can go in which slots, and I have a couple recipes created that work but they are INSTA-CRAFTED as in, as soon as the final item is in place it consumes the input and leaves the result. Issues: Input items consume as soon as valid crafting recipe is found, leaving resulting item only. I need 1x1 to never be null, but my 1x3 to be shapeless. I can't figure out how to change my "canSocket()" code to allow slot 1/3 to be null for crafting. Breaking my Block (which is tied to a TileEntity) drops the block, but all items in the container are zapped away from existence and disappear forever, I want to just have it to where I close the inventory the items are spit out like a normal crating table. - Solved! I can't figure out how to say slot 0 is only instanceOf ItemTool / ItemArmor and slot 1, 2, 3 is only for instanceOf ItemSocket - Solved! isItemValid on SlotSocketStation added I can't get shift click to place items in proper slots, probably due to above mentioned problem. Like, I think I can even place items into my output still, REALLY weird. - Solved TODO on my part is once this is working this way, I need to figure out a nice way to add slots dynamically if possible since some tools will have 1 socket slot, others 3, but that's just dynamic GUI changes and won't be as bad once the basics are done. Source Code (I think this is everything, let me know if you need another file): Main Class (CrystalMagic.java) - http://pastebin.com/vGpgiRvv Machine Block (BlockSocketStation.java) - http://pastebin.com/iSqbfXze Container (SocketStationContainer.java) - http://pastebin.com/vKTD830K Crafting Recipes (SocketStationRecipes.java) - http://pastebin.com/iXvWcDbP GuiHandler (GuiHandler.java) - http://pastebin.com/8M6JDaNE Slot (SlotSocketStation) - http://pastebin.com/UgZj4wUy //Not entirely sure why this was needed, but it works I think for my result slot. I think....and was in the dual input furnace tutorial TileEntity (TileEntitySocketStation) - http://pastebin.com/DeSzqetr Gui (SocketStationGui.java) - http://pastebin.com/t0TnD4N7
-
[1.7.10] How to get harvest level from Tool? [RESOLVED]
Well, I resolved it myself. Easy enough, as soon as I posted I realized another way to test this. I'll leave topic open in case people have input on a better way or anything, but this works for me to have a harvest level 2 or above, which is iron level or better. I think any mod would at some point use ItemSpade to extend from, so this should cover any mod shovel I believe. @SubscribeEvent public void onBlockDropItems(BlockEvent.HarvestDropsEvent event) //This is overriding drop tables of vanilla blocks. { if (event.block == Blocks.gravel) { World world = event.world; EntityPlayer player = event.harvester; if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemSpade) //If its a shovel { Item toolUsed = player.getCurrentEquippedItem().getItem(); //Gets item used int toolUsedHarvestLevel = player.getCurrentEquippedItem().getItem().getHarvestLevel(new ItemStack(toolUsed), "shovel"); // Gets harvest level of said tool if (toolUsedHarvestLevel >= 2) //Iron or better, aka 2 or better. { if (world.rand.nextFloat() < 0.25f) //25% Chance to drop a RoughCrystalFragment if using the right shovel! { event.drops.add(new ItemStack(ModItems.itemRoughCrystalFragment, world.rand.nextInt(2) + 1)); //drops RoughCrystalFragment 1-2 } } } }
-
[1.7.10] How to get harvest level from Tool? [RESOLVED]
Hey guys, I'm having a small issue (brain fart if you will) on how the heck I can check the harvest level of a tool used in the OnBlockDropItems event. I feel I'm missing just one little thing, and I can't seem to find a method that would be along the lines of .getHarvestLevel() which grabs the harvest level of a tool if its a shovel. This is what I'm working with so far. @SubscribeEvent public void onBlockDropItems(BlockEvent.HarvestDropsEvent event) //This is overriding drop tables of vanilla blocks. { if (event.block == Blocks.gravel) { World world = event.world; EntityPlayer player = event.harvester; if(player.getCurrentEquippedItem() != null) { Item itemUsed = player.getCurrentEquippedItem().getItem(); // Checks what tool was that player used to break item. if (itemUsed == (Items.iron_shovel) || itemUsed == (Items.diamond_shovel)) //TODO check for material harvest level iron or better (2 or better) { if (world.rand.nextFloat() < 0.25f) //25% Chance to drop a RoughCrystalFragment if using the right shovel! { event.drops.add(new ItemStack(ModItems.itemRoughCrystalFragment, world.rand.nextInt(2) + 1)); //drops RoughCrystalFragment 1-2 } } } }
-
[1.8] plant growing
Bonemeal seems to randomly increase metadata, but not always by just 1 stage. Any mod that has a crop will very likely be using metadata to control its growth. You need an item to increment meta data. Not sure why you don't think that would work for you, especially when I'm saying I've made what you described to effect growth rate of a single block, which can easily be expanded to a 3x3 area like the extra utilities can will.
-
[1.8] plant growing
How do you want to effect it? Do you want to use an item like a watering can to increase growth rate like ExtraUtilities adds? If so, I can help with the code in 1.7.10, I haven't looked into 1.8 just yet though as most mods I play are 1.7.10 still so I'm making mine in 1.7.10 for now. If that's the effect you want, look at bonemeal functions or just look at how a plant grows. It has a random chance during it's updateTick to increase metadata (aka the growth stage). So on your item's onItemUse you can check if the block you are using it on is an instance of blockCrop for example, if so give a random chance to increase metadata by one .setBlockMetadataWithNotify(...); Here is an example of a debug item I use as a tool to increment/decrement my crop's growth stage (metadata) if its an instance of my crops specifically (OrePlant), the player is in creative, and the metadata isn't already at full grown or lower than 0. You would replace 7 with whatever your max growth stage is, so you may want to call that into a variable. All of my ore plants have a stage of 7 so I hard coded it, but I will likely go recode that later into a variable just to make things better. I can include the full file if you need me to. NOTE: THIS IS TESTED IN 1.7.10, I haven't tested it in 1.8 so methods may be changed. public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int worldX, int worldY, int worldZ, int blockSide, float p_77648_8_, float p_77648_9_, float p_77648_10_) { int blockMeta = world.getBlockMetadata(worldX, worldY, worldZ); Block block = world.getBlock(worldX, worldY, worldZ); Boolean isOrePlant = block instanceof OreCrystalPlant; Boolean isCreative = player.capabilities.isCreativeMode; if(blockMeta < 7 && !player.isSneaking() && isOrePlant && isCreative) //metaData cant go past 7, player is not sneaking. This is on our OrePlant. { blockMeta += 1; world.setBlockMetadataWithNotify(worldX, worldY, worldZ, blockMeta, 2); } So for the watering can I would add to that if statement (or nest all of this into an if statement) that does a random number, give it whatever % (like rand <=25 would be 25%) and let it increment.
-
[RESOLVED] Rotating a "blockCrop" to grow upside down? [1.7.10]
Wow, that platform though, haha. Awesome stuff. I'm marking topic resolved, thanks again for the help getting it done. I'd love to see blockRotate in some source somewhere, but I'll search on git later....time to work on other projects
-
[RESOLVED] Rotating a "blockCrop" to grow upside down? [1.7.10]
Makes complete sense, thank you. Got it all functioning just fine. Crops grow upside down, bound box even changes based on growth state (metadata). Still curious when one would want to use blockRotate, but that will be for another day.
-
[RESOLVED] Rotating a "blockCrop" to grow upside down? [1.7.10]
Alright, so bottom line the blockRotate isn't doing what I think it's doing or intended for that. Block bounds it is... Any clue as to when one would use blockRotate?
-
[RESOLVED] Rotating a "blockCrop" to grow upside down? [1.7.10]
This is in 1.7.10. I want to make a plant grow upside down. I have my blockCrop working just fine as far as growing properly, can stay on my custom soil, ticks properly, etc. However, since it's growing upside down I need to rotate the blockPlant (the block itself) 180 degrees when its placed by my "seed" item and can't seem to get it working. I am trying to override onBlockAdded so when its added by the seed's onItemUse it rotates, and I'm failing with what I assume is the axis parameter. http://pastebin.com/PijrLeHJ is the snippet of code I'm overriding. Am I on the right track or completely off here? Is there another method I can pass to rotate it? Am I using the wrong event? I feel like it's a matter of manipulating the axis parameter based on the java documentation, but I'm not getting it. EDIT: I know I can rotate the texture 180 in any editor and it would give the same look, but because its a crop, the bound box is still at the bottom so I get a floating wireframe. Do I need to set the bounding box myself and rotate the texture? Or is there a way to just rotate the block as it seems much more probably to do a rotation of the block over the X or Z axis.
IPS spam blocked by CleanTalk.