Jump to content

DimensionsInTime

Members
  • Posts

    24
  • Joined

  • Last visited

Everything posted by DimensionsInTime

  1. You are re-inventing the wheel. Look at the Block::getDrops, Block::getItemDropped and Block::quantityDropped methods. You can override these to set what is dropped when a block is broken.
  2. Have you ever been able to place a bucket on the ground in Minecraft?
  3. I've never found such a resource, but if you keep the idea that game logic runs on the logical server and client interaction/graphics runs on the logical client you should be okay.
  4. Do you mean you want to place the lava bucket? On the ground?
  5. All outlined in the docs: https://mcforge.readthedocs.io/en/latest/concepts/sides/ But do some experimenting to see what runs where. if(world.isRemote){ // Log something }else{ // Log something else } and see what happens, when it happens, where it happens.
  6. TheGreyGhost makes a great tool called ItemTransformHelper that you can use to help figure out item transforms when creating your jsons. Place it in your run/mods folder, start your mod and put the camera from the mod's creativetab in your toolbar. Viola, a tool to manipulate the item and get the values you need.
  7. Think I have it now. I kept it falling, but scrapped the code from WorldGenMinable and just wrote a small iterator that creates the vein right where I want it, as you suggested. Seems to work ok, going to do some testing today to be sure. Added sets for the blocks the ore spawns into, and liquid blocks to look for nearby when deciding to spawn. The chance to spawn is lower because the ore has tiny chance to drop things other than a dust, like gold nugget, coal, clay balls or diamond/emerald shards or full items. New class:
  8. More progress (?) This morning I bypassed WorldGenMinable and put the meat of it into my own method called createVein(..), with the only difference being it no longer looks to make sure it's replacing the correct block type. Started a new world and found some water and quickly saw that ocean blocks with high light levels (near the surface) were being replaced with my ore. Which is a falling ore like sand. So it would spawn and fall, and the loop would continue so another would spawn and fall, and so on, and so on... Also, finding the ore spawned at the surface in villages replacing blocks making up wells and horribly ruining the villagers crop areas. Whoops! Now I know why the routine specifies a block you want to replace.
  9. New findGroundLevel(..) method: Seems to work MUCH better! I capture brightness too, just to test things like blocks under trees. So far a light level of 10+ seems to be a great gauge for finding ground level. However, when I find water near the block and run the following to generate a vein of ore it still doesn't work. I do pass WorldGenMinable#generate that third parameter as a predicate, so I'll have to look at it further tomorrow.
  10. Yes! I did see that happening, actually, though some of that may have been stopped by the check for and air block above the center block in the search. Thanks for the suggestion. I think what I might do for testing purposes is create an item that I can right click on a block so I can do some sort of visual representation of the search for water to make sure it's working properly. With regard to my problem with WorldGenMinable not actually replacing blocks, you think it could be because it's encountering air blocks (since it's start point is on the ground) causing it to crap out? I haven't wrapped my head around how the code in there works.
  11. I might be going about this the wrong way, not sure. I am trying to generate my custom ore only around water and only at the surface. My idea was to use a standard method that implements IWorldGenerator (like everyone does) but in the generate method it would choose a random x and z, then start at z=50 and move upward until I find a block that can see the sky, hopefully giving me a surface block. Then search the surrounding blocks in a radius of 3 blocks to see if water is nearby. If all those match, run a WorldGenMinable to generate my vein. The problem I'm having is the find surface and find water routines seem to work well, it's just not generating the vein or ore at the block position found. Prior to this, I had a normal random version that simply replaced stone on y=55-95 and it worked fine. But the mod ore is alluvium based (silty dirt/clay/sand composite found near waterways) and I want to keep with an accurate portrayal of where the ore is found. Some code: World Generation This is called in the init() section of the main mod class with simple "EPWorldGeneration.init();" Ore Generation The constructor makes sure we're in the overworld. EP_ALLIVIUM_ORE is my custom ore. findGroundLevel(..) starts at x, 50, z and moves up y++ until it hits ground level or returns zero. isBlockNearWater(..) searches in a block radius to see if water is nearby. In the generateInOverworld(..) method I added BlockDirt, BlockGrass and BlockClay to see if it would help in finding somewhere to generate the vein. It finds blocks, but the gen.generate(..) call does nothing. I surrounded it with an if/then to log the result, and the log shows "Ore Gen:" lines so I know the code is successfully reached. But when you /tp to the coords you see that the block has not changed to the custom ore block. NOTE: If you run this code to test and use the logging lines it will slow down worldgen a lot, so be prepared. Also, logging class is below to make things easier. EDIT: Found a bug already myself in this code I believe. In isBlockNearWater(..) the for loops for x and z should start at xIn - radius and yIn - radius so the loops cover the entire radius around the block... Logging Class
  12. Aha, sorry I did read right past that in his first post. I just did that exact same thing (leave item in crafting table) too!
  13. To answer your other question, you can use the ore dictionary to use varied items into your recipe. I would write the recipe like this: GameRegistry.addShapedRecipe(new ItemStack(moditems.castPA, 1), "SSS", "SDS", "SSS", 'S', Blocks.SAND, 'D', new ItemStack(Items.DIAMOND_PICKAXE, 1, OreDictionary.WILDCARD_VALUE)); Changing T to D is my OCD kicking in. I'm actually torn between using D or P. I need help...
  14. Your play code was in there, it's how I knew you had that complicated pitch formula there. You just had a few nested spoiler tags that made it hidden. You have stream set in your json, so it should start playing right away instead of loading then playing.
  15. 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F Why is your pitch that complicated formula and not 1.0F for normal speed?
  16. Solved. I was making it harder than it was I guess. @Override public ItemStack getContainerItem(@Nonnull ItemStack stack){ return stack.getItemDamage() < stack.getMaxDamage() ? new ItemStack(stack.getItem(), 1,stack.getItemDamage() + 10) : ItemStack.EMPTY; } Works great.
  17. Whoops, missed that new method. Fixed. Thanks. The hammer item still disappears on crafting. Recipe is a shapeless where a stack of another item is given when you place the hammer and a block/item in the table. In the hook code I see it checks for container and returns the stack if not empty, has max damage, etc. Looks as if this is called on crafting, so is that the right place to return the stack to keep it in the table? Recipes:
  18. Is setting hasContainerItem() and getContainerItem() not enough to keep an item in the table on latest forge versions? Found posts for previous versions where it worked in older versions. I have an ItemTool extended class that I want to stay in the table and just have some damage after crafting. Thanks for any help! Item Class: ItemTool Extension Class:
  19. Hi, Continuing work on my bucket mod, I want to be able to switch models based on what the bucket contains, so I made a model bakery. All seems to work fine and the bucket in the player's hand changes based on the NBT fine. But the itemstack icon on the toolbar changes to the first registered render, even on a call to getModel(1) where 0 = water in the bucket and 1 = lava. Hope that makes sense... Am I missing something? After further research, basing what I want to do off GreyGhost's Animate Tutorial is not the right way to do it. Back to drawing board.
  20. As promised, here's the solution I just wrote for my recipe need: package info.dimensionsintime.additionalbuckets.recipe; import com.sun.istack.internal.NotNull; import info.dimensionsintime.additionalbuckets.utility.NBTData; import net.minecraft.block.Block; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; import java.util.ArrayList; import java.util.Iterator; public class ShapelessNBTRecipe implements IRecipe { private ItemStack output = null; private ArrayList<Object> input = new ArrayList<Object>(); public ShapelessNBTRecipe(Block result, @NotNull Object... recipe){ this(new ItemStack(result), recipe); } public ShapelessNBTRecipe(Item result, @NotNull Object... recipe){ this(new ItemStack(result), recipe); } public ShapelessNBTRecipe(ItemStack result, Object... recipe) { output = result.copy(); for (Object in : recipe){ if (in instanceof ItemStack){ input.add(((ItemStack)in).copy()); }else if (in instanceof Item){ input.add(new ItemStack((Item)in)); }else if (in instanceof Block){ input.add(new ItemStack((Block)in)); }else if (in instanceof String){ input.add(OreDictionary.getOres((String) in)); }else{ String ret = "Invalid NBT shapeless ore recipe: "; for (Object tmp : recipe){ ret += tmp + ", "; } ret += output; throw new RuntimeException(ret); } } } @Override public boolean matches(InventoryCrafting inv, World worldIn){ ArrayList<Object> required = new ArrayList<Object>(input); for(int s = 0; s < inv.getSizeInventory(); s++){ ItemStack slot = inv.getStackInSlot(s); if(slot != null){ boolean inRecipe = false; Iterator<Object> req = required.iterator(); while (req.hasNext()){ boolean match = false; Object next = req.next(); if (next instanceof ItemStack){ if(NBTData.hasTag(slot, "containedBlock")){ if(NBTData.getString(slot, "containedBlock").equals(NBTData.getString((ItemStack)next, "containedBlock"))){ match = true; } }else{ if(slot.getItem() == ((ItemStack) next).getItem()){ match = true; } } } if(match){ inRecipe = true; required.remove(next); break; } } if (!inRecipe){ return false; } } } return required.isEmpty(); } @Override public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting){ return this.output.copy(); } @Override public int getRecipeSize(){ return this.input.size(); } @Override public ItemStack getRecipeOutput(){ return this.output; } public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) { ItemStack[] aitemstack = new ItemStack[inventoryCrafting.getSizeInventory()]; for (int i = 0; i < aitemstack.length; ++i) { ItemStack itemstack = inventoryCrafting.getStackInSlot(i); aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack); } return aitemstack; } } As I said before, the buckets in the mod have NBT set to save the Block the bucket contains in a string ("containedBlock") that actually is the Block's unlocalized name in a string. Keep in mind this is for shapeless recipes, and it's based off the Minecraftforge ShapelessOreRecipe class. The NBTData class in the utility package is just a helper class that checks and fetches NBT data from ItemStacks. And here's how you set the recipe. You create a holder instance of the correct ItemStack and set the desired match NBT on it, then register your recipe like a normal shapeless (EDIT: except it's ShapelessNBTRecipe instead of ShapelessOreRecipe - thought I should point that out!). ItemStack stackHolder = new ItemStack(ModItems.bucketWoodFull); NBTData.setString(stackHolder, "containedBlock", "tile.water"); GameRegistry.addRecipe(new ShapelessNBTRecipe(new ItemStack(Blocks.clay), stackHolder, Blocks.dirt, Blocks.gravel, Blocks.sand)); The result of this recipe is one clay block when you put one of my Wood Buckets (stackHolder) that is filled with water plus one each of dirt, gravel and sand into the table. Hope this helps you, and maybe others!
  21. @ coolAlias Thanks again! @ WeiseGuy Not sure we're looking to do the same thing, but I'll let you know when I get the solution for my problem done.
  22. Yes! Storing bucket data for each stack in NBT is exactly what I've done (my title says NBT, sorry I didn't make that clear in the text of my post). I thought that I might have to create my own recipe class, I just thought I remembered seeing a post long ago where someone set recipes using NBT without creating their own class. I was also toying with the idea of creating something akin to the Cauldron that you could drop water and other blocks like dirt, cobble and gravel into to get clay. The more I think about a recipe for it, the more I feel it might be too easy.
  23. I'm working on a custom buckets mod, and the mod contains two base item classes: BucketEmpty and BucketFull. BucketFull stores the contained liquid in a private Block var called "containedBlock". So far things are working great, but I just ran into my first hitch with my planned design - recipes. I want an instance of a FullBucket item that contains water to be used in a recipe to make clay. A FullBucket item + a dirt block + a gravel block = a clay block. But the following tells the game nothing about what FullBucket contains: GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Blocks.clay), new Object[]{ModItems.bucketWoodFull, Blocks.dirt, Blocks.gravel})); FYI, ModItems.bucketWoodFull is a class that extends FullBucket. I tried adding another var to the FullBucket class called "containedBlockName" and setting it to "water" if any kind of water was set as the containedBlock, plus creating a getter for it. This throws an exception (as I thought it would): GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Blocks.clay), new Object[]{ModItems.bucketWoodFull.getContainedBlockName().contains("water"), Blocks.dirt, Blocks.gravel})); So, is there a way to create a recipe that checks for value like I am trying to do? I looked at RecipesFood where cookies use a dye color, but not quite what I want.
×
×
  • Create New...

Important Information

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