• Recently Browsing

    No registered users viewing this page.

  • Posts

    • Below are my capability classes for attaching to vanilla living entities (besides player). I'd like to change the entity's capability (to a value of 1.0F) when right clicking with a mod item. I thought this would be accomplished with: target.getCapability(ModCap.MOD_CAP).ifPresent(IModCap::set); But checking the values before and after with: System.out.println(target.getCapability(ModCap.MOD_CAP).orElse(new ModCapMethods()).get()); Still yields 0.0F (the default value). Since it returns the default, the capability should be registered, but I could be wrong.    ModCap Class ModCapStorage Class ModCapMethods Class IModCap Class ModItem Class
    • I'm trying to make it so that witches drop a custom item I made. I read that I needed to use global loot modifiers and I am currently looking at the documentation as well as other posts online about how to use them and I can't seem to fully understand what I need to put in my code.   This is my what I have in my global_loot_modifiers.json: { "replace": false, "entries": [ "global_loot_test:witch" ] }   my witch.json: { "type": "mwh:dust_drop", "conditions": [ { "condition": "minecraft:killed_by_player" }, { "condition": "minecraft:entity_properties", "predicate": { "type": "minecraft:witch" }, "entity": "this" } ], "item": "mwh:witch_dust" }   and my modifier class: class VanillaMobModifier extends LootModifier { private final int numSeedsToConvert; private final Item itemToCheck; private final Item itemReward; public VanillaMobModifier(ILootCondition[] conditionsIn, int numSeeds, Item itemCheck, Item reward) { super(conditionsIn); numSeedsToConvert = numSeeds; itemToCheck = itemCheck; itemReward = reward; } @Nonnull @Override public List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) { // // Additional conditions can be checked, though as much as possible should be parameterized via JSON data. // It is better to write a new ILootCondition implementation than to do things here. // int numSeeds = 0; for(ItemStack stack : generatedLoot) { if(stack.getItem() == itemToCheck) numSeeds+=stack.getCount(); } if(numSeeds >= numSeedsToConvert) { generatedLoot.removeIf(x -> x.getItem() == itemToCheck); generatedLoot.add(new ItemStack(itemReward, (numSeeds/numSeedsToConvert))); numSeeds = numSeeds%numSeedsToConvert; if(numSeeds > 0) generatedLoot.add(new ItemStack(itemToCheck, numSeeds)); } return generatedLoot; } @SuppressWarnings("unused") private static class Serializer extends GlobalLootModifierSerializer<VanillaMobModifier> { @Override public VanillaMobModifier read(ResourceLocation name, JsonObject object, ILootCondition[] conditionsIn) { int numSeeds = JSONUtils.getInt(object, "numSeeds"); Item seed = ForgeRegistries.ITEMS.getValue(new ResourceLocation((JSONUtils.getString(object, "seedItem")))); Item wheat = ForgeRegistries.ITEMS.getValue(new ResourceLocation(JSONUtils.getString(object, "replacement"))); return new VanillaMobModifier(conditionsIn, numSeeds, seed, wheat); } @Override public JsonObject write(VanillaMobModifier instance) { // TODO Auto-generated method stub return null; } } }   I don't know how to modify this part of the code to fit my needs. I only want just witches to have a chance at dropping my item when killed.     And I saw that I needed to do something like this:   @SubscribeEvent public static void registerModifierSerializers(@Nonnull final RegistryEvent.Register<GlobalLootModifierSerializer<?>> event) { if (ENABLE) { event.getRegistry().register(new VanillaMobDropsModifier.Serializer().setRegistryName(new ResourceLocation(MOD_ID,"dust_drop"))); } }   buts it's giving me errors. Pretty sure I'm missing something. I bet I'm probably missing important or obvious but if anyone can point me in the right direction I would very my appreciate it.
    • Because the company has decided that it likes people like you (because people like you generate page views and ad clicks) despite the fact that people like you never actually get your question answered because it's garbage content (duplicate, poorly explained, spam, whatever).   I'll let this meta-answer explain. https://meta.stackexchange.com/a/355674  
    • Look at: Bed Torch Door Pressure Plate A thousand other vanilla blocks
    • Use  updatePostPlacement and check if the bottom block is air, if so return air's default state (check bush block).
  • Topics

  • Who's Online (See full list)