Skip to content

Commit 11ef147

Browse files
committed
water potion rework
1 parent cbc9468 commit 11ef147

13 files changed

Lines changed: 109 additions & 22 deletions

File tree

TODO.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,27 @@ Bugfixes
2525
[✔] Campfires no longer do excessive damage
2626
[✔] Creative players out of RTS cam are no longer locked into flying and no longer have noclip
2727
[✔] Fixed the blizzard sound effect still continuing sometimes after the spell ends
28-
29-
[❌] night rings are a bit bugged sometimes (see northern plaguelands on server)
30-
[❌] overlapping resources with a bridge makes it ungatherable
28+
[✔] Building a bridge overlapping resource blocks no longer makes those resources ungatherable
3129

3230
Quality of Life
3331
---------------
34-
[❌] checkpoints not showing up sometimes (only on server?)
3532

3633
Balance
3734
-------
3835
[✔] The Wretched Wraith healing on snow raised from 0.25hp/layer to 0.33hp/layer
3936
[✔] Wretched Wraith bonus armour during blizzard increased from 30% to 50%
4037
[✔] Wretched Wraith Frostblink mana cost reduced from 40 to 30, and cooldown reduced from (20,16,12) to (20,15,10)
38+
4139
[✔] Piglin Merchant TNT Throw range increased from 12 to 14
4240
[✔] Marauder HP reduced from 140 to 125
43-
[🟡] Marauder Cleaving Flail damage to secondary targets reduced from 7 to 5 and stun from 1.5s to 1s
44-
[🟡] Piglins lose their magma block immunity if they are actively on fire
45-
[🟡] Removed the piglin Fire Resistance upgrade
46-
[🟡] Wildfire's magma blocks duration reduced from 10-15s to 8-12s
41+
[✔] Marauder Cleaving Flail damage to secondary targets reduced from 7 to 5 and stun from 1.5s to 1s
42+
[✔] Piglins lose their magma block immunity if they are actively on fire
43+
[✔] Removed the piglin Fire Resistance upgrade
44+
[✔] Wildfire Molten Bomb no longer deals explosion damage (this was actually unintended)
45+
[✔] Scorching gaze no longer causes 2x magma and fire block damage, but fire tick damage is raised to 3x
46+
47+
[✔] Witch Water Potions are greatly improved, and now extinguish fires on all mobs and blocks within a 2 block radius
48+
[✔] Raised water potion cooldown from 5s to 8s
4749

4850
Languages
4951
---------

src/main/java/com/solegendary/reignofnether/ability/abilities/ThrowWaterPotion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
public class ThrowWaterPotion extends Ability {
2828

29-
public static final int CD_MAX_SECONDS = 5;
29+
public static final int CD_MAX_SECONDS = 8;
3030

3131
public final Potion potion = Potions.WATER;
3232

src/main/java/com/solegendary/reignofnether/blocks/WalkableMagmaBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public WalkableMagmaBlock(BlockBehaviour.Properties pProperties) {
3131
}
3232

3333
public void stepOn(Level pLevel, BlockPos pPos, BlockState pState, Entity pEntity) {
34-
boolean isPiglinFaction = pEntity instanceof Unit unit && unit.getFaction() == Faction.PIGLINS;
34+
boolean isPiglinFaction = pEntity instanceof Unit unit && unit.getFaction() == Faction.PIGLINS && !pEntity.isOnFire();
3535
boolean isDamageTick = pEntity.tickCount % DAMAGE_DELAY == 0;
3636

3737
if (!pEntity.isSteppingCarefully() &&

src/main/java/com/solegendary/reignofnether/building/BuildingClientEvents.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.solegendary.reignofnether.building.buildings.piglins.CentralPortal;
1111
import com.solegendary.reignofnether.building.buildings.piglins.PortalBasic;
1212
import com.solegendary.reignofnether.building.buildings.placements.BeaconPlacement;
13+
import com.solegendary.reignofnether.building.buildings.placements.BridgePlacement;
1314
import com.solegendary.reignofnether.building.buildings.placements.PortalPlacement;
1415
import com.solegendary.reignofnether.building.buildings.placements.ProductionPlacement;
1516
import com.solegendary.reignofnether.building.buildings.shared.AbstractBridge;
@@ -28,6 +29,9 @@
2829
import com.solegendary.reignofnether.orthoview.OrthoviewClientEvents;
2930
import com.solegendary.reignofnether.player.PlayerColors;
3031
import com.solegendary.reignofnether.research.ResearchClient;
32+
import com.solegendary.reignofnether.resources.BlockUtils;
33+
import com.solegendary.reignofnether.resources.ResourceName;
34+
import com.solegendary.reignofnether.resources.ResourceSources;
3135
import com.solegendary.reignofnether.sandbox.SandboxClientEvents;
3236
import com.solegendary.reignofnether.tutorial.TutorialClientEvents;
3337
import com.solegendary.reignofnether.unit.Relationship;
@@ -123,8 +127,12 @@ public static int getTotalPopulationSupply(String playerName) {
123127

124128
// can only be one preselected building as you can't box-select them like units
125129
public static BuildingPlacement getPreselectedBuilding() {
130+
BlockPos preSelBp = CursorClientEvents.getPreselectedBlockPos();
126131
for (BuildingPlacement building : buildings)
127-
if (building.isPosInsideBuilding(CursorClientEvents.getPreselectedBlockPos())) {
132+
if (building.isPosInsideBuilding(preSelBp)) {
133+
if (building instanceof BridgePlacement && ResourceSources.getBlockResourceName(preSelBp, MC.level) != ResourceName.NONE) {
134+
return null;
135+
}
128136
return building;
129137
}
130138
return null;

src/main/java/com/solegendary/reignofnether/building/BuildingUtils.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.solegendary.reignofnether.building.buildings.monsters.Stronghold;
77
import com.solegendary.reignofnether.building.buildings.piglins.Fortress;
88
import com.solegendary.reignofnether.building.buildings.placements.BeaconPlacement;
9+
import com.solegendary.reignofnether.building.buildings.placements.BridgePlacement;
910
import com.solegendary.reignofnether.building.buildings.placements.SculkCatalystPlacement;
1011
import com.solegendary.reignofnether.building.buildings.shared.AbstractBridge;
1112
import com.solegendary.reignofnether.building.buildings.villagers.Castle;
@@ -261,6 +262,19 @@ public static boolean isPosInsideAnyBuilding(boolean isClientSide, BlockPos bp)
261262
return false;
262263
}
263264

265+
public static boolean isPosInsideAnyNonBridgeBuilding(boolean isClientSide, BlockPos bp) {
266+
List<BuildingPlacement> buildings;
267+
if (isClientSide)
268+
buildings = BuildingClientEvents.getBuildings();
269+
else
270+
buildings = BuildingServerEvents.getBuildings();
271+
272+
for (BuildingPlacement building : buildings)
273+
if (!(building instanceof BridgePlacement) && building.isPosInsideBuilding(bp))
274+
return true;
275+
return false;
276+
}
277+
264278
@Nullable
265279
public static BuildingPlacement findClosestBuilding(boolean isClientSide, Vec3 pos, Predicate<BuildingPlacement> condition) {
266280
List<BuildingPlacement> buildings;

src/main/java/com/solegendary/reignofnether/entities/MoltenBombProjectile.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public boolean ignoreExplosion() {
6262
}
6363

6464
protected void detonate() {
65-
this.level().explode(this, this.getX(), this.getY(), this.getZ(), 2, false, Level.ExplosionInteraction.NONE);
65+
level().explode(null, null, null, this.getX(), this.getEyeY(), this.getZ(),
66+
2.0f, false, Level.ExplosionInteraction.NONE);
6667

6768
HashMap<BlockPos, Double> bpAndDists = new HashMap<>();
6869

@@ -101,7 +102,9 @@ protected void detonate() {
101102
}
102103
List<Mob> mobs = MiscUtil.getEntitiesWithinRange(position(), moltenBomb.radius, Mob.class, level());
103104
for (Mob mob : mobs) {
104-
mob.hurt(damageSources().explosion(this.getOwner(), this), moltenBomb.damage);
105+
if (mob.hurt(damageSources().explosion(this.getOwner(), this), moltenBomb.damage) && random.nextBoolean()) {
106+
mob.setSecondsOnFire(5);
107+
}
105108
if (this.getOwner() instanceof LivingEntity le && le.hasEffect(MobEffectRegistrar.SOULS_AFLAME.get())) {
106109
mob.addEffect(new MobEffectInstance(MobEffectRegistrar.SOULS_AFLAME.get(), 120, 0, false, false));
107110
}

src/main/java/com/solegendary/reignofnether/mixin/ThrownPotionMixin.java

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
import com.solegendary.reignofnether.entities.AdjustableAreaEffectCloud;
55
import com.solegendary.reignofnether.research.ResearchClient;
66
import com.solegendary.reignofnether.research.ResearchServerEvents;
7+
import com.solegendary.reignofnether.research.researchItems.ResearchWaterPotions;
78
import com.solegendary.reignofnether.unit.units.villagers.WitchUnit;
9+
import com.solegendary.reignofnether.util.MiscUtil;
10+
import net.minecraft.core.BlockPos;
11+
import net.minecraft.core.Direction;
812
import net.minecraft.nbt.CompoundTag;
913
import net.minecraft.world.effect.MobEffectInstance;
10-
import net.minecraft.world.entity.AreaEffectCloud;
14+
import net.minecraft.world.entity.Entity;
1115
import net.minecraft.world.entity.EntityType;
1216
import net.minecraft.world.entity.LivingEntity;
1317
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
@@ -16,13 +20,20 @@
1620
import net.minecraft.world.item.LingeringPotionItem;
1721
import net.minecraft.world.item.alchemy.Potion;
1822
import net.minecraft.world.item.alchemy.PotionUtils;
23+
import net.minecraft.world.item.alchemy.Potions;
1924
import net.minecraft.world.level.Level;
25+
import net.minecraft.world.phys.BlockHitResult;
26+
import net.minecraft.world.phys.EntityHitResult;
2027
import net.minecraft.world.phys.HitResult;
2128
import org.spongepowered.asm.mixin.Mixin;
29+
import org.spongepowered.asm.mixin.Shadow;
2230
import org.spongepowered.asm.mixin.injection.At;
2331
import org.spongepowered.asm.mixin.injection.Inject;
2432
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2533

34+
import java.util.Iterator;
35+
import java.util.List;
36+
2637
@Mixin(ThrownPotion.class)
2738
public abstract class ThrownPotionMixin extends ThrowableItemProjectile {
2839

@@ -77,6 +88,13 @@ private void makeAreaOfEffectCloud(ItemStack pStack, Potion pPotion, CallbackInf
7788
this.level().addFreshEntity(aec);
7889
}
7990

91+
private boolean isWaterPotion() {
92+
ItemStack item = this.getItem();
93+
Potion potion = PotionUtils.getPotion(item);
94+
List<MobEffectInstance> mei = PotionUtils.getMobEffects(item);
95+
return potion == Potions.WATER && mei.isEmpty();
96+
}
97+
8098
// lingering potions should not collide with entities so their AOE cloud is better placed
8199
@Inject(
82100
method = "onHit",
@@ -87,8 +105,45 @@ private void onHit(HitResult pResult, CallbackInfo ci) {
87105
ItemStack item = this.getItem();
88106
if (pResult.getType() == HitResult.Type.ENTITY &&
89107
item.getItem() instanceof LingeringPotionItem &&
90-
this.getOwner() instanceof WitchUnit witchUnit) {
108+
this.getOwner() instanceof WitchUnit) {
91109
ci.cancel();
110+
} else if (isWaterPotion() && pResult.getType() == HitResult.Type.ENTITY) {
111+
dowseNearbyFires(((EntityHitResult)pResult).getEntity().blockPosition());
112+
}
113+
}
114+
115+
@Shadow private void dowseFire(BlockPos pPos) { }
116+
@Shadow private void applyWater() { }
117+
118+
@Inject(
119+
method = "onHitBlock",
120+
at = @At("TAIL"),
121+
cancellable = true
122+
)
123+
protected void onHitBlock(BlockHitResult pResult, CallbackInfo ci) {
124+
if (!this.level().isClientSide) {
125+
boolean isWater = isWaterPotion();
126+
Direction dir = pResult.getDirection();
127+
BlockPos hitBp = pResult.getBlockPos();
128+
BlockPos adjBp = hitBp.relative(dir);
129+
if (isWater) {
130+
dowseNearbyFires(adjBp);
131+
}
132+
}
133+
}
134+
135+
private void dowseNearbyFires(BlockPos bp) {
136+
float radius = ResearchWaterPotions.DOWSE_RADIUS;
137+
for (LivingEntity entity : MiscUtil.getEntitiesWithinRange(bp.getCenter(), radius, LivingEntity.class, level())) {
138+
if (entity.isOnFire() && entity.isAlive()) {
139+
entity.extinguishFire();
140+
}
141+
if (entity.isSensitiveToWater()) {
142+
entity.hurt(this.damageSources().indirectMagic(this, this.getOwner()), 1.0F);
143+
}
144+
}
145+
for (BlockPos bp2 : BlockPos.withinManhattan(bp, (int) radius, (int) radius, (int) radius)) {
146+
dowseFire(bp2);
92147
}
93148
}
94149
}

src/main/java/com/solegendary/reignofnether/research/researchItems/ResearchWaterPotions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class ResearchWaterPotions extends ProductionItem {
2323
public final static String itemName = "Water Potions";
2424
public final static ResourceCost cost = ResourceCosts.RESEARCH_WATER_POTIONS;
2525

26+
public final static float DOWSE_RADIUS = 2f;
27+
2628
public ResearchWaterPotions() {
2729
super(cost, ProdDupeRule.DISALLOW);
2830
this.onComplete = (Level level, ProductionPlacement building) -> {

src/main/java/com/solegendary/reignofnether/resources/ResourcesClientEvents.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static void onClientTick(ScreenEvent.Render evt) {
6060

6161
BlockPos preSelBp = CursorClientEvents.getPreselectedBlockPos();
6262
ResourceSource res = ResourceSources.getFromBlockPos(preSelBp, MC.level);
63-
if (res != null && res.resourceValue > 0 && !BuildingUtils.isPosInsideAnyBuilding(true, preSelBp)) {
63+
if (res != null && res.resourceValue > 0 && !BuildingUtils.isPosInsideAnyNonBridgeBuilding(true, preSelBp)) {
6464
String str = switch (res.resourceName) {
6565
case FOOD -> "\uE000 " + res.resourceValue;
6666
case WOOD -> "\uE001 " + res.resourceValue;

src/main/java/com/solegendary/reignofnether/unit/UnitActionItem.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.solegendary.reignofnether.building.BuildingPlacement;
99
import com.solegendary.reignofnether.building.BuildingUtils;
1010
import com.solegendary.reignofnether.building.GarrisonableBuilding;
11+
import com.solegendary.reignofnether.building.buildings.placements.BridgePlacement;
1112
import com.solegendary.reignofnether.building.buildings.placements.FarmPlacement;
1213
import com.solegendary.reignofnether.building.buildings.placements.PortalPlacement;
1314
import com.solegendary.reignofnether.hud.HudClientEvents;
@@ -231,7 +232,7 @@ public void action(Level level) {
231232
);
232233

233234
if (unit instanceof WorkerUnit workerUnit && resName != ResourceName.NONE
234-
&& buildingAtPos == null) {
235+
&& (buildingAtPos == null || buildingAtPos instanceof BridgePlacement)) {
235236
GatherResourcesGoal goal = workerUnit.getGatherResourceGoal();
236237
goal.setTargetResourceName(resName);
237238
goal.setMoveTarget(preselectedBlockPos);

0 commit comments

Comments
 (0)