Fixed slimes not splitting when hp is under 0

master
Wynd 2024-08-19 01:03:12 +03:00
parent b73a52ed98
commit 406fe6f861
4 changed files with 38 additions and 13 deletions

View File

@ -75,6 +75,8 @@ public class ModConfig {
"Fixes double doors not being in their correct state when pressure plates are used to open them"); "Fixes double doors not being in their correct state when pressure plates are used to open them");
public static final Option<Boolean> FIX_SLABS_RECIPE = make("Fix Slabs Recipe", true, public static final Option<Boolean> FIX_SLABS_RECIPE = make("Fix Slabs Recipe", true,
"Givs two slabs for every block, since 1 block = 2 slabs => 3 blocks = 6 slabs (instead of 3)"); "Givs two slabs for every block, since 1 block = 2 slabs => 3 blocks = 6 slabs (instead of 3)");
public static final Option<Boolean> FIX_SLIME_SPLITS = make("Fix Slime Splits", true,
"Fixes slimes not splitting if their HP is not exactly zero");
private static ModConfig instance = new ModConfig(); private static ModConfig instance = new ModConfig();
public static final ModConfig instance() { public static final ModConfig instance() {

View File

@ -8,8 +8,6 @@ import java.util.HashMap;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.Player; import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemInstance;
import net.minecraft.item.ItemType;
public class WyHelper { public class WyHelper {
@ -94,12 +92,17 @@ public class WyHelper {
} }
public static void cheatCommand(Player player) { public static void cheatCommand(Player player) {
player.level.entities.stream().filter(e -> !(e instanceof Player)).forEach((e) -> ((net.minecraft.entity.Entity)e).remove()); // Slime slime = new Slime(player.level);
// slime.setPositionAndAngles(player.x, player.y + 0.5D, player.z, player.level.rand.nextFloat() * 360.0F, 0.0F);
// player.level.spawnEntity(slime);
// slime.setSize(10);
// player.level.entities.stream().filter(e -> !(e instanceof Player)).forEach((e) -> ((net.minecraft.entity.Entity)e).remove());
// player.dropItem(new ItemInstance(Tile.LADDER, 64)); // player.dropItem(new ItemInstance(Tile.LADDER, 64));
player.dropItem(new ItemInstance(ItemType.minecart, 1)); // player.dropItem(new ItemInstance(ItemType.minecart, 1));
player.dropItem(new ItemInstance(ItemType.minecartFurnace, 1)); // player.dropItem(new ItemInstance(ItemType.minecartFurnace, 1));
player.dropItem(new ItemInstance(ItemType.coal, 64)); // player.dropItem(new ItemInstance(ItemType.coal, 64));
// player.dropItem(new ItemInstance(Tile.GOLDEN_RAIL, 64)); // player.dropItem(new ItemInstance(Tile.GOLDEN_RAIL, 64));
// player.dropItem(new ItemInstance(Tile.COBBLESTONE, 64)); // player.dropItem(new ItemInstance(Tile.COBBLESTONE, 64));
@ -113,11 +116,10 @@ public class WyHelper {
// player.level.setTile(x + i, y, z, Tile.REDSTONE_TORCH_LIT.id); // player.level.setTile(x + i, y, z, Tile.REDSTONE_TORCH_LIT.id);
// } // }
// player.level.setLevelTime(0);
player.level.setLevelTime(0); // player.level.getProperties().setRaining(false);
player.level.getProperties().setRaining(false); // player.level.getProperties().setRainTime(0);
player.level.getProperties().setRainTime(0); // player.level.getProperties().setThundering(false);
player.level.getProperties().setThundering(false); // player.level.getProperties().setThunderTime(0);
player.level.getProperties().setThunderTime(0);
} }
} }

View File

@ -0,0 +1,20 @@
package xyz.pixelatedw.finalbeta.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.entity.monster.Slime;
import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(Slime.class)
public class SlimeMixin {
@Inject(method = "remove", at = @At("HEAD"))
public void remove(CallbackInfo ci) {
if (ModConfig.FIX_SLIME_SPLITS.get()) {
Slime slime = ((Slime) (Object) this);
slime.health = Math.max(slime.health, 0);
}
}
}

View File

@ -41,7 +41,8 @@
"CraftingInventoryMixin", "CraftingInventoryMixin",
"RecipeRegistryMixin", "RecipeRegistryMixin",
"SnowballMixin", "SnowballMixin",
"EntityMixin" "EntityMixin",
"SlimeMixin"
], ],
"injectors": { "injectors": {
"defaultRequire": -1 "defaultRequire": -1