Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CWater++ #1289

Open
wants to merge 4 commits into
base: 1.20
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2024-02-18T23:17:23.6326183 Tags for minecraft:mob_effect mod id ars_nouveau
// 1.20.1 2024-04-28T11:08:37.1245583 Tags for minecraft:mob_effect mod id ars_nouveau
08d652bf70406a53ea8f4c794d20f054284765b9 data/ars_nouveau/tags/mob_effect/deny_dispel.json
35133e95f1c8fdd7a1c21afcc231fc0bffefb9a8 data/ars_nouveau/tags/mob_effect/to_sync.json
eeb33e305587ee0fddec8dfc8d9477b45bc45d7b data/ars_nouveau/tags/mob_effect/to_sync.json
0315b9264874191953c091e06cf2d340f81d6d67 data/ars_nouveau/tags/mob_effect/unstable_gifts.json
2 changes: 1 addition & 1 deletion src/generated/resources/assets/ars_nouveau/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"ars_nouveau.glyph_desc.glyph_bounce": "Gives players the Bounce effect, causing them to bounce upwards upon falling. Amplification of Bounce will preserve additional forward facing motion per bounce.",
"ars_nouveau.glyph_desc.glyph_break": "A spell you start with. Breaks blocks of an average hardness. Can be amplified to increase the harvest level. Sensitive will simulate breaking blocks with Shears instead of a pickaxe.",
"ars_nouveau.glyph_desc.glyph_cold_snap": "Causes wet, slowed, or freezing entities to take a burst of damage and erupt into falling ice. Falling ice will slow and damage nearby entities. Can also be used to erupt a block of ice instead. Falling blocks of ice can be manipulated with the Focus of Block Shaping. Entities afflicted with Freezing will be set to the maximum freeze level immediately.",
"ars_nouveau.glyph_desc.glyph_conjure_water": "Places water at a location or extinguishes entities on fire.",
"ars_nouveau.glyph_desc.glyph_conjure_water": "Places water at a location or extinguishes entities on fire. If augmented with extend time, it will keep entities wet for a longer period of time.",
"ars_nouveau.glyph_desc.glyph_craft": "Opens the crafting menu.",
"ars_nouveau.glyph_desc.glyph_crush": "Turns stone into gravel, and gravel into sand. Will also crush flowers into bonus dye. Need Sensitive to work on items. For full recipe support, see JEI. Will also harm entities and deals bonus damage to entities that are swimming.",
"ars_nouveau.glyph_desc.glyph_cut": "Simulates using shears on entities and blocks, or damages non-shearable entities for a small amount. Amplify will simulate using an Axe instead of Shears. For simulating breaking with shears, see Break and Sensitive. Costs nothing.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"values": []
"values": [
"ars_nouveau:soggy"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ protected void addTags(HolderLookup.Provider pProvider) {
);
//placeholder to not leave the tag empty
this.tag(PotionEffectTags.DISPEL_DENY).add(ModPotions.SUMMONING_SICKNESS_EFFECT.get());
this.tag(PotionEffectTags.TO_SYNC);
this.tag(PotionEffectTags.TO_SYNC).add(ModPotions.SOAKED_EFFECT.get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class LibPotions {
public static final String BLAST = "blasting";
public static final String FREEZING = "freezing";
public static final String DEFENCE = "shielding";
public static final String SOAKED = "soaked";

public static String potion(String base) {
return base + "_potion";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.hollingsworth.arsnouveau.common.mixin;

import com.hollingsworth.arsnouveau.setup.registry.ModPotions;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(Entity.class)
public class EntityMixin {

@ModifyReturnValue(method = "isInWaterOrRain", at = @At("RETURN"))
private boolean ars_nouveau$isInWaterOrRain(boolean original) {
if (((Entity) (Object) this) instanceof LivingEntity livingEntity && livingEntity.hasEffect(ModPotions.SOAKED_EFFECT.get())) {
return true;
}
return original;
}

@ModifyReturnValue(method = "setSecondsOnFire", at = @At("RETURN"))
private int ars_nouveau$setSecondsOnFire(int original) {
if (((Entity) (Object) this) instanceof LivingEntity livingEntity && livingEntity.hasEffect(ModPotions.SOAKED_EFFECT.get())) {
return 0;
}
return original;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public void applyEffectTick(LivingEntity living, int amplifier) {
}
}

@Override
public boolean isDurationEffectTick(int pDuration, int pAmplifier) {
return pDuration > 0;
}

public abstract ParticleOptions getParticle();

public int getChance() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.hollingsworth.arsnouveau.common.potions;

import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.entity.LivingEntity;

public class SoggyEffect extends ParticleMobEffect {

public SoggyEffect() {
super(MobEffectCategory.NEUTRAL, 0x0000FF);
}

@Override
public void applyEffectTick(LivingEntity living, int amplifier) {
super.applyEffectTick(living, amplifier);
if (living.isOnFire()) {
living.clearFire();
}
}

@Override
public ParticleOptions getParticle() {
return ParticleTypes.DRIPPING_WATER;
}

@Override
public int getChance() {
return 4;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
import com.hollingsworth.arsnouveau.common.items.curios.ShapersFocus;
import com.hollingsworth.arsnouveau.common.lib.GlyphLib;
import com.hollingsworth.arsnouveau.common.spell.augment.AugmentAOE;
import com.hollingsworth.arsnouveau.common.spell.augment.AugmentExtendTime;
import com.hollingsworth.arsnouveau.common.spell.augment.AugmentPierce;
import com.hollingsworth.arsnouveau.common.spell.augment.AugmentSensitive;
import com.hollingsworth.arsnouveau.setup.registry.ModPotions;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
Expand All @@ -19,12 +23,13 @@
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.ForgeConfigSpec;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.Set;

public class EffectConjureWater extends AbstractEffect {
public class EffectConjureWater extends AbstractEffect implements IPotionEffect {

public static EffectConjureWater INSTANCE = new EffectConjureWater();

Expand All @@ -38,6 +43,13 @@ public void onResolveEntity(EntityHitResult rayTraceResult, Level world, @NotNul
if (entity.isOnFire()) {
entity.clearFire();
}
if (entity instanceof LivingEntity livingEntity && spellStats.getDurationMultiplier() > 0) {
applyConfigPotion(livingEntity, ModPotions.SOAKED_EFFECT.get(), spellStats);
}
if (spellStats.isSensitive() && !world.dimensionType().ultraWarm()) {
placeWater(world, shooter, spellContext, resolver, entity.blockPosition(), Direction.UP);
}

}

@Override
Expand All @@ -47,23 +59,27 @@ public void onResolveBlock(BlockHitResult rayTraceResult, Level world, @NotNull
if (world.dimensionType().ultraWarm())
return;
for (BlockPos pos1 : posList) {
if (!BlockUtil.destroyRespectsClaim(getPlayer(shooter, (ServerLevel) world), world, pos1))
continue;
if(!world.isInWorldBounds(pos1))
continue;
BlockState hitState = world.getBlockState(pos1);
if (hitState.getBlock() instanceof LiquidBlockContainer liquidBlockContainer && liquidBlockContainer.canPlaceLiquid(world, pos1, world.getBlockState(pos1), Fluids.WATER)) {
liquidBlockContainer.placeLiquid(world, pos1, hitState, Fluids.WATER.getSource(true));
ShapersFocus.tryPropagateBlockSpell(new BlockHitResult(
new Vec3(pos1.getX(), pos1.getY(), pos1.getZ()), rayTraceResult.getDirection(), pos1, false
), world, shooter, spellContext, resolver);
} else if (world.getBlockState(pos1.relative(rayTraceResult.getDirection())).canBeReplaced(Fluids.WATER)) {
pos1 = pos1.relative(rayTraceResult.getDirection());
world.setBlockAndUpdate(pos1, Blocks.WATER.defaultBlockState());
ShapersFocus.tryPropagateBlockSpell(new BlockHitResult(
new Vec3(pos1.getX(), pos1.getY(), pos1.getZ()), rayTraceResult.getDirection(), pos1, false
), world, shooter, spellContext, resolver);
}
placeWater(world, shooter, spellContext, resolver, pos1, rayTraceResult.getDirection());
}
}

private void placeWater(Level world, @NotNull LivingEntity shooter, SpellContext spellContext, SpellResolver resolver, BlockPos pos1, Direction direction) {
if (!BlockUtil.destroyRespectsClaim(getPlayer(shooter, (ServerLevel) world), world, pos1))
return;
if (!world.isInWorldBounds(pos1))
return;
BlockState hitState = world.getBlockState(pos1);
if (hitState.getBlock() instanceof LiquidBlockContainer liquidBlockContainer && liquidBlockContainer.canPlaceLiquid(world, pos1, world.getBlockState(pos1), Fluids.WATER)) {
liquidBlockContainer.placeLiquid(world, pos1, hitState, Fluids.WATER.getSource(true));
ShapersFocus.tryPropagateBlockSpell(new BlockHitResult(
new Vec3(pos1.getX(), pos1.getY(), pos1.getZ()), direction, pos1, false
), world, shooter, spellContext, resolver);
} else if (world.getBlockState(pos1.relative(direction)).canBeReplaced(Fluids.WATER)) {
pos1 = pos1.relative(direction);
world.setBlockAndUpdate(pos1, Blocks.WATER.defaultBlockState());
ShapersFocus.tryPropagateBlockSpell(new BlockHitResult(
new Vec3(pos1.getX(), pos1.getY(), pos1.getZ()), direction, pos1, false
), world, shooter, spellContext, resolver);
}
}

Expand All @@ -75,12 +91,12 @@ public int getDefaultManaCost() {
@NotNull
@Override
public Set<AbstractAugment> getCompatibleAugments() {
return augmentSetOf(AugmentAOE.INSTANCE, AugmentPierce.INSTANCE);
return augmentSetOf(AugmentAOE.INSTANCE, AugmentPierce.INSTANCE, AugmentExtendTime.INSTANCE, AugmentSensitive.INSTANCE);
}

@Override
public String getBookDescription() {
return "Places water at a location or extinguishes entities on fire.";
return "Places water at a location or extinguishes entities on fire. If augmented with extend time, it will keep entities wet for a longer period of time.";
}

@Override
Expand All @@ -93,4 +109,22 @@ public SpellTier defaultTier() {
public Set<SpellSchool> getSchools() {
return setOf(SpellSchools.ELEMENTAL_WATER);
}


@Override
public int getBaseDuration() {
return POTION_TIME == null ? 30 : POTION_TIME.get();
}

@Override
public int getExtendTimeDuration() {
return EXTEND_TIME == null ? 10 : EXTEND_TIME.get();
}

@Override
public void buildConfig(ForgeConfigSpec.Builder builder) {
super.buildConfig(builder);
addPotionConfig(builder, 20);
addExtendTimeConfig(builder, 10);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.hollingsworth.arsnouveau.setup.registry.RecipeRegistry;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
Expand Down Expand Up @@ -54,7 +53,7 @@ public void onResolve(HitResult rayTraceResult, Level world, @NotNull LivingEnti

@Override
public void onResolveEntity(EntityHitResult rayTraceResult, Level level,@NotNull LivingEntity shooter, SpellStats spellStats, SpellContext spellContext, SpellResolver resolver) {
float damage = (float) ((rayTraceResult.getEntity().isSwimming() ? DAMAGE.get() * 3.0 : DAMAGE.get()) + AMP_VALUE.get() * spellStats.getAmpMultiplier());
float damage = (float) ((rayTraceResult.getEntity().isUnderWater() ? DAMAGE.get() * 3.0 : DAMAGE.get()) + AMP_VALUE.get() * spellStats.getAmpMultiplier());
attemptDamage(level, shooter, spellStats, spellContext, resolver, rayTraceResult.getEntity(), buildDamageSource(level, shooter), damage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void addAttributeModifiers(LivingEntity pLivingEntity, AttributeMap pAttr
}
});
public static final RegistryObject<MobEffect> IMMOLATE_EFFECT = EFFECTS.register(IMMOLATE, ImmolateEffect::new);
public static final RegistryObject<MobEffect> SOAKED_EFFECT = EFFECTS.register(SOAKED, SoggyEffect::new);
public static final RegistryObject<MobEffect> BOUNCE_EFFECT = EFFECTS.register(BOUNCE, BounceEffect::new);
public static final RegistryObject<MobEffect> MAGIC_FIND_EFFECT = EFFECTS.register(MAGIC_FIND, MagicFindEffect::new);

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/ars_nouveau.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"mixins": [
"CrossbowMixin",
"DamageSourceMixin",
"EntityMixin",
"LivingAccessor",
"MobAccessor",
"PotionRecipeMixin",
Expand Down