Jump to content

Atijaf

Members
  • Posts

    198
  • Joined

  • Last visited

Posts posted by Atijaf

  1. When an item is shift clicked from from a chest, it is organized into your inventory.

     

    I.e. Shift clicking on 64 oak within a separate inventory will fill oak stacks in your inventory first, before adding new ones.

     

    Is there a way to call that method, that transfers the stacks, from the event "PlayerOpenContainerEvent"?  Or will I have to write my own code?

     

    Thanks!

  2. Hi, the problem I am having is obtaining the ItemStack's stackSize when the player shift clicks the result.  The stackSize is always 0.

    But, when the player clicks and drags the item, it obtains the correct stack size.  Any ideas?

     

    Thanks!

  3. I'm trying to make it to where you can only craft slabs with the base block (Meta of 0)

    Or in other words, a sandstone block can be used to make a sandstone slab, but a chiseled, or smooth, sandstone block can't be used to make a sandstone slab.

     

    This is how I'm going through my recipes

     

     

    Iterator<IRecipe> Leash = recipes.iterator();
    	{
    		IRecipe recipe = null;
    		while (Leash.hasNext())
    		{
    			//Get Recipe
    			recipe = Leash.next();
    			//Remove Recipe
    
    			if(recipe instanceof ShapedRecipes)
    			{
    				ShapedRecipes shapedRecipe = (ShapedRecipes) recipe;
    				if(removedCraftingRecipes_OUTPUT.contains(recipe.getRecipeOutput().getItem()))
    				{
    
    					//Check if recipe is to not be added
    					for(int index = 0; index < shapedRecipe.recipeItems.length; index++)
    					{
    						if(shapedRecipe.recipeItems != null)
    						{
    							//Check if ItemStack is being made with the materials I don't want them to be made with
    							if(removedCraftingRecipes_INPUT.contains(shapedRecipe.recipeItems[index]))
    							{
    								Leash.remove();
    							}
    						}
    					}
    				}
    			}
    		}
    

     

     

     

    removedCraftingRecipes_OUTPUT

     

     

    private static Set removedCraftingRecipes_OUTPUT = Sets.newHashSet(new Item[]{
    		Item.getItemFromBlock(Blocks.stone_slab), Item.getItemFromBlock(Blocks.stone_slab2)
    });
    

     

     

     

    removedCraftingRecipes_INPUT

     

     

    private static Set removedCraftingRecipes_INPUT = Sets.newHashSet(new ItemStack[]{
    	/*Smooth SandStone */new ItemStack(Blocks.sandstone, 1, 2),	/*Chiseled SandStone */new ItemStack(Blocks.sandstone, 1, 1),
    	/*Smooth RedSandStone */new ItemStack(Blocks.red_sandstone, 1, 2),	/*Chiseled RedSandStone */new ItemStack(Blocks.red_sandstone, 1, 1),
    	/*Chiseled Quartz Block */new ItemStack(Blocks.quartz_block, 1, 1),	/*Piller Quartz Block */ new ItemStack(Blocks.quartz_block, 1, 2),
    	/*Mossy Stone Brick*/new ItemStack(Blocks.stonebrick, 1, 1),	/*Cracked Stone Brick */new ItemStack(Blocks.stonebrick, 1, 2),
    	/*Chiseled Stone Brick */new ItemStack(Blocks.stonebrick, 1, 3)
    });
    

     

     

     

     

    The meta data of sandstone that is used to craft the slabs is always 32767.  Why is that the case?

     

    Thanks!

  4. I understand that this post is old, but I have completed implementing a block storage that stores the location, and the block's id/meta.

     

    I have a List of dimensions, -1 through 14. (-1 is actually 15), and any other dimensions can go up to 14.

     

    Inside the list of dimensions, holds a sorted ArrayList of my "ChunkPos" objects. (These objects contain dimension Id, X and Z position.  48 bits... 4 bits dimension, 22 bits X, 22 bits Z) 

     

    This chunk also holds a HashMap of my "ChunkBlockPos" objects.  (These objects contain x -4 bits, y -8 bits, and z-4 bits coords.  Along with the block Id -12 bits and meta -4 bits)

     

    Each chunk is 48 bits, and each block within is 32 bits.  That is also calculated without java's overhead for my classes and whatnot...  Unfortunately, I had to include the block's id and meta, in case if the player places a sapling and it grows, the location of the sapling is now wood and that wood was not placed by a player.

     

     

    And now for getting the information.  When a player places a block, it goes into the dimension list, it then does a binary search for the chunk, and if not found, creates a new chunk, instantiates the hashmap within, and instantiates a "ChunkBlockPos", inserts that into the hashmap, and adds the hashmap to the dimension list.

     

    In other words, if there are 100,000 chunks stored within the dimension list, it can find the correct chunk within 17 searches doing a binary search.  Woot!

     

    AND NO, I haven't been working on this for a year.  I was just looking through my questions and found this one.  I figured I'd update it and say thanks to all of y'all!  Thanks!

  5. I am adding my own crafting requirements to some tools, including this one.  I've made a way to automate a process so that I would not have to re-enter all of the crafting recipes for each and every item.  This automation grabs the recipe from the IRecipe like so.

     

    //My recipe String.  It is later separated every 3 places into 3 separate Strings.
    
    //Used to define where and what an item is in the recipe
    char letters[] = {'a','b','c','d','e','f','g','h','i'};
    
    String recipeData = "";
    
    //Gets list of Items within 
    Object[] locationNumbers = ((ShapedOreRecipe)recipe).getInput();
    
    for(int i = 0; i < locationNumbers.length; i++)
    {
        //Null Checks and instanceChecks
        //Add to the crafting recipe (It would look similar to this , 
        //"abc", "def", "ghi"  ... But not in this case.  Read notes below...)
        recipeData += letters[i];
    }
    
    

     

    in the end, the recipeData looks like...  "abc" , "d f", "".

    When it should look like... "ab " , "cd " , " f "

     

    And after Everything is finished, it would look like this...

     

    "aa " , "ad" , " d " , 'a', new ItemStack(Blocks.Blocks.planks), 'd', new ItemStack(Items.stick);  ... Which happens to be the recipe for the axe, more or less.

     

     

    More information:

    locationNumbers is an array of data (0 through 8, with some being null for blank spots)

     

    for the axe, locationNumbers holds datas (0,1,2,3,5) numbers 4,6,7,8 are null.

    or in other words, my recipe would look like this if I stored numbers from directly above.  "012", "3 5", ""

    AND that's not the axe shape.

     

    Another thing to note is that this works on about a hundred other recipes.

     

     

    And for the question if you haven't guessed it.

    Anyone have any clue as to why locationNumbers have datas (0,1,2,3,5) and not (0,1,3,4,7)? or ("01 " , "34 " , " 7 ")

     

     

    Fore reference

    I tried to simplify what was being asked, so information in paste bin is slightly different.

    http://pastebin.com/isxPNT8z

  6. I am adding my own crafting requirements to some tools, including this one.  I've made a way to automate a process so that I would not have to re-enter all of the crafting recipes for each and every item.  This automation grabs the recipe from the IRecipe like so.

     

    //My recipe String.  It is later separated every 3 places into 3 separate Strings.
    
    //Used to define where and what an item is in the recipe
    char letters[] = {'a','b','c','d','e','f','g','h','i'};
    
    String recipeData = "";
    
    //Gets list of Items within 
    Object[] locationNumbers = ((ShapedOreRecipe)recipe).getInput();
    
    for(int i = 0; i < locationNumbers.length; i++)
    {
        //Null Checks and instanceChecks
        //Add to the crafting recipe (It would look similar to this , 
        //"abc", "def", "ghi"  ... But not in this case.  Read notes below...)
        recipeData += letters[i];
    }
    
    

     

    in the end, the recipeData looks like...  "abc" , "d f", "".

    When it should look like... "ab " , "cd " , " f "

     

    And after Everything is finished, it would look like this...

     

    "aa " , "ad" , " d " , 'a', new ItemStack(Blocks.Blocks.planks), 'd', new ItemStack(Items.stick);  ... Which happens to be the recipe for the axe, more or less.

     

     

    More information:

    locationNumbers is an array of data (0 through 8, with some being null for blank spots)

     

    for the axe, locationNumbers holds datas (0,1,2,3,5) numbers 4,6,7,8 are null.

    or in other words, my recipe would look like this if I stored numbers from directly above.  "012", "3 5", ""

    AND that's not the axe shape.

     

    Another thing to note is that this works on about a hundred other recipes.

     

     

    And for the question if you haven't guessed it.

    Anyone have any clue as to why locationNumbers have datas (0,1,2,3,5) and not (0,1,3,4,7)? or ("01 " , "34 " , " 7 ")

     

     

    Fore reference

    I tried to simplify what was being asked, so information in paste bin is slightly different.

    http://pastebin.com/isxPNT8z

  7. As for my understanding of java.  The method #setStrings(String... data)

    allows for passing multiple string parameters.

     

    How would one do that with objects?  #setObjects(Object... data)

     

    is there a way to return an object holding data?

     

    For example

    String[] StringArray = new String[3];
    char[] charArray = new char[2];
    ItemStack[] stackArray = new ItemStack[2];
    
    //How can I do this.  Is it possible?
    Object obj = (stackArray, charArray, stackArray);
    

     

    I know this is more of a "java related question", but what I am trying to do is add crafting recipes and I need to pass an object. (It's a little bit more complicated than that, but the main point is here)

     

    Thanks!

  8. As for my understanding of java.  The method #setStrings(String... data)

    allows for passing multiple string parameters.

     

    How would one do that with objects?  #setObjects(Object... data)

     

    is there a way to return an object holding data?

     

    For example

    String[] StringArray = new String[3];
    char[] charArray = new char[2];
    ItemStack[] stackArray = new ItemStack[2];
    
    //How can I do this.  Is it possible?
    Object obj = (stackArray, charArray, stackArray);
    

     

    I know this is more of a "java related question", but what I am trying to do is add crafting recipes and I need to pass an object. (It's a little bit more complicated than that, but the main point is here)

     

    Thanks!

  9. Thanks!  I'll take a look into that!

     

    Another thing is that I don't necessarily need to change the recipe's input and output.  The additional requirement is based on the player's level in one of my skills.

     

    I also want to clear up what I asked earlier just to be sure I was understood.  Can I get the input and output from the recipe?  Or am I able to obtain the input and output in any ways?

  10. Thanks!  I'll take a look into that!

     

    Another thing is that I don't necessarily need to change the recipe's input and output.  The additional requirement is based on the player's level in one of my skills.

     

    I also want to clear up what I asked earlier just to be sure I was understood.  Can I get the input and output from the recipe?  Or am I able to obtain the input and output in any ways?

  11. I have followed a tutorial on how to create custom requirements for crafting recipes.  What I want to do now, is replace all of the vanilla recipes with my custom ones, but before I do that, is it possible to use the "IRecipe" to obtain the crafting result and what's required in order to re add the recipe back to minecraft.

     

    For example:

    //The idea.  Is there any way to replicate this?
    GameRegistry.addRecipe(vanillaRecipe.outPut, vanillaRecipe.contents);
    

     

    Here is what I've gotten so far.

    http://pastebin.com/7yBqKVxW

     

    Thanks!

  12. I have followed a tutorial on how to create custom requirements for crafting recipes.  What I want to do now, is replace all of the vanilla recipes with my custom ones, but before I do that, is it possible to use the "IRecipe" to obtain the crafting result and what's required in order to re add the recipe back to minecraft.

     

    For example:

    //The idea.  Is there any way to replicate this?
    GameRegistry.addRecipe(vanillaRecipe.outPut, vanillaRecipe.contents);
    

     

    Here is what I've gotten so far.

    http://pastebin.com/7yBqKVxW

     

    Thanks!

  13. The additional requirement is whether or not the item that is on the ground has been modified, by the player, in any way - If the block was placed by the player and then broken, or if the player drops the block it'll have a NBTTag storing a boolean.  A method for getting that information #isCollectable(ItemStack)

     

    I've made a skill that depends on blocks that are naturally generated by the world and when the player collects said blocks.

     

    But, the merging thing was just an extra step towards making this a little bit more friendly.  For instance, if one block of stone is collectible, and another block of stone is not collectible, and they merge, the two of them become non collectible and won't count towards the skill.

  14. Am I suppose to call the get method in order for it to run #readFromNBT?  I do call it, but is there a certain place that I'm suppose to do that?

     

    Also, I get this error

     

     

     

    [03:54:14] [server thread/INFO] [FML]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@359173ac)
    [03:54:14] [server thread/INFO] [FML]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@359173ac)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: java.lang.RuntimeException: Failed to instantiate class MCO.World.WorldData
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.world.storage.MapStorage.loadData(MapStorage.java:59)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at MCO.World.WorldData.get(WorldData.java:26)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at MCO.Events.PlayerEvents.worldEvent(PlayerEvents.java:433)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_PlayerEvents_worldEvent_Load.invoke(.dynamic)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:100)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:127)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:508)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at java.lang.Thread.run(Unknown Source)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: Caused by: java.lang.NoSuchMethodException: MCO.World.WorldData.<init>(java.lang.String)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at java.lang.Class.getConstructor0(Unknown Source)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at java.lang.Class.getConstructor(Unknown Source)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at net.minecraft.world.storage.MapStorage.loadData(MapStorage.java:55)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	... 9 more
    [03:54:14] [server thread/INFO] [FML]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@359173ac)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: java.lang.RuntimeException: Failed to instantiate class MCO.World.WorldData
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.world.storage.MapStorage.loadData(MapStorage.java:59)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at MCO.World.WorldData.get(WorldData.java:26)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at MCO.Events.PlayerEvents.worldEvent(PlayerEvents.java:433)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_PlayerEvents_worldEvent_Load.invoke(.dynamic)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:100)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:127)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:508)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at java.lang.Thread.run(Unknown Source)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: Caused by: java.lang.NoSuchMethodException: MCO.World.WorldData.<init>(java.lang.String)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at java.lang.Class.getConstructor0(Unknown Source)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at java.lang.Class.getConstructor(Unknown Source)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at net.minecraft.world.storage.MapStorage.loadData(MapStorage.java:55)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	... 9 more
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: java.lang.RuntimeException: Failed to instantiate class MCO.World.WorldData
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.world.storage.MapStorage.loadData(MapStorage.java:59)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at MCO.World.WorldData.get(WorldData.java:26)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at MCO.Events.PlayerEvents.worldEvent(PlayerEvents.java:433)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_PlayerEvents_worldEvent_Load.invoke(.dynamic)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:100)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:127)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:508)
    [03:54:14] [server thread/INFO] [sTDERR]: [net.minecraft.world.storage.MapStorage:loadData:70]: 	at java.lang.Thread.run(Unknown Source)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: Caused by: java.lang.NoSuchMethodException: MCO.World.WorldData.<init>(java.lang.String)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at java.lang.Class.getConstructor0(Unknown Source)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at java.lang.Class.getConstructor(Unknown Source)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	at net.minecraft.world.storage.MapStorage.loadData(MapStorage.java:55)
    [03:54:14] [server thread/INFO] [sTDERR]: [java.lang.Throwable:printStackTrace:-1]: 	... 9 more
    

     

     

  15. I do call the #get method.  After marking it dirty and it saves, #writeToNBT is called.

     

    I have a hierarchy of lists within lists...  This is saved within nbt in a long.

     

    The chunk requires about 48 bits, (22 bits x coord, 22 bits z coord, 4 bits dimension) in order to cover the Minecraft world of chunks and in which dimension they belong.  Then, within the chunk, I store the x, y, and z coords (4 bits, 8 bits, 4 bits), taking up a total of 64 bits. (During ram usage)

    So, in other words, A chunk needs 48 bits, and each block within needs 16.

     

    I do see your point on storing a long within the nbt...  I'll work on that after getting the #readFromNBT to work.  Perhaps I just need to update my forge version.

     

    I'll mess around with the code a little bit.

     

    Thanks for the help thus far.

  16. While debugging, I have a breakpoint at where #readFromNBT starts.  Nothing ever happens for me there.  I run it in debug mode.

     

    //Instead of this
    NBTTagList list = nbt.getTagList(IDENTITY, NBT.TAG_LIST);
    
    //I should do this?
    NBTTagList list = nbt.getTagList(IDENTITY, NBT.TAG_COMPOUND);
    //Because the integer passed is the type of NBT's the list is holding?
    

     

    Thanks for clarifying that bit up, was a little bit confused as to how that worked:)

  17. What would cause #readFromNBT to not be called?

     

    I have a class that extends WorldSavedData and that class overrides both writeToNBT and readFromNBT.

     

    get method

    public static WorldData get(World world)
    {
    	WorldData data = (WorldData) world.loadItemData(WorldData.class, IDENTITY);
    	if(data == null)
    	{
    		data = new WorldData();
    		world.setItemData(IDENTITY, data);
    	}
    	return data;
    }
    

     

    I use the get method and call #markDirty().  It then runs through #writeToNBT and I store data within the nbt.  I am fairly certain it is writing data correctly, but for some unknown reason, #readFromNBT is never called.

     

    Am I suppose to register my class somewhere or...

     

    Thanks!

×
×
  • Create New...

Important Information

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