Jump to content

Recommended Posts

Posted

I have a answer^^ xD i made a 5 input furnace but the system can Be extended as much as you want. I post the code later i have to find the right words for it^^

  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

Posted
  On 7/15/2013 at 3:32 PM, Moritz said:

I have a answer^^ xD i made a 5 input furnace but the system can Be extended as much as you want. I post the code later i have to find the right words for it^^

you didn't remember, did you?

Posted
  On 7/15/2013 at 3:32 PM, Moritz said:

I have a answer^^ xD i made a 5 input furnace but the system can Be extended as much as you want. I post the code later i have to find the right words for it^^

you DID forget... I'd really like to know still.

Posted

someones gonna have to make a tutorial for this because the question gets asked WAY too often

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

Sry i had to much todo with my Modular Machine that i had forgot the thing here^^"

I am really sorry! xD this machine is so hard to code! Its to much for a lonly person^^

But back to reallity^^

Now to the code

 

And i do know how it works! Only thing is its always a ShapedRecipe!

If you want to add a shapless recipe then you had to make it manually!

 

You only need to make a the furnace as normal. Everything as normal!

The only things what you have to change that he consumes all 3 inputs and the Recipe list!

 

I show you how that works!

Here the code:

 

public class FurnaceList
{
      private static FurnaceList recipes = new FurnaceList();

      public static FurnaceList smelting()
      {
           return recipes;
      }



      //RecipList i do not make a exp Bar. But its easy too
      private HashMap<List<Integer>, ItemStack> recipeList = new HashMap<List<Integer>, ItemStack>();
      //Why Do i make a Forge Meta Recipe list ?
     // Because its the Easiest way! 

    // Now The Tricky Part and do not say its a little bit big! I know that but Its working!
    public void addSmelting(ItemStack output, ItemStack input1, ItemStack input2, ItemStack input3)
    {
         int item1 = 0;
         int damage1 = 0;
         int item2 = 0;
         int damage2 = 0;
         int item3 = 0;
         int damage3 = 0;
         
         if(input1 != null)
         {
              item1 = input1.itemID;
              damage1 = input1.getItemDamage();
         }

         if(input2 != null)
         {
             item2 = input2.itemID;
             damage2 = input2.getItemDamage();
         }

         if(input3 != null)
         {
               item3 = input3.itemID;
               damage3 = input3.getItemDamage();
         }
         recipeList.put(Arrays.asList(item1, damage1, item2, damage2, item3, damage3), output);

    }
      
    public Map<List<Integer>, ItemStack> getRecipeList()
    {
        return recipeList;
    }

    public ItemStack getRecipeOutput(ItemStack input1, ItemStack input2, ItemStack input3)
    {
         int item1 = 0;
         int damage1 = 0;
         int item2 = 0;
         int damage2 = 0;
         int item3 = 0;
         int damage3 = 0;
         
         if(input1 != null)
         {
              item1 = input1.itemID;
              damage1 = input1.getItemDamage();
         }

         if(input2 != null)
         {
             item2 = input2.itemID;
             damage2 = input2.getItemDamage();
         }

         if(input3 != null)
         {
               item3 = input3.itemID;
               damage3 = input3.getItemDamage();
         }
         return recipeList.get(Arrays.asList(item1, damage1, item2, damage2, item3, damage3));
    }
}

 

I know its a lot of code.

Now to explaining.

 

When you add a recipe than it will safed as a list:

[item1, damage1, item2, damage2, item3, damage3];

so and if you want to get it then he looks at the rcipes list with the same informations.

So you can extend the code as much as you want. So long you make it as list^^

But this way you had to add every combination by yourself! Its always a shaped recipe!

So if you want to add a 1 item recipe than you had to add 3 recipes xD

 

And i think thats what you are looking for.

I hope it helps^^ xD

Posted

It works! I had to modify quite a few things in my TileEntity, but it works great! But right now I'm wondering if it would be possible to use the Arrays.sort method to arrange the recipes before comparing them. Could the Arrays for the arraylist be written something like (item1, item2, item3, meta1, meta2, meta 3) or something of that sorts, or if that doesn't work, maybe 2 arrays inside of one array being something like: recipelist(ArrayItems[], ArrayMeta[])??? I really want the shapeless stuffs....

Posted

xD Here a way to add a shaplessRecipe^^

 

//Your Add smelting function out of my old post. I do not want write everything doube

public void addSmelting(ItemStack output, ItemStack input1, ItemStack input2, ItemStack input3)
{};

public void addShaplessSmelting(ItemStack output, ItemStack in1, ItemStack in2, ItemStack in3)
{
      addSmelting(output, in1, in2, in3);
      addSmelting(output, in1, in3, in2);
      addSmelting(output, in2, in1, in3);
      addSmelting(output, in2, in3, in1);
      addSmelting(output, in3, in1, in2);
      addSmelting(output, in3, in2, in1);
}

with this function you make shaplessRecipes  XD So you can have both.
There might be easier ways but i do not know them!

  • 1 year later...
Guest
This topic is now closed to further replies.

Announcements




  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Managed to solve the issue myself. Solved by a fresh modpack instance.
    • Hello, so straight to the problem. Today i wanted to startup Enigmatica as usual and it just wont startup. Last night everything worked fine, i didnt even turn off my pc. Crash log: https://mclo.gs/GJ6Kcy1
    • Rubidium and Embeddium are versions of the same mod, you can only have one. I believe Embeddium is the one that's actively maintained.
    • Hello, New to modding, but have a solid CS foundation. I've created multiple custom BlockEntities that all have the same issue, which is that the inventory only updates on right click (overriding the useItemOn method). I've seen multiple posts on here outlining a similar issue to mine, but I've already implemented the solution of: overriding the correct methods in the BlockEntity class and calling setChanged(). I've tried every different place for setChanged() to no success. I'm wondering if I'm missing something else or if there was some change to sending data to the client in 1.21.5? Or will I have to use a custom packet sender? Here is the code for one of my BlockEntity classes with a single inventory slot: public class MyCustomBlockEntity extends BlockEntity { public final ItemStackHandler inventory = new ItemStackHandler(1) { @Override protected int getStackLimit(int slot, @NotNull ItemStack stack) { return 1; } @Override protected void onContentsChanged(int slot) { setChanged(); if (!level.isClientSide()) { level.setBlockAndUpdate(getBlockPos(), getBlockState()); } } }; public MyCustomBlockEntity(BlockPos pPos, BlockState pBlockState) { super(ModBlockEntities.MY_CUSTOM_BE.get(), pPos, pBlockState); } public void clearContents() { inventory.setStackInSlot(0, ItemStack.EMPTY); } public void dropItem() { SimpleContainer inv = new SimpleContainer(inventory.getSlots()); inv.setItem(0, inventory.getStackInSlot(0)); Containers.dropContents(this.level, this.worldPosition, inv); } @Override public void setRemoved() { dropItem(); super.setRemoved(); } @Override protected void saveAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) { super.saveAdditional(pTag, pRegistries); pTag.put("inventory", inventory.serializeNBT(pRegistries)); } @Override protected void loadAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) { super.loadAdditional(pTag, pRegistries); inventory.deserializeNBT(pRegistries, pTag.getCompound("inventory").get()); } @Override public Packet<ClientGamePacketListener> getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); } @Override public CompoundTag getUpdateTag(HolderLookup.Provider pRegistries) { return saveWithoutMetadata(pRegistries); } } Mostly encountering the issue when calling the clearContents() method anywhere outside of useItemOn() in the Block class. I've also tried overriding both the handleUpdateTag() and onDataPacket() methods, calling their super along with loadAdditional(), but neither changed the outcome. Thanks in advance for any replies.
    • Hi all! I’m working on a Jurassic Park-themed mod for Minecraft 1.20.1, aiming to include dinosaurs, fossils, DNA extraction, and cool machines. This is a free project, mainly passion-driven, and I’ll give full credit to everyone involved. this is the perfect opportunity for beginners of modeling and coding. This project will give you experience and a creative freedom If you love dinosaurs and Minecraft modding, hit me up! Thanks! Add Me ogfrost. <--- Discord
  • Topics

×
×
  • Create New...

Important Information

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