Skip to content

Commit

Permalink
DD biomes with rain particles act as being under permanent rain
Browse files Browse the repository at this point in the history
  • Loading branch information
Azzyypaaras committed Nov 29, 2024
1 parent b29878c commit ca8bd95
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ public void beforeDestroyedByExplosion(World world, BlockPos pos, BlockState sta

@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
var velocity = entity.getVelocity().length();
if (velocity > 0.235 && world.random.nextInt(20) <= velocity * 20 || entity.isOnFire()) {
explode(world, pos, state);
if (!world.isClient()) {
var velocity = entity.getVelocity().length();
if (velocity > 0.235 && world.random.nextInt(20) <= velocity * 20 || entity.isOnFire()) {
explode(world, pos, state);
}
}
}

Expand Down
29 changes: 29 additions & 0 deletions src/main/java/de/dafuqs/spectrum/mixin/FireBlockMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package de.dafuqs.spectrum.mixin;

import com.llamalad7.mixinextras.injector.*;
import com.llamalad7.mixinextras.sugar.*;
import de.dafuqs.spectrum.registries.*;
import net.minecraft.block.*;
import net.minecraft.server.world.*;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;

@Mixin(FireBlock.class)
public class FireBlockMixin {

@ModifyExpressionValue(method = "scheduledTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;isRaining()Z", ordinal = 0))
public boolean spectrum$extinguishInPermanentRain(boolean original, @Local ServerWorld world) {
if (world.getRegistryKey().equals(SpectrumDimensions.DIMENSION_KEY)) {
return true;
}
return original;
}

@ModifyExpressionValue(method = "scheduledTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;isRaining()Z", ordinal = 1))
public boolean spectrum$assuageInPermanentRain(boolean original, @Local ServerWorld world) {
if (world.getRegistryKey().equals(SpectrumDimensions.DIMENSION_KEY)) {
return true;
}
return original;
}
}
11 changes: 11 additions & 0 deletions src/main/java/de/dafuqs/spectrum/mixin/WorldMixin.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package de.dafuqs.spectrum.mixin;

import de.dafuqs.spectrum.progression.*;
import de.dafuqs.spectrum.registries.*;
import net.minecraft.block.*;
import net.minecraft.entity.*;
import net.minecraft.server.network.*;
import net.minecraft.util.math.*;
import net.minecraft.world.*;
import net.minecraft.world.biome.source.*;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.*;

@Mixin(World.class)
public abstract class WorldMixin {

@Shadow
@Final
private BiomeAccess biomeAccess;

// using a mixin additional to net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents,
// since the fabric api event does not trigger for indirect breaks, like via projectile
@Inject(method = "breakBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getFluidState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/fluid/FluidState;"), locals = LocalCapture.CAPTURE_FAILHARD)
Expand All @@ -22,4 +28,9 @@ public void breakBlock(BlockPos pos, boolean drop, Entity breakingEntity, int ma
}
}

@Inject(method = "hasRain", at = @At("HEAD"), cancellable = true)
public void forcePermanentRain(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
if (biomeAccess.getBiome(pos).isIn(SpectrumBiomeTags.HAS_PERMANENT_RAIN))
cir.setReturnValue(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class SpectrumBiomeTags {

public static final TagKey<Biome> DD_BIOMES = getReference("in_deeper_down");
public static final TagKey<Biome> HAS_PERMANENT_RAIN = getReference("has_permanent_rain");

public static final TagKey<Biome> COLORED_TREES_GENERATING_IN = getReference("colored_trees_generating_in");
public static final TagKey<Biome> MERMAIDS_BRUSHES_GENERATING_IN = getReference("mermaids_brushes_generating_in");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"spectrum:deep_dripstone_caves",
"spectrum:dragonrot_swamp"
]
}
1 change: 1 addition & 0 deletions src/main/resources/spectrum.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"ExplosionMixin",
"FallingBlockEntityMixin",
"FarmlandBlockMixin",
"FireBlockMixin",
"FirstStrikeEnchantmentMixin",
"FishingHookPredicateMixin",
"FoxEntityMixin",
Expand Down

0 comments on commit ca8bd95

Please sign in to comment.