From 65d5c9926a328e8d192bf7440bbb5c25bf8eea0f Mon Sep 17 00:00:00 2001 From: Sweenus <48658188+Sweenus@users.noreply.github.com> Date: Fri, 19 Aug 2022 15:17:42 +1000 Subject: [PATCH] Loot Drop rates lowered Loot table now allows for enchanted items Storm status effect will now only spawn lightning if distance to player is more than 5 blocks. Storm radius increased by 5 blocks in all directions to compensate Rapier speed amplifier reduced to 1 from 3 The Watcher has had its attack speed reduced by .1 Brimstone Claymore has had its attack range increased --- .../config/SimplySwordsConfig.java | 6 +-- .../simplyswords/effect/StormEffect.java | 22 +++++--- .../sweenus/simplyswords/item/ModItems.java | 2 +- .../item/custom/SafeLightning.java | 53 +++++++++++++++++++ .../item/custom/SpeedSwordItem.java | 2 +- .../item/custom/StormSwordItem.java | 3 +- .../util/ModLootTableModifiers.java | 4 ++ .../assets/simplyswords/lang/en_us.json | 2 + .../weapon_attributes/brimstone_claymore.json | 1 + 9 files changed, 81 insertions(+), 14 deletions(-) create mode 100644 src/main/java/net/sweenus/simplyswords/item/custom/SafeLightning.java diff --git a/src/main/java/net/sweenus/simplyswords/config/SimplySwordsConfig.java b/src/main/java/net/sweenus/simplyswords/config/SimplySwordsConfig.java index 98a2e447..db276991 100644 --- a/src/main/java/net/sweenus/simplyswords/config/SimplySwordsConfig.java +++ b/src/main/java/net/sweenus/simplyswords/config/SimplySwordsConfig.java @@ -58,9 +58,9 @@ public static void init() { INT_OPTIONS.put("plague_chance", 15); - FLOAT_OPTIONS.put("standard_loot_table_weight", 0.1f); - FLOAT_OPTIONS.put("rare_loot_table_weight", 0.05f); - FLOAT_OPTIONS.put("unique_loot_table_weight", 0.005f); + FLOAT_OPTIONS.put("standard_loot_table_weight", 0.08f); + FLOAT_OPTIONS.put("rare_loot_table_weight", 0.008f); + FLOAT_OPTIONS.put("unique_loot_table_weight", 0.002f); FLOAT_OPTIONS.put("omen_absorption_amount", 1f); FLOAT_OPTIONS.put("watcher_restore_amount", 0.5f); } diff --git a/src/main/java/net/sweenus/simplyswords/effect/StormEffect.java b/src/main/java/net/sweenus/simplyswords/effect/StormEffect.java index 93a7c869..42f87e94 100644 --- a/src/main/java/net/sweenus/simplyswords/effect/StormEffect.java +++ b/src/main/java/net/sweenus/simplyswords/effect/StormEffect.java @@ -1,20 +1,19 @@ package net.sweenus.simplyswords.effect; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.SpawnReason; +import net.minecraft.client.render.entity.LightningEntityRenderer; +import net.minecraft.entity.*; +import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffectCategory; import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; +import net.minecraft.util.math.Vec3d; import net.sweenus.simplyswords.config.SimplySwordsConfig; public class StormEffect extends StatusEffect { public StormEffect(StatusEffectCategory statusEffectCategory, int color) {super (statusEffectCategory, color); } - @Override public void applyUpdateEffect(LivingEntity pLivingEntity, int pAmplifier) { if (!pLivingEntity.world.isClient()) { @@ -24,15 +23,20 @@ public void applyUpdateEffect(LivingEntity pLivingEntity, int pAmplifier) { double y = pLivingEntity.getY(); double z = pLivingEntity.getZ(); var pPlayer = pLivingEntity.getAttacker(); - Box box = new Box(x + 10, y +5, z + 10, x - 10, y - 5, z - 10); + Box box = new Box(x + 15, y +5, z + 15, x - 15, y - 5, z - 15); //for(Entity e: world.getEntitiesByType(pLivingEntity.getType(), box, EntityPredicates.VALID_ENTITY)) - for(Entity e: world.getOtherEntities(pPlayer, box, EntityPredicates.VALID_ENTITY)) + for(Entity e: world.getOtherEntities(pPlayer, box, EntityPredicates.VALID_LIVING_ENTITY)) { if (e != null) { if (e.isTouchingWaterOrRain()) { var stormtarget = e.getBlockPos(); - Entity storm = EntityType.LIGHTNING_BOLT.spawn(world, null, null, null, stormtarget, SpawnReason.TRIGGERED, true, true); + if (e.distanceTo(pPlayer) >= 5 ){ + Entity storm = EntityType.LIGHTNING_BOLT.spawn(world, null, null, null, stormtarget, SpawnReason.TRIGGERED, true, true); + } + //e.damage(DamageSource.LIGHTNING_BOLT, 5f); + + } } } @@ -43,6 +47,8 @@ public void applyUpdateEffect(LivingEntity pLivingEntity, int pAmplifier) { } + + @Override public boolean canApplyUpdateEffect(int pDuration, int pAmplifier) { return true; diff --git a/src/main/java/net/sweenus/simplyswords/item/ModItems.java b/src/main/java/net/sweenus/simplyswords/item/ModItems.java index d0f7df32..9a7f3367 100644 --- a/src/main/java/net/sweenus/simplyswords/item/ModItems.java +++ b/src/main/java/net/sweenus/simplyswords/item/ModItems.java @@ -115,7 +115,7 @@ public class ModItems { new FabricItemSettings().group(ModItemGroup.SIMPLYSWORDS).rarity(Rarity.EPIC))); public static final Item WATCHER_CLAYMORE = registerItem( "watcher_claymore", - new WatcherSwordItem(ToolMaterials.NETHERITE, 6, -2.7f, + new WatcherSwordItem(ToolMaterials.NETHERITE, 6, -2.8f, new FabricItemSettings().group(ModItemGroup.SIMPLYSWORDS).rarity(Rarity.EPIC))); public static final Item STORMS_EDGE = registerItem( "storms_edge", diff --git a/src/main/java/net/sweenus/simplyswords/item/custom/SafeLightning.java b/src/main/java/net/sweenus/simplyswords/item/custom/SafeLightning.java new file mode 100644 index 00000000..6f619b27 --- /dev/null +++ b/src/main/java/net/sweenus/simplyswords/item/custom/SafeLightning.java @@ -0,0 +1,53 @@ +package net.sweenus.simplyswords.item.custom; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LightningEntity; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.network.Packet; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.text.Text; +import net.minecraft.world.World; +import net.sweenus.simplyswords.item.ModItems; + +public class SafeLightning extends Entity { + + public SafeLightning(EntityType type, World world) { + super(type, world); + } + + @Override + protected void initDataTracker() { + + } + + @Override + protected void readCustomDataFromNbt(NbtCompound nbt) { + + } + + @Override + protected void writeCustomDataToNbt(NbtCompound nbt) { + + } + + @Override + public void onStruckByLightning(ServerWorld world, LightningEntity lightning) { + /*this.setFireTicks(this.fireTicks + 1); + if (this.fireTicks == 0) { + this.setOnFireFor(8); + }*/ + + var equips = getItemsEquipped(); + if (equips == ModItems.STORMS_EDGE) { + this.damage(DamageSource.LIGHTNING_BOLT, 0.0F); + this.sendMessage(Text.translatable("message.simplyswords.testlightning")); + } + } + + @Override + public Packet createSpawnPacket() { + return null; + } +} diff --git a/src/main/java/net/sweenus/simplyswords/item/custom/SpeedSwordItem.java b/src/main/java/net/sweenus/simplyswords/item/custom/SpeedSwordItem.java index 0f095a70..fce1a640 100644 --- a/src/main/java/net/sweenus/simplyswords/item/custom/SpeedSwordItem.java +++ b/src/main/java/net/sweenus/simplyswords/item/custom/SpeedSwordItem.java @@ -21,7 +21,7 @@ public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attack int sduration = SimplySwordsConfig.getIntValue("speed_duration"); if (attacker.getRandom().nextInt(100) <= shitchance) { - attacker.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, sduration, 3), attacker); + attacker.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, sduration, 1), attacker); } return super.postHit(stack, target, attacker); diff --git a/src/main/java/net/sweenus/simplyswords/item/custom/StormSwordItem.java b/src/main/java/net/sweenus/simplyswords/item/custom/StormSwordItem.java index a4be8ebe..ac39c1dd 100644 --- a/src/main/java/net/sweenus/simplyswords/item/custom/StormSwordItem.java +++ b/src/main/java/net/sweenus/simplyswords/item/custom/StormSwordItem.java @@ -2,6 +2,7 @@ import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; @@ -22,7 +23,7 @@ public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attack int phitchance = SimplySwordsConfig.getIntValue("storm_chance"); if (attacker.getRandom().nextInt(100) <= phitchance) { - target.addStatusEffect(new StatusEffectInstance(ModEffects.STORM, 1, 1), attacker); + target.addStatusEffect(new StatusEffectInstance(ModEffects.STORM, 2, 1), attacker); } return super.postHit(stack, target, attacker); diff --git a/src/main/java/net/sweenus/simplyswords/util/ModLootTableModifiers.java b/src/main/java/net/sweenus/simplyswords/util/ModLootTableModifiers.java index 3e0d08c4..0675a932 100644 --- a/src/main/java/net/sweenus/simplyswords/util/ModLootTableModifiers.java +++ b/src/main/java/net/sweenus/simplyswords/util/ModLootTableModifiers.java @@ -2,6 +2,9 @@ import net.fabricmc.fabric.api.loot.v2.LootTableEvents; import net.minecraft.loot.LootPool; +import net.minecraft.loot.function.EnchantRandomlyLootFunction; +import net.minecraft.loot.function.EnchantWithLevelsLootFunction; +import net.minecraft.loot.function.LootFunction; import net.sweenus.simplyswords.config.SimplySwordsConfig; import net.sweenus.simplyswords.item.ModItems; import net.minecraft.loot.condition.RandomChanceLootCondition; @@ -47,6 +50,7 @@ public static void modifyLootTables() { LootPool.Builder pool = LootPool.builder() .rolls(ConstantLootNumberProvider.create(1)) .conditionally(RandomChanceLootCondition.builder(SimplySwordsConfig.getFloatValue("standard_loot_table_weight"))) // 1 = 100% of the time + .apply(EnchantRandomlyLootFunction.builder()) .with(ItemEntry.builder(ModItems.IRON_LONGSWORD)) .with(ItemEntry.builder(ModItems.IRON_TWINBLADE)) .with(ItemEntry.builder(ModItems.IRON_RAPIER)) diff --git a/src/main/resources/assets/simplyswords/lang/en_us.json b/src/main/resources/assets/simplyswords/lang/en_us.json index fd970ee3..8ba0012f 100644 --- a/src/main/resources/assets/simplyswords/lang/en_us.json +++ b/src/main/resources/assets/simplyswords/lang/en_us.json @@ -34,6 +34,8 @@ "itemGroup.simplyswords.simplyswords": "Simply Swords", + "message.simplyswords.testlightning": "We have not been damaged", + "effect.simplyswords.freeze": "Freeze", "effect.simplyswords.burn": "Brimstone", diff --git a/src/main/resources/data/simplyswords/weapon_attributes/brimstone_claymore.json b/src/main/resources/data/simplyswords/weapon_attributes/brimstone_claymore.json index cf7ce5a8..48cdf87f 100644 --- a/src/main/resources/data/simplyswords/weapon_attributes/brimstone_claymore.json +++ b/src/main/resources/data/simplyswords/weapon_attributes/brimstone_claymore.json @@ -2,6 +2,7 @@ "parent": "bettercombat:heavy_axe", "attributes" : { "pose": "bettercombat:pose_two_handed_sword", + "attack_range": 3.5, "category": "claymore", "two_handed": true, "attacks": [