Jump to content

Jiro7

Members
  • Posts

    31
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Jiro7's Achievements

Tree Puncher

Tree Puncher (2/8)

2

Reputation

  1. Not sure if this is what you meant by reflection, as I've never done that yet (I know basic Java, but not that much), but this is what I did and got a crash. In my main.java: @EventHandler public static void init(FMLInitializationEvent event){ Collection<VillagerProfession> profs = ForgeRegistries.VILLAGER_PROFESSIONS.getValuesCollection(); for (VillagerProfession pr : profs){ if(pr.getSkin().toString().equals("minecraft:textures/entity/villager/librarian.png")){ pr.getCareer(0).getTrades(0).remove(1); pr.getCareer(0).getTrades(3).remove(0); pr.getCareer(0).getTrades(4).remove(0); pr.getCareer(0).getTrades(0).add(1, new ListEnchantedBookNew()); pr.getCareer(0).getTrades(3).add(0, new ListEnchantedBookNew()); pr.getCareer(0).getTrades(4).add(0, new ListEnchantedBookNew()); } } } The new class: public class ListEnchantedBookNew implements EntityVillager.ITradeList { @Override public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random) { Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(random); while (!(enchantment instanceof EnchantmentSlimy || enchantment instanceof EnchantmentShieldBoost || enchantment instanceof EnchantmentAbsorb)){ enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(random); } int i = MathHelper.getInt(random, enchantment.getMinLevel(), enchantment.getMaxLevel()); ItemStack itemstack = ItemEnchantedBook.getEnchantedItemStack(new EnchantmentData(enchantment, i)); int j = 2 + random.nextInt(5 + i * 10) + 3 * i; if (enchantment.isTreasureEnchantment()) { j *= 2; } if (j > 64) { j = 64; } recipeList.add(new MerchantRecipe(new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, j), itemstack)); } } And the crash:
  2. Is there really no easy way to do this without having to do the PR, though? Like, creating a custom villager class that extends from the original one but overrides the trade for books method, and then replace villagers with the new ones. The only problem I see is that ListEnchantedBookForEmeralds is a static class and not a method, but I feel like there must be a way. I literally just want to replace Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(random); by Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(random); while (enchantment instanceof EnchantmentMyEnchant){ enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(random); } in ListEnchantedBookForEmeralds
  3. How can I see the source code, though? I went ahead and try to add a PR, but the code in MinecraftForge/patches/minecraft/net/minecraft/enchantment/EntityVillager.java.patch is way different than the one I see at my own eclipse when I go to net.minecraft.enchantment.EntityVillager.java so I don't know exactly where to edit ListEnchantedBookForEmeralds
  4. Thank you for the answer. I will try to do the PR, it seems much easier.
  5. My mod adds new enchantments, and I gave them special ways to be obtained (drop from certain mob). I want to disable ANY other way to obtain the enchanted book. Making them "treasure" enchantments fixed the enchanting table part, but even treasure enchantments can still be found in some chest loot and in villager trades. I can edit the loot tables for the chest part, but how do I disable those specific trades? Even if I disabled village generation, players could still just cure a zombie villager and breed them, and I don't want to remove villagers. I just want to remove some specific trades.
  6. Title. I have an enchantment that gives player 30 seconds of resistance for the cost of 30 durability, which is activated when sneaking + right click the item. The ability works fine, except that the effect never ends and stays at 0 seconds permanently. The only way to fix it is closing the world and entering again. Additional note: the sound effect also doesn't seem to work @SubscribeEvent public static void sneakBoost(InputUpdateEvent event){ if (event.getMovementInput().sneak){ EntityPlayer player = event.getEntityPlayer(); if (player.getActiveItemStack().getItem().isShield(player.getActiveItemStack(), player)){ if (!player.isPotionActive(MobEffects.RESISTANCE)){ player.getHeldItemOffhand().damageItem(30, player); player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 600, 0)); player.world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_SHULKER_BOX_CLOSE, SoundCategory.NEUTRAL, 2.0F, 1.0F); } } } }
  7. Nvm, found it, this is the solution for anyone else wondering: public static void sneakBoost(InputUpdateEvent event){ if (event.getMovementInput().sneak){ // rest of the code
  8. I want to add a new enchantment that activates an ability when sneaking (player pressing shift). I tried looking all types of PlayerEvent and there doesn't seem to be anyone related to sneaking. Any help?
  9. I'm making a mod that adds enchantments to shield and I want to make one that increases the distance that deflected arrows travel. My plan is to use my custom shield class (that extends from ItemShield) to override the function that implements the arrow deflecting functionality, however I can't find it. All I could find related to "blocking" is this code: this.addPropertyOverride(new ResourceLocation("blocking"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F; } }); BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, ItemArmor.DISPENSER_BEHAVIOR); However I don't know how to deal with this. Any ideas?
  10. How would you do this in 1.12.2? GameRegistry.addSubstitutionAlias method doesn't exist anymore
  11. I found out that I need to use GameRegistry.addSubstitutionAlias, but Eclipse doesn't seem to recognize that method, is it outdated??? Is there a new way to do this? Please help All this just to change a 0 by a 1. And no, I don't want to make a new shield item, I want this to work for the vanilla one, so people can get the mod in started worlds and get their enchantments in their already crafted shields.
  12. Looking at the code it seems like the issue is that Item class has a method called getItemEnchantability which returns 0, except for classes that override it like bow, tools, armor... but not ItemShield. So my question is, how can I modify the ItemShield class to make shields enchantable? I already have the enchantments added and working with /enchant command. I just need them to be available at enchanting table, which should hopefully be fixed by overriding getItemEnchantability for ItemShield to return 1.
  13. Managed to fix this by simply putting public static final EnumEnchantmentType SHIELDS = EnumHelper.addEnchantmentType("shields", (item)->(item instanceof ItemShield)); before public static final Enchantment HEAVYWEIGHT = new EnchantmentHeavyweight(); public static final Enchantment BERSERK = new EnchantmentBerserk(); public static final Enchantment GUARD = new EnchantmentGuard(); public static final Enchantment DEFLECTION = new EnchantmentDeflection(); public static final Enchantment ABSORB = new EnchantmentAbsorb(); public static final Enchantment SHIELD_BOOST = new EnchantmentShieldBoost(); public static final Enchantment SLIMY = new EnchantmentSlimy(); public static final Enchantment TEST = new EnchantmentTest(); Hope it helps others in the same situation!
×
×
  • Create New...

Important Information

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