Skip to content

Commit

Permalink
Now supports 1.19.x
Browse files Browse the repository at this point in the history
Storm proc only when raining
Bramblethorn added (AoE poison/slow on hit)
  • Loading branch information
Sweenus committed Aug 18, 2022
1 parent d4002c2 commit 8034412
Show file tree
Hide file tree
Showing 25 changed files with 824 additions and 15 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19
yarn_mappings=1.19+build.4
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.4
loader_version=0.14.9

# Mod Properties
mod_version = 1.02-1.19
mod_version = 1.04-1.19
maven_group = net.sweenus
archives_base_name = simplyswords

# Dependencies
fabric_version=0.58.0+1.19
fabric_version=0.60.0+1.19.2
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 @@ -28,6 +28,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", "plague"), ModEffects.PLAGUE);
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public static void init() {
INT_OPTIONS.put("slowness_duration", 50);
INT_OPTIONS.put("wildfire_duration", 8);
INT_OPTIONS.put("toxin_duration", 150);
INT_OPTIONS.put("plague_duration", 300);
INT_OPTIONS.put("plague_chance", 15);


FLOAT_OPTIONS.put("standard_loot_table_weight", 0.1f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,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 PLAGUE = new PlagueEffect(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);
Expand Down
51 changes: 51 additions & 0 deletions src/main/java/net/sweenus/simplyswords/effect/PlagueEffect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package net.sweenus.simplyswords.effect;

import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
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.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.sweenus.simplyswords.config.SimplySwordsConfig;
import net.sweenus.simplyswords.item.custom.PlagueSwordItem;

public class PlagueEffect extends StatusEffect {
public PlagueEffect(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 attacker = pLivingEntity.getAttacker();
//int spreadchance = SimplySwordsConfig.getIntValue("plague_spread_chance");

if (pLivingEntity.getRandom().nextInt(100) <= 10) {
Box box = new Box(x + 10, y + 5, z + 10, x - 10, y - 5, z - 10);

for(Entity e: world.getOtherEntities(attacker, box, EntityPredicates.VALID_ENTITY)) {
if (e != null) {
//end me
}
}
}

}

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 @@ -30,8 +30,10 @@ public void applyUpdateEffect(LivingEntity pLivingEntity, int pAmplifier) {
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);
if (e.isTouchingWaterOrRain()) {
var stormtarget = e.getBlockPos();
Entity storm = EntityType.LIGHTNING_BOLT.spawn(world, null, null, null, stormtarget, SpawnReason.TRIGGERED, true, true);
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/main/java/net/sweenus/simplyswords/item/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class ModItems {

//RUNIC
public static final Item RUNIC_LONGSWORD = registerItem( "runic_longsword",
new ElectricSwordItem(ToolMaterials.NETHERITE, 3, -2.4f,
new PoisonSwordItem(ToolMaterials.NETHERITE, 3, -2.4f,
new FabricItemSettings().group(ModItemGroup.SIMPLYSWORDS).rarity(Rarity.EPIC)));

public static final Item RUNIC_TWINBLADE = registerItem( "runic_twinblade",
Expand Down Expand Up @@ -123,11 +123,15 @@ public class ModItems {
new FabricItemSettings().group(ModItemGroup.SIMPLYSWORDS).rarity(Rarity.EPIC)));

public static final Item SWORD_ON_A_STICK = registerItem( "sword_on_a_stick",
new SwordItem(ToolMaterials.WOOD, 5, -1.9f,
new SwordItem(ToolMaterials.WOOD, 5, -2.2f,
new FabricItemSettings().group(ModItemGroup.SIMPLYSWORDS).rarity(Rarity.EPIC)));

public static final Item BRAMBLETHORN = registerItem( "bramblethorn",
new BrambleSwordItem(ToolMaterials.WOOD, 6, -1.6f,
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 PlagueSwordItem(ToolMaterials.NETHERITE, 3, -2.4f,
new FabricItemSettings().group(ModItemGroup.SIMPLYSWORDS).rarity(Rarity.EPIC)));

private static Item registerItem(String name, Item item) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package net.sweenus.simplyswords.item.custom;


import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
import net.minecraft.item.ToolMaterial;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.Box;
import net.sweenus.simplyswords.config.SimplySwordsConfig;
import net.sweenus.simplyswords.effect.ModEffects;

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

@Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
int fhitchance = 50; //SimplySwordsConfig.getIntValue("brimstone_chance");


if (attacker.getRandom().nextInt(100) <= fhitchance) {
if (!target.world.isClient()) {
double x = target.getX();
double y = target.getY();
double z = target.getZ();
ServerWorld world = (ServerWorld) target.world;
Box box = new Box(x + 10, y + 5, z + 10, x - 10, y - 5, z - 10);

for(Entity e: world.getOtherEntities(attacker, box, EntityPredicates.VALID_LIVING_ENTITY)) {
if (e != null) {
target = (LivingEntity) e;
target.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 300, 1), attacker);
target.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 150, 1), attacker);
}
}
}
}

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

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.sweenus.simplyswords.item.custom;


import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
import net.minecraft.item.ToolMaterial;
import net.sweenus.simplyswords.config.SimplySwordsConfig;
import net.sweenus.simplyswords.effect.ModEffects;

public class PlagueSwordItem extends SwordItem {
public PlagueSwordItem(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("plague_chance");
int pduration = SimplySwordsConfig.getIntValue("plague_duration");

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

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

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static void modifyLootTables() {
.with(ItemEntry.builder(ModItems.WATCHER_CLAYMORE))
.with(ItemEntry.builder(ModItems.TOXIC_LONGSWORD))
.with(ItemEntry.builder(ModItems.SWORD_ON_A_STICK))
.with(ItemEntry.builder(ModItems.BRAMBLETHORN))
.with(ItemEntry.builder(ModItems.STORMS_EDGE))
.with(ItemEntry.builder(ModItems.BRIMSTONE_CLAYMORE));
tableBuilder.pool(upool);
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 @@ -29,6 +29,7 @@
"item.simplyswords.netherite_twinblade": "Netherite Twinblade",
"item.simplyswords.storms_edge": "Storm's Edge",
"item.simplyswords.sword_on_a_stick": "Sword on a Stick",
"item.simplyswords.bramblethorn": "Bramblethorn",


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

0 comments on commit 8034412

Please sign in to comment.