Fixed piston display, fixed critical issue, added comparator output

still need fixes
This commit is contained in:
Vaern 2023-05-16 15:09:11 -07:00
parent 2ea60eae13
commit 5f27a78bcb
4 changed files with 73 additions and 9 deletions

View File

@ -71,7 +71,7 @@ public class PistonInserter extends BlockContainerBase {
if(!world.isRemote) {
TileEntityPistonInserter piston = (TileEntityPistonInserter)world.getTileEntity(x, y, z);
if(piston.slot != null) {
if(piston.slot != null && piston.isRetracting) {
ForgeDirection dir = ForgeDirection.getOrientation(piston.getBlockMetadata());
EntityItem dust = new EntityItem(world, x + 0.5D + dir.offsetX * 0.75D, y + 0.5D + dir.offsetY * 0.75D, z + 0.5D + dir.offsetZ * 0.75D, piston.slot);
@ -113,6 +113,8 @@ public class PistonInserter extends BlockContainerBase {
return meta != side.ordinal() && meta != side.getOpposite().ordinal();
}
//TODO make item drop when block is broken
@Override
public int getRenderType(){
return -1;
@ -252,6 +254,7 @@ public class PistonInserter extends BlockContainerBase {
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("extend", extend);
nbt.setBoolean("retract", isRetracting);
nbt.setBoolean("state", lastState); //saved so loading into a world doesn't cause issues
@ -264,10 +267,11 @@ public class PistonInserter extends BlockContainerBase {
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.extend = nbt.getInteger("extend");
this.isRetracting = nbt.getBoolean("retract");
this.lastState = nbt.getBoolean("state");
if(nbt.hasKey("stack")) {
if(nbt.hasKey("stack")) { //TODO double check that these work
NBTTagCompound stack = nbt.getCompoundTag("stack");
this.slot = ItemStack.loadItemStackFromNBT(stack);
} else {

View File

@ -17,6 +17,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@ -34,6 +35,17 @@ public class BlockGraphiteFuel extends BlockGraphiteDrilledTE implements IToolab
this.blockIconAluminum = iconRegister.registerIcon(RefStrings.MODID + ":block_graphite_fuel_aluminum");
}
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int side) { //serverside? maybe
TileEntityPileFuel pile = (TileEntityPileFuel)world.getTileEntity(x, y, z);
return MathHelper.clamp_int((pile.progress * 16) / pile.maxProgress, 0, 15); //potentially wip
}
@Override
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {

View File

@ -6,11 +6,16 @@ import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.machine.PistonInserter.TileEntityPistonInserter;
import com.hbm.main.ResourceManager;
import com.hbm.render.item.ItemRenderBase;
import com.hbm.render.util.RenderDecoItem;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraftforge.client.IItemRenderer;
public class RenderPistonInserter extends TileEntitySpecialRenderer implements IItemRendererProvider {
@ -25,10 +30,13 @@ public class RenderPistonInserter extends TileEntitySpecialRenderer implements I
switch(tile.getBlockMetadata()) {
case 0: GL11.glRotatef(180, 1F, 0F, 0F); break;
case 1: break;
case 2: GL11.glRotatef(-90, 1F, 0F, 0F); break;
case 4: GL11.glRotatef(90, 0F, 0F, 1F); break;
case 2: GL11.glRotatef(-90, 1F, 0F, 0F);
GL11.glRotatef(180, 0F, 1F, 0F); break;
case 4: GL11.glRotatef(90, 0F, 0F, 1F);
GL11.glRotatef(-90, 0F, 1F, 0F); break;
case 3: GL11.glRotatef(90, 1F, 0F, 0F); break;
case 5: GL11.glRotatef(-90, 0F, 0F, 1F); break;
case 5: GL11.glRotatef(-90, 0F, 0F, 1F);
GL11.glRotatef(90, 0F, 1F, 0F); break;
}
GL11.glTranslated(0D, -0.5, 0D);
@ -40,6 +48,32 @@ public class RenderPistonInserter extends TileEntitySpecialRenderer implements I
double e = (piston.lastExtend + (piston.renderExtend - piston.lastExtend) * interp) / (double) piston.maxExtend;
GL11.glTranslated(0, e * 0.9375D, 0);
ResourceManager.piston_inserter.renderPart("Piston");
RenderItem itemRenderer = new RenderDecoItem(this);
itemRenderer.setRenderManager(RenderManager.instance);
if(piston.slot != null) {
ItemStack stack = piston.slot.copy();
EntityItem item = new EntityItem(null, 0.0D, 0.0D, 0.0D, stack);
item.getEntityItem().stackSize = 1;
item.hoverStart = 0.0F;
if(stack.getItem() instanceof ItemBlock) {
GL11.glTranslated(0.0D, 1.125D, 0.0D);
} else {
GL11.glTranslated(0.0D, 1.0625D, 0.1D);
if(!RenderManager.instance.options.fancyGraphics)
GL11.glTranslated(0.0D, 0.01D, 0.0D);
GL11.glRotated(90, -1, 0, 0);
}
RenderItem.renderInFrame = true;
itemRenderer.doRender(item, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
RenderItem.renderInFrame = false;
}
GL11.glPopMatrix();
}

View File

@ -9,6 +9,7 @@ import com.hbm.packet.PacketDispatcher;
import api.hbm.block.IPileNeutronReceiver;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutronReceiver {
@ -24,7 +25,7 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
if(!worldObj.isRemote) {
dissipateHeat();
react();
checkRedstone(react());
transmute();
if(this.heat >= this.maxHeat) {
@ -53,22 +54,35 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
this.heat -= (this.getBlockMetadata() & 4) == 4 ? heat * 0.065 : heat * 0.05; //remove 5% of the stored heat per tick; 6.5% for windscale
}
private void react() {
private int react() {
int reaction = (int) (this.neutrons * (1D - ((double)this.heat / (double)this.maxHeat) * 0.5D)); //max heat reduces reaction by 50% due to thermal expansion
this.lastNeutrons = this.neutrons;
this.neutrons = 0;
int lastProgress = this.progress;
this.progress += reaction;
if(reaction <= 0)
return;
return lastProgress;
this.heat += reaction;
for(int i = 0; i < 12; i++)
this.castRay((int) Math.max(reaction * 0.25, 1), 5);
return lastProgress;
}
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
}
private void transmute() {