Skip to content

Commit

Permalink
fix sweared plants drop on place nearby sweared plants
Browse files Browse the repository at this point in the history
- it's more a dirty fix, but it actually works
- could be improved in the future
  • Loading branch information
Pilzinsel64 committed Jan 4, 2025
1 parent 346d5cb commit 66dcd83
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public List<String> getMixins(Set<String> loadedMods) {
if (loadedMods.contains("plantmegapack")) {
list.add("PMPGenVineMixin");
list.add("PMPWorldGeneratorMixin");
list.add("PMPGenAquaticMixin");
list.add("PMPBlockPlantMixin");
}

return list;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package de.pilz.plantmegapackfix.mixins.late;

import net.minecraft.block.Block;
import net.minecraft.world.World;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;

import plantmegapack.block.PMPBlockPlant;
import plantmegapack.common.PMPPlantGrowthType;

@Mixin(PMPBlockPlant.class)
public abstract class PMPBlockPlantMixin {

@ModifyExpressionValue(
method = "onNeighborBlockChange",
at = @At(
value = "INVOKE",
target = "Lplantmegapack/block/PMPBlockPlant;canBlockStay(Lnet/minecraft/world/World;III)Z"),
remap = false)
private boolean pmpfix$onNeighborBlockChange$ignoreSweared(boolean original, World world, int x, int y, int z,
@Local Block block) {
return original || (block instanceof PMPBlockPlant
&& ((PMPBlockPlant) block).plantData.attributes.growthType == PMPPlantGrowthType.SEAWEED);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package de.pilz.plantmegapackfix.mixins.late;

import net.minecraft.block.Block;
import net.minecraft.world.World;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;

import plantmegapack.block.PMPBlockPlant;
import plantmegapack.worldgen.PMPGenAquatic;

@Mixin(PMPGenAquatic.class)
public abstract class PMPGenAquaticMixin {

@WrapWithCondition(
method = "spawnRandomSeaweedCluster",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlock(IIILnet/minecraft/block/Block;II)Z"),
remap = false)
private static boolean pmpfix$spawnRandomSeaweedCluster$checkForWaterAbove(World world, int x, int y, int z,
Block blockIn, int metadataIn, int flags) {
PMPBlockPlant plant = (PMPBlockPlant) blockIn;
if (!plant.canPlaceBlockAt(world, x, y, z)) return false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void generateSurface(World world, Random random, int chunkX, int chunkZ)
private void generateEnd(World world, Random random, int chunkX, int chunkZ) {}

@Inject(method = "generate", at = @At("RETURN"), cancellable = false, remap = false)
private void pmpfix$$checkWorldProviderSuface(Random random, int chunkX, int chunkZ, World world,
private void pmpfix$generate$checkWorldProviderSuface(Random random, int chunkX, int chunkZ, World world,
IChunkProvider chunkGenerator, IChunkProvider chunkProvider, CallbackInfo callback) {
if (world.provider.dimensionId == 0 || world.provider.dimensionId == -1 || world.provider.dimensionId == 1) {
// Handled by original already
Expand Down

0 comments on commit 66dcd83

Please sign in to comment.