Skip to content

Commit

Permalink
Added Storms Edge twinblade
Browse files Browse the repository at this point in the history
Added Storm status effect (AOE Lightning)
Adjusted Watcher status effect - now hits all entities in proximity, except player but siphons less health
Base wildfire chance reduced
  • Loading branch information
Sweenus committed Aug 16, 2022
1 parent 0c5759b commit 9ecb948
Show file tree
Hide file tree
Showing 16 changed files with 707 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/main/java/net/sweenus/simplyswords/SimplySwords.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public void onInitialize() {
ModEffects.registerEffects();
Registry.register(Registry.STATUS_EFFECT, new Identifier("simplyswords", "burn"), ModEffects.BURN);
Registry.register(Registry.STATUS_EFFECT, new Identifier("simplyswords", "wildfire"), ModEffects.WILDFIRE);
Registry.register(Registry.STATUS_EFFECT, new Identifier("simplyswords", "storm"), ModEffects.STORM);
Registry.register(Registry.STATUS_EFFECT, new Identifier("simplyswords", "electric"), ModEffects.ELECTRIC);
Registry.register(Registry.STATUS_EFFECT, new Identifier("simplyswords", "omen"), ModEffects.OMEN);
Registry.register(Registry.STATUS_EFFECT, new Identifier("simplyswords", "watcher"), ModEffects.WATCHER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public static void init() {
INT_OPTIONS.put("toxin_chance", 15);
INT_OPTIONS.put("freeze_chance", 15);
INT_OPTIONS.put("brimstone_chance", 15);
INT_OPTIONS.put("wildfire_chance", 20);
INT_OPTIONS.put("wildfire_chance", 10);
INT_OPTIONS.put("storm_chance", 15);
INT_OPTIONS.put("watcher_chance", 15);
INT_OPTIONS.put("omen_chance", 25);
INT_OPTIONS.put("lightning_chance", 10);
Expand All @@ -59,7 +60,7 @@ public static void init() {
FLOAT_OPTIONS.put("rare_loot_table_weight", 0.05f);
FLOAT_OPTIONS.put("unique_loot_table_weight", 0.005f);
FLOAT_OPTIONS.put("omen_absorption_amount", 1f);
FLOAT_OPTIONS.put("watcher_restore_amount", 1f);
FLOAT_OPTIONS.put("watcher_restore_amount", 0.5f);
}

public static void loadConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static void registerEffects() {
public static final StatusEffect BURN = new BurnEffect(StatusEffectCategory.HARMFUL, 2124687);
public static final StatusEffect ELECTRIC = new ElectricEffect(StatusEffectCategory.HARMFUL, 2184187);
public static final StatusEffect WILDFIRE = new WildfireEffect(StatusEffectCategory.HARMFUL, 1124687);
public static final StatusEffect STORM = new StormEffect(StatusEffectCategory.HARMFUL, 1124687);
public static final StatusEffect OMEN = new OmenEffect(StatusEffectCategory.HARMFUL, 1124687);
public static final StatusEffect WATCHER = new WatcherEffect(StatusEffectCategory.HARMFUL, 1124687);

Expand Down
49 changes: 49 additions & 0 deletions src/main/java/net/sweenus/simplyswords/effect/StormEffect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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.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.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()) {
ServerWorld world = (ServerWorld)pLivingEntity.world;
BlockPos position = pLivingEntity.getBlockPos();
double x = pLivingEntity.getX();
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);

//for(Entity e: world.getEntitiesByType(pLivingEntity.getType(), box, EntityPredicates.VALID_ENTITY))
for(Entity e: world.getOtherEntities(pPlayer, box, EntityPredicates.VALID_ENTITY))
{
if (e != null) {
var stormtarget = e.getBlockPos();
Entity storm = EntityType.LIGHTNING_BOLT.spawn(world, null, null, null, stormtarget, SpawnReason.TRIGGERED, true, true);
}
}

}

super.applyUpdateEffect(pLivingEntity, pAmplifier);

}

@Override
public boolean canApplyUpdateEffect(int pDuration, int pAmplifier) {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectCategory;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.sweenus.simplyswords.config.SimplySwordsConfig;
Expand All @@ -25,14 +28,16 @@ public void applyUpdateEffect(LivingEntity pLivingEntity, int pAmplifier) {
double z = pLivingEntity.getZ();
int pduration = 1;
float rAmount = SimplySwordsConfig.getFloatValue("watcher_restore_amount");
Box box = new Box(x + 20, y +10, z + 20, x - 20, y - 10, z - 20);
Box box = new Box(x + 10, y +10, z + 10, x - 10, y - 10, z - 10);
var pPlayer = pLivingEntity.getAttacker();

for(Entity e: world.getEntitiesByType(pLivingEntity.getType(), box, EntityPredicates.VALID_ENTITY))
//for(Entity e: world.getEntitiesByType(pLivingEntity.getType(), box, EntityPredicates.VALID_ENTITY))
for(Entity e: world.getOtherEntities(pPlayer, box, EntityPredicates.VALID_ENTITY))
{
if (e != null && pPlayer != null){
e.damage(DamageSource.FREEZE, rAmount);
pPlayer.setHealth(pPlayer.getHealth() + rAmount);
world.playSound(null, position, SoundEvents.BLOCK_ENDER_CHEST_OPEN, SoundCategory.BLOCKS, 1f, 1f);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/sweenus/simplyswords/item/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ public class ModItems {
new WatcherSwordItem(ToolMaterials.NETHERITE, 6, -2.7f,
new FabricItemSettings().group(ModItemGroup.SIMPLYSWORDS).rarity(Rarity.EPIC)));

public static final Item STORMS_EDGE = registerItem( "storms_edge",
new StormSwordItem(ToolMaterials.NETHERITE, 3, -1.7f,
new FabricItemSettings().group(ModItemGroup.SIMPLYSWORDS).rarity(Rarity.EPIC)));

public static final Item TOXIC_LONGSWORD = registerItem( "toxic_longsword",
new PoisonSwordItem(ToolMaterials.NETHERITE, 3, -2.4f,
new FabricItemSettings().group(ModItemGroup.SIMPLYSWORDS).rarity(Rarity.EPIC)));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.sweenus.simplyswords.item.custom;


import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
import net.minecraft.item.ToolMaterial;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.structure.OceanRuinStructure;
import net.sweenus.simplyswords.config.SimplySwordsConfig;
import net.sweenus.simplyswords.effect.ModEffects;

public class StormSwordItem extends SwordItem {
public StormSwordItem(ToolMaterial toolMaterial, int attackDamage, float attackSpeed, Settings settings) {
super(toolMaterial, attackDamage, attackSpeed, settings);
}

@Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {

int phitchance = SimplySwordsConfig.getIntValue("storm_chance");

if (attacker.getRandom().nextInt(100) <= phitchance) {
target.addStatusEffect(new StatusEffectInstance(ModEffects.STORM, 1, 1), attacker);
}

return super.postHit(stack, target, attacker);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attack
int thitchance = SimplySwordsConfig.getIntValue("omen_chance");

if (attacker.getRandom().nextInt(100) <= thitchance) {
target.addStatusEffect(new StatusEffectInstance(ModEffects.WATCHER, 1, 3), attacker);
target.addStatusEffect(new StatusEffectInstance(ModEffects.WATCHER, 1, 1), attacker);
}

if (attacker.getRandom().nextInt(100) <= phitchance) {
target.addStatusEffect(new StatusEffectInstance(ModEffects.OMEN, 1, 3), attacker);
target.addStatusEffect(new StatusEffectInstance(ModEffects.OMEN, 1, 1), attacker);
}

return super.postHit(stack, target, attacker);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/simplyswords/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"item.simplyswords.gold_twinblade": "Gold Twinblade",
"item.simplyswords.diamond_twinblade": "Diamond Twinblade",
"item.simplyswords.netherite_twinblade": "Netherite Twinblade",
"item.simplyswords.storms_edge": "Storm's Edge",


"itemGroup.simplyswords.simplyswords": "Simply Swords",
Expand Down
Loading

0 comments on commit 9ecb948

Please sign in to comment.