Fixes o'plenty, nearing completion

This commit is contained in:
Vaern 2023-05-16 19:58:15 -07:00
parent 5f27a78bcb
commit d871e46b9f
4 changed files with 29 additions and 12 deletions

View File

@ -16,6 +16,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@ -179,7 +180,7 @@ public class PistonInserter extends BlockContainerBase {
@SideOnly(Side.CLIENT) public double renderExtend;
@SideOnly(Side.CLIENT) public double lastExtend;
@SideOnly(Side.CLIENT) private int syncExtend; //what are these for?
@SideOnly(Side.CLIENT) private int turnProgress; //idk man, i can't find the convo bob had about them
@SideOnly(Side.CLIENT) private int turnProgress;
public TileEntityPistonInserter() { }
@ -271,7 +272,7 @@ public class PistonInserter extends BlockContainerBase {
this.extend = nbt.getInteger("extend");
this.isRetracting = nbt.getBoolean("retract");
this.lastState = nbt.getBoolean("state");
if(nbt.hasKey("stack")) { //TODO double check that these work
if(nbt.hasKey("stack")) {
NBTTagCompound stack = nbt.getCompoundTag("stack");
this.slot = ItemStack.loadItemStackFromNBT(stack);
} else {
@ -279,7 +280,19 @@ public class PistonInserter extends BlockContainerBase {
}
}
//TODO: render AABB that extends out in direction of piston so it will render
@SideOnly(Side.CLIENT)
private AxisAlignedBB aabb;
@Override
public AxisAlignedBB getRenderBoundingBox() {
if(aabb != null)
return aabb;
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata());
aabb = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).addCoord(dir.offsetX, dir.offsetY, dir.offsetZ);
return aabb;
}
/* BS inventory stuff */

View File

@ -201,13 +201,15 @@ public abstract class BlockGraphiteDrilledBase extends BlockFlammable implements
newTag.setInteger("z", te.zCoord + dir.offsetZ);
}
world.setBlock(ix, iy, iz, oldBlock, (oldMeta & ~0b100) | (newMeta & 0b100), 2);
world.setBlock(ix, iy, iz, oldBlock, (oldMeta & ~0b100) | (newMeta & 0b100), 0);
if(oldBlock instanceof BlockGraphiteDrilledTE && !oldTag.hasNoTags()) { //safety first
TileEntity te = world.getTileEntity(ix, iy, iz);
te.readFromNBT(oldTag);
}
world.markAndNotifyBlock(ix, iy, iz, world.getChunkFromBlockCoords(ix, iz), newBlock, oldBlock, 3); //in case setBlock returns false due to = meta / block
oldMeta = newMeta;
oldBlock = newBlock;
oldTag = newTag;

View File

@ -24,8 +24,12 @@ import net.minecraftforge.common.util.ForgeDirection;
public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolable, IBlowable {
@Override
public TileEntity createNewTileEntity(World world, int mets) {
return new TileEntityPileFuel();
public TileEntity createNewTileEntity(World world, int meta) {
TileEntityPileFuel pile = new TileEntityPileFuel();
if((meta & 8) != 0)
pile.progress = pile.maxProgress - 1000; // pu239 rods cringe :(
return pile;
}
@Override
@ -41,7 +45,7 @@ public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolab
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int side) { //serverside? maybe
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
TileEntityPileFuel pile = (TileEntityPileFuel)world.getTileEntity(x, y, z);
return MathHelper.clamp_int((pile.progress * 16) / pile.maxProgress, 0, 15); //potentially wip
}

View File

@ -18,7 +18,7 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
public int neutrons;
public int lastNeutrons;
public int progress;
public static final int maxProgress = GeneralConfig.enable528 ? 75000 : 50000;
public static final int maxProgress = GeneralConfig.enable528 ? 75000 : 50000; //might double to reduce compact setup's effectiveness
@Override
public void updateEntity() {
@ -79,10 +79,8 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
private void checkRedstone(int lastProgress) {
int lastLevel = MathHelper.clamp_int((lastProgress * 16) / maxProgress, 0, 15);
int newLevel = MathHelper.clamp_int((progress * 16) / maxProgress, 0, 15);
if(lastLevel != newLevel) //TODO TEST
System.out.println(lastLevel + ", " + newLevel + "; " + lastProgress + ", " + progress);
if(lastLevel != newLevel) //the block update doesn't seem to update the comparators... need to troubleshoot and fix
worldObj.scheduleBlockUpdate(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1); //TODO test
if(lastLevel != newLevel)
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, this.getBlockType());
}
private void transmute() {