Jump to content

pervll

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by pervll

  1. But it doesn't seem to work in my project.
  2. I've made an event for my custom enchantment, and it need to change the player's speed. I tried to use PlayerEntity#addPotionEffect but it did bad with the player who has speed effect. How can I just modify the speed of the player?
  3. Ok. I've check the tutorial but It went wrong in my project public class ModDimensions extends ModDimension{ } It says there are no class ModDimension
  4. I want to make a simple custom dimension but I don't know how to do it. I tried to refer to the mod Twilight Forest, but the dimension is too complex for me to read. Can anybody give me a simple example or a tutorial for making custom Dimensions? Thanks.
  5. Ok. I got it. Thanks and I'm almost done.😀
  6. The event file: @SubscribeEvent public static void onWithVoidSpeedEnchantment(LivingEquipmentChangeEvent event, ItemStack itemStack, LivingDamageEvent event2) { LivingEntity player = event.getEntityLiving(); EquipmentSlotType slot = event.getSlot(); if (player instanceof PlayerEntity) { if (EnchantmentHelper.getMaxEnchantmentLevel(RegistryHandler.VOID_SPEED.get(), player) > 0) { player.addPotionEffect(new EffectInstance(Effects.SPEED, 1, 3)); } } } And I don't now how to do damage to player. The register file: public static final DeferredRegister<Enchantment> ENCHANTMENTS = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, Technology.MOD_ID); public static final RegistryObject<Enchantment> VOID_SPEED = ENCHANTMENTS.register("void_speed", VoidSpeedEnchantment::new); The enchantment file: public class VoidSpeedEnchantment extends Enchantment { public VoidSpeedEnchantment() { super(Rarity.VERY_RARE, EnchantmentType.ARMOR_FEET, new EquipmentSlotType[]{EquipmentSlotType.FEET}); } @Override public int getMaxLevel() { return 4; } @Override public int getMinEnchantability(int enchantmentLevel) { return enchantmentLevel * 20; } @Override public int getMaxEnchantability(int enchantmentLevel) { return this.getMinEnchantability(enchantmentLevel) + 15; } @Override public boolean isAllowedOnBooks() { return true; } @Override public boolean canVillagerTrade() { return false; } @Override public boolean isTreasureEnchantment() { return true; } }
  7. And how can I check the enchantment? I used EnchantmentHelper#getMaxEnchantmentLevel but failed
  8. I'm really new in forge modding, so how can I check if the entity is a player? if (player instanceof PlayerEntity){ } like this?
  9. I have added an enchantment to my mod and it has some problem when running the mod. The feature of the enchantment should be: When the feet slot have this enchantment, the player get a speed 3 effect The player will hurt 1/40 of the probability for every 20 blocks movement The register file: public static final DeferredRegister<Enchantment> ENCHANTMENTS = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, Technology.MOD_ID); private static final EquipmentSlotType[] LEGS = new EquipmentSlotType[]{EquipmentSlotType.FEET}; public static final RegistryObject<Enchantment> VOID_SPEED = ENCHANTMENTS.register("void_speed", () -> new VoidSpeedEnchantment(Enchantment.Rarity.VERY_RARE, EnchantmentType.ARMOR_FEET, LEGS)); The enchantment file: public class VoidSpeedEnchantment extends Enchantment { public VoidSpeedEnchantment(Rarity rarity, EnchantmentType type, EquipmentSlotType[] slots) { super(rarity, EnchantmentType.ARMOR_FEET, slots); } @Override public int getMaxLevel() { return 4; } @Override public int getMinEnchantability(int enchantmentLevel) { return enchantmentLevel * 20; } @Override public int getMaxEnchantability(int enchantmentLevel) { return this.getMinEnchantability(enchantmentLevel) + 15; } @Override public boolean isAllowedOnBooks() { return true; } @Override public boolean canVillagerTrade() { return false; } @Override public boolean isTreasureEnchantment() { return true; } } The event file: @Mod.EventBusSubscriber(modid = Technology.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class ModClientEvents { @SubscribeEvent public static void onFeetWithVoidSpeedEnchantment(PlayerEvent event){ PlayerEntity player = event.getPlayer(); World world = event.getPlayer().getEntityWorld(); double move = event.getPlayer().getDistance(player); if (EnchantmentHelper.getMaxEnchantmentLevel(RegistryHandler.VOID_SPEED.get(), player) > 0){ // Problem shows on this line when debugging player.addPotionEffect(new EffectInstance(Effects.SPEED, 5, 3)); if (move >= 20){ move = 0; Random random = new Random(); int d1 = random.nextInt(40); if (d1 == 1){ d1 = 0; player.addPotionEffect(new EffectInstance(Effects.INSTANT_DAMAGE)); player.sendStatusMessage(new StringTextComponent(TextFormatting.RED + "Hurt by the void"), true); } } } } }
  10. I want to make a RPG in my mod, but I don't know how to make that.
×
×
  • Create New...

Important Information

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