Fix Campfire Bug

This commit is contained in:
Kam committed 2025-02-04 02:19:51 -05:00
1 parent 1be707ce47
commit 4f52e2674b
4 files changed
+33 -14

No files matched your search

@@ -41,8 +41,7 @@ public class BlockCampfire extends BlockLightable{
int meta = world.getBlockMetadata(x, y, z);
if((item.getItem() == Items.flint || item.getItem() == Items.flint_and_steel) && unlitBlock() == this){
if(world.rand.nextInt(3) == 0 && !world.isRemote)
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
CustomNpcs.proxy.spawnParticle("largesmoke", x + 0.5f, y + 0.5f, z + 0.5f, 0.0D, 0.0D, 0.0D, 2);
if(item.getItem() == Items.flint)
NoppesUtilServer.consumeItemStack(1, player);
@@ -6,33 +6,49 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.Random;
public abstract class BlockLightable extends BlockRotated{
public abstract class BlockLightable extends BlockRotated {
protected BlockLightable(Block block, boolean lit) {
super(block);
if (lit)
this.setLightLevel(1.0F);
}
public abstract Block unlitBlock();
public abstract Block litBlock();
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
TileEntity tile = world.getTileEntity(x, y, z);
if(litBlock() == this)
world.setBlock(x, y, z, unlitBlock(), world.getBlockMetadata(x, y, z), 2);
else
world.setBlock(x, y, z, litBlock(), world.getBlockMetadata(x, y, z), 2);
tile.validate();
world.setTileEntity(x, y, z, tile);
// Get the current tile entity and store its NBT
TileEntity oldTile = world.getTileEntity(x, y, z);
NBTTagCompound compound = new NBTTagCompound();
oldTile.writeToNBT(compound);
// Determine which block to set (lit/unlit) based on the current one
Block newBlock = (litBlock() == this ? unlitBlock() : litBlock());
int meta = world.getBlockMetadata(x, y, z);
// Change the block; this creates a new tile entity instance
world.setBlock(x, y, z, newBlock, meta, 2);
// Get the new tile and load the stored NBT
TileEntity newTile = world.getTileEntity(x, y, z);
if(newTile != null){
newTile.readFromNBT(compound);
newTile.markDirty();
}
world.markBlockForUpdate(x, y, z);
world.notifyBlockOfNeighborChange(x, y, z, newBlock);
return true;
}
@@ -1,6 +1,9 @@
package noppes.npcs.blocks.tiles;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs;
import java.util.Random;
@@ -53,6 +56,7 @@ public class TileCampfire extends TileColorable {
public boolean isLit()
{
return this.getBlockMetadata() == 0;
Block block = this.getBlockType();
return block == CustomItems.campfire;
}
}
@@ -19,7 +19,7 @@ import noppes.npcs.config.ConfigClient;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class BlockCampfireRenderer extends BlockRendererInterface{
public class BlockCampfireRenderer extends BlockRendererInterface {
// Legacy
private final ModelCampfire legacy_model = new ModelCampfire();