mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Fixed piston display, fixed critical issue, added comparator output
still need fixes
This commit is contained in:
parent
2ea60eae13
commit
5f27a78bcb
@ -71,7 +71,7 @@ public class PistonInserter extends BlockContainerBase {
|
|||||||
if(!world.isRemote) {
|
if(!world.isRemote) {
|
||||||
TileEntityPistonInserter piston = (TileEntityPistonInserter)world.getTileEntity(x, y, z);
|
TileEntityPistonInserter piston = (TileEntityPistonInserter)world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
if(piston.slot != null) {
|
if(piston.slot != null && piston.isRetracting) {
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(piston.getBlockMetadata());
|
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);
|
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();
|
return meta != side.ordinal() && meta != side.getOpposite().ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO make item drop when block is broken
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRenderType(){
|
public int getRenderType(){
|
||||||
return -1;
|
return -1;
|
||||||
@ -252,6 +254,7 @@ public class PistonInserter extends BlockContainerBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
|
super.writeToNBT(nbt);
|
||||||
nbt.setInteger("extend", extend);
|
nbt.setInteger("extend", extend);
|
||||||
nbt.setBoolean("retract", isRetracting);
|
nbt.setBoolean("retract", isRetracting);
|
||||||
nbt.setBoolean("state", lastState); //saved so loading into a world doesn't cause issues
|
nbt.setBoolean("state", lastState); //saved so loading into a world doesn't cause issues
|
||||||
@ -264,10 +267,11 @@ public class PistonInserter extends BlockContainerBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt) {
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
|
super.readFromNBT(nbt);
|
||||||
this.extend = nbt.getInteger("extend");
|
this.extend = nbt.getInteger("extend");
|
||||||
this.isRetracting = nbt.getBoolean("retract");
|
this.isRetracting = nbt.getBoolean("retract");
|
||||||
this.lastState = nbt.getBoolean("state");
|
this.lastState = nbt.getBoolean("state");
|
||||||
if(nbt.hasKey("stack")) {
|
if(nbt.hasKey("stack")) { //TODO double check that these work
|
||||||
NBTTagCompound stack = nbt.getCompoundTag("stack");
|
NBTTagCompound stack = nbt.getCompoundTag("stack");
|
||||||
this.slot = ItemStack.loadItemStackFromNBT(stack);
|
this.slot = ItemStack.loadItemStackFromNBT(stack);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.util.ChatComponentText;
|
import net.minecraft.util.ChatComponentText;
|
||||||
import net.minecraft.util.ChatStyle;
|
import net.minecraft.util.ChatStyle;
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
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");
|
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
|
@Override
|
||||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||||
|
|
||||||
|
|||||||
@ -6,11 +6,16 @@ import com.hbm.blocks.ModBlocks;
|
|||||||
import com.hbm.blocks.machine.PistonInserter.TileEntityPistonInserter;
|
import com.hbm.blocks.machine.PistonInserter.TileEntityPistonInserter;
|
||||||
import com.hbm.main.ResourceManager;
|
import com.hbm.main.ResourceManager;
|
||||||
import com.hbm.render.item.ItemRenderBase;
|
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.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraftforge.client.IItemRenderer;
|
import net.minecraftforge.client.IItemRenderer;
|
||||||
|
|
||||||
public class RenderPistonInserter extends TileEntitySpecialRenderer implements IItemRendererProvider {
|
public class RenderPistonInserter extends TileEntitySpecialRenderer implements IItemRendererProvider {
|
||||||
@ -25,10 +30,13 @@ public class RenderPistonInserter extends TileEntitySpecialRenderer implements I
|
|||||||
switch(tile.getBlockMetadata()) {
|
switch(tile.getBlockMetadata()) {
|
||||||
case 0: GL11.glRotatef(180, 1F, 0F, 0F); break;
|
case 0: GL11.glRotatef(180, 1F, 0F, 0F); break;
|
||||||
case 1: break;
|
case 1: break;
|
||||||
case 2: GL11.glRotatef(-90, 1F, 0F, 0F); break;
|
case 2: GL11.glRotatef(-90, 1F, 0F, 0F);
|
||||||
case 4: GL11.glRotatef(90, 0F, 0F, 1F); break;
|
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 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);
|
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;
|
double e = (piston.lastExtend + (piston.renderExtend - piston.lastExtend) * interp) / (double) piston.maxExtend;
|
||||||
GL11.glTranslated(0, e * 0.9375D, 0);
|
GL11.glTranslated(0, e * 0.9375D, 0);
|
||||||
ResourceManager.piston_inserter.renderPart("Piston");
|
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();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import com.hbm.packet.PacketDispatcher;
|
|||||||
import api.hbm.block.IPileNeutronReceiver;
|
import api.hbm.block.IPileNeutronReceiver;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
|
||||||
public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutronReceiver {
|
public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutronReceiver {
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ public class TileEntityPileFuel extends TileEntityPileBase implements IPileNeutr
|
|||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
dissipateHeat();
|
dissipateHeat();
|
||||||
react();
|
checkRedstone(react());
|
||||||
transmute();
|
transmute();
|
||||||
|
|
||||||
if(this.heat >= this.maxHeat) {
|
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
|
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
|
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.lastNeutrons = this.neutrons;
|
||||||
this.neutrons = 0;
|
this.neutrons = 0;
|
||||||
|
|
||||||
|
int lastProgress = this.progress;
|
||||||
|
|
||||||
this.progress += reaction;
|
this.progress += reaction;
|
||||||
|
|
||||||
if(reaction <= 0)
|
if(reaction <= 0)
|
||||||
return;
|
return lastProgress;
|
||||||
|
|
||||||
this.heat += reaction;
|
this.heat += reaction;
|
||||||
|
|
||||||
for(int i = 0; i < 12; i++)
|
for(int i = 0; i < 12; i++)
|
||||||
this.castRay((int) Math.max(reaction * 0.25, 1), 5);
|
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() {
|
private void transmute() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user