Jump to content

Razor

Members
  • Posts

    27
  • Joined

  • Last visited

Posts posted by Razor

  1. Hey guys,

    I try to make a mod thats overrides recipes from other mods. My problem is how to change the loading order that my recipes are loaded last.

     

    I tried to change 'ordering' to "AFTER" or "BEFORE" in the dependencies of the mods.toml file but it doesn't seem to work..  Can anyone help me?

     

    [[dependencies.allthecompatibility]]
        modId="assemblylinemachines"
        mandatory=false
        versionRange="[1.18-1.3.5,)"
        ordering="BEFORE"
        side="BOTH"

     

  2. Hey guys, i try to make recipes based of config options, but i can`t find the problem here, all recipes linked to an config options are always disabled and theres no error in the console, maybe a problem in the factories?

     

    ConditionsFactory

    public class ConditionFactory implements IConditionBuilder {
    
            //@Override
            public BooleanSupplier parse(JsonSerializationContext context, JsonObject json) {
                boolean value = JSONUtils.getBoolean(json , "value", true);
                String key = JSONUtils.getString(json, "type");
    
                if (key.equals(Uncrafted.MODID + ":spawneggs_enabled")) {
                    return () -> Config.ACTIVATE_SPAWNEGG_RECIPES.get().booleanValue() == value;
                }
                else if (key.equals(Uncrafted.MODID + ":spawner_enabled")) {
                    return () -> Config.ACTIVATE_SPAWNER_RECIPES.get().booleanValue() == value;
                }
                else if (key.equals(Uncrafted.MODID + ":skulls_enabled")) {
                    return () -> Config.ACTIVATE_SKULL_RECIPES.get().booleanValue() == value;
                }
                return null;
            }
    }

     

    _factories.json

    {
        "conditions": {
          "spawneggs_enabled": "xxrexraptorxx.util.ConditionFactory",
          "spawner_enabled": "xxrexraptorxx.util.ConditionFactory",
          "skulls_enabled": "xxrexraptorxx.util.ConditionFactory"
        }
    }
    

     

    example recipe: spawner.json

    {
      "conditions" : [
        {
          "type" : "uncrafted:spawner_enabled",
          "value" : true
        } ],
      "type": "minecraft:crafting_shaped",
      "pattern": [
      
        "XXX",
        "X#X",
        "XXX"
      ],
      
      "key": {
        "X": {
          "item": "minecraft:iron_bars"
        },
        "#": {
          "item": "minecraft:nether_star"
        }  
      },
      
      
      "result": {
        "item": "minecraft:spawner"
      }
    }

     

    i hope anyone can help me :D

     

     

  3. Okay, i found a easier way to deactivate recipes!   

     

    Here is my code:

    Spoiler

    @EventBusSubscriber
    public class RecipeHandler {

        
        @SubscribeEvent
        public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
            ResourceLocation recipe = new ResourceLocation("testmod:recipe");
            IForgeRegistryModifiable modRegistry = (IForgeRegistryModifiable) event.getRegistry();
            modRegistry.remove(recipe);
        }
    }

     

  4. On 26.7.2017 at 10:40 AM, diesieben07 said:

    Implement IConditionFactory and implement your condition there. A condition is really just something that returns a boolean, so you'd return whether or not your recipe should be active.

    Then create a file assets/<modid>/recipes/_factories.json. It's structure is like so:

    
    {
        "conditions": {
            "<name>": "<fully qualified classname for IConditionFactory>
        }
    }

     

    You can specify recipe and ingredient factories, too.

     

    Now in your recipe json you can specify conditions like so:

    
    {
        "conditions": [
            {
                "type": "<modid>:<name>"
            }
        ]
    }

    The JSON object in the conditions array will be passed to your IConditionFactory, so you can specify additional data here.

     

    Note that this is only updated once at startup, conditions are not dynamically checked.

     

     

     

    Okay i tried is, but now is the recipe deactivated regardless of whether the config option is true or false, whats wrong?

     

    heres my condition class:

    Spoiler

    public class Condition implements IConditionFactory {

        @Override
        public BooleanSupplier parse(JsonContext context, JsonObject json) {
            return () -> Testmod.activateBowCrafting;
        }

    }

     

     

    the _factories.json:

    Spoiler

    {
        "conditions": {
            "bow_recipes": "testmod.util.Condition"
        }
    }

     

    and a recipe json file:

    Spoiler

    {
      "conditions": [
        {
          "type": "testmod:bow_recipes"
        }
       ],
       
       
      "type": "minecraft:crafting_shaped",
      "pattern": [
     
        " #I",
        "# I",
        " #I"
        
      ],
      "key": {
        "#": {
          "item": "minecraft:diamond"
        },
        "I": {
          "item": "minecraft:string"
        }
      },
     
     
      "result": {
        "item": "testmod:diamond_bow"
      }
    }

     

  5. 7 minutes ago, diesieben07 said:

    I don't know why. You wrote the code and you have not posted it.

     

    public class BlockBox extends Block {
        List<Item> myItems = ForgeRegistries.ITEMS.getValues().stream().filter(it -> it.getRegistryName().getResourceDomain().equals("ageofweapons")).collect(Collectors.toList());

     

        public BlockWeaponBox() {
            super(Material.WOOD);
            this.setCreativeTab(ModTabs.generalTab);
            this.setHardness(0.5F);
            this.setResistance(1.0F);
            this.setSoundType(SoundType.WOOD);       

        }

        
       
        
        @Override
        public Item getItemDropped(IBlockState state, Random rand, int fortune) {
             int index = rand.nextInt(myItems.size());
                Item item = myItems.get(index);
                return item;
            
        }
        
        
       

  6. 1 hour ago, diesieben07 said:

    Ahem.

     

    Yes, i tried this:

     

         int index = rand.nextInt(myItems.size());
                Item item = myItems.get(index);
                return item;

     

    but the console says:

     

    java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: bound must be positive

  7. 1 hour ago, diesieben07 said:

    If you're lazy you can use this to obtain all Items added by your mod. But don't do this every time, do it once and store it in a field

     

    
    List<Item> myItems = ForgeRegistries.ITEMS.getValues().stream()
      .filter(it -> it.getRegistryName().getResourceDomain().equals("yourmod"))
      .collect(Collectors.toList());

    Yes, thats what i mean :D         And how can i get a single item for the drop out of this list ?   Sorry i´m new     ^^  

  8. 11 hours ago, fcelon said:

    You can create a public list in your item registry and add all of your items (at least those you want to be dropped from that item) ot that list while registering them. You can then select a random item from that list. I think it's propably the fastest way.

    but how i make this without write all the items in

  9. Heyyy, i try to make a block that drops the most of all the items in my mod (~100), but whats the easiest way to do this?

     

    Thats my current way, but to much work for all my items..  Anyone an idea?:

     

        @Override
        public Item getItemDropped(IBlockState state, Random rand, int fortune) {
            switch(rand.nextInt(6)){
            case 1:
                return Item1;
            case 2:
                return Item2;
            case 3:
                return Item3;
            case 4:
                return Item4;
            case 5:
                return Item5;
            default:
                return Item6;
            }
        }

  10. 1 hour ago, Bak3dC said:

    It seems that you are using an outdated way of registering items and their models. Try using registry events like this: 

    
    @Mod.EventBusSubscriber(modid = %modid%)
    public class RegistryEventHandler {
    	//This Registers the items to the games registry
    	@SubscribeEvent
    	public static void registerItems(RegistryEvent.Register<Item> event) {
              event.getRegistry().registerAll(ModItems.ITEMS);
              
              for(Block block : ModBlocks.BLOCKS) {
    			event.getRegistry().register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
    		}
              
        }
       
      //This is the model registerer
       @SideOnly(Side.CLIENT)
       @SubscribeEvent
       public staic void registerModels(MOdelRegistryEvent event) {
       
         for(Item item: ModItems.ITEMS) {
         
         	ModelLoader.setCustomModelResourceLocation(item, 0 , new ModelResourceLocation(item.getRegistryName(), "inventory"));
           
         }
       
       }
    }

     Similar to MrBendScrolls, we use RegistryEvents, you do not need to put this into the main java file. Make sure that no file in the assets file is capitolized, forge now enforces that rule.

    what do you mean with "capitolized"

×
×
  • Create New...

Important Information

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