Added random sfx for lava pools and furnaces while they're cookin

master
Wynd 2024-12-24 19:21:10 +02:00
parent e117a7e25c
commit c092414565
4 changed files with 45 additions and 3 deletions

View File

@ -115,7 +115,7 @@ public class WyHelper {
// player.dropItem(new ItemInstance(Tile.SLAB, 64));
// player.dropItem(new ItemInstance(ItemType.minecart, 1));
// player.dropItem(new ItemInstance(ItemType.minecartFurnace, 1));
player.dropItem(new ItemInstance(ItemType.flintAndSteel, 1));
player.dropItem(new ItemInstance(ItemType.bucket, 1));
// player.dropItem(new ItemInstance(Tile.GOLDEN_RAIL, 64));
// player.dropItem(new ItemInstance(Tile.COBBLESTONE, 64));

View File

@ -23,8 +23,22 @@ public class FurnaceEntityMixin {
@Shadow
private ItemInstance[] contents;
private int nextRandomTick = 20;
@Inject(method = "tick", at = @At("HEAD"))
public void tickHead(CallbackInfo ci) {
FurnaceEntity tileEntity = ((FurnaceEntity)(Object)this);
if (ModConfig.ADD_MORE_SOUNDS.get() && tileEntity.cookTime > 0) {
if (tileEntity.level.getLevelTime() % this.nextRandomTick == 0) {
float pitch = 0.5f + tileEntity.level.rand.nextFloat() / 1.5f;
tileEntity.level.playSound(tileEntity.x, tileEntity.y, tileEntity.z, "sound3.liquid.lavapop", 0.4f, pitch);
this.nextRandomTick = 20 + tileEntity.level.rand.nextInt(20);
}
}
}
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/FurnaceEntity;getFuelTime(Lnet/minecraft/item/ItemInstance;)I", shift = At.Shift.BY, by = 5), cancellable = true)
public void tick(CallbackInfo ci) {
public void tick(CallbackInfo ci) {
if(ModConfig.FIX_FURNACE_LAVA_BUCKET.get()) {
if(this.contents[1] != null && this.contents[1].itemId == ItemType.bucketLava.id) {
ci.cancel();

View File

@ -0,0 +1,27 @@
package xyz.pixelatedw.finalbeta.mixin;
import java.util.Random;
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.level.Level;
import net.minecraft.tile.StillFluidTile;
import net.minecraft.tile.material.Material;
@Mixin(StillFluidTile.class)
public class StillFluidTileMixin {
@Inject(method = "onScheduledTick", at = @At("HEAD"))
public void onScheduledTick(Level level, int x, int y, int z, Random random, CallbackInfo ci) {
StillFluidTile tile = ((StillFluidTile) (Object) this);
if (tile.material == Material.LAVA) {
if (level.rand.nextBoolean()) {
level.playSound(x, y, z, "sound3.liquid.lava", 0.5f, 1.0f);
} else {
level.playSound(x, y, z, "sound3.liquid.lavapop", 0.5f, 1.0f);
}
}
}
}

View File

@ -48,7 +48,8 @@
"FoodItemMixin",
"ItemTypeAccessor",
"PressurePlateTileMixin",
"LeavesTileMixin"
"LeavesTileMixin",
"StillFluidTileMixin"
],
"injectors": {
"defaultRequire": -1