mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
some more crane functionality
This commit is contained in:
parent
8090108257
commit
223469bad7
@ -68,10 +68,18 @@ public class RenderCraneConsole extends TileEntitySpecialRenderer {
|
|||||||
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
|
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
|
||||||
GL11.glColor3f(0F, 1F, 0F);
|
|
||||||
|
//loading indicator
|
||||||
|
if(console.isCraneLoading()) GL11.glColor3f(0.8F, 0.8F, 0F); //is the crane loading? yellow
|
||||||
|
else if(console.hasItemLoaded()) GL11.glColor3f(0F, 1F, 0F); //is the crane loaded? green
|
||||||
|
else GL11.glColor3f(0F, 0.1F, 0F); //is the crane unloaded? off
|
||||||
ResourceManager.rbmk_crane_console.renderPart("Lamp1");
|
ResourceManager.rbmk_crane_console.renderPart("Lamp1");
|
||||||
GL11.glColor3f(1F, 1F, 0F);
|
|
||||||
|
//target indicator
|
||||||
|
if(console.isAboveValidTarget()) GL11.glColor3f(0F, 1F, 0F); //valid? green
|
||||||
|
else GL11.glColor3f(1F, 0F, 0F); //not valid? red
|
||||||
ResourceManager.rbmk_crane_console.renderPart("Lamp2");
|
ResourceManager.rbmk_crane_console.renderPart("Lamp2");
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
GL11.glPopAttrib();
|
GL11.glPopAttrib();
|
||||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.hbm.tileentity.machine.rbmk;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.hbm.blocks.BlockDummyable;
|
import com.hbm.blocks.BlockDummyable;
|
||||||
|
import com.hbm.blocks.machine.rbmk.RBMKBase;
|
||||||
import com.hbm.extprop.HbmPlayerProps;
|
import com.hbm.extprop.HbmPlayerProps;
|
||||||
import com.hbm.handler.HbmKeybinds.EnumKeybind;
|
import com.hbm.handler.HbmKeybinds.EnumKeybind;
|
||||||
import com.hbm.packet.NBTPacket;
|
import com.hbm.packet.NBTPacket;
|
||||||
@ -12,10 +13,13 @@ import com.hbm.tileentity.INBTPacketReceiver;
|
|||||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityCraneConsole extends TileEntity implements INBTPacketReceiver {
|
public class TileEntityCraneConsole extends TileEntity implements INBTPacketReceiver {
|
||||||
@ -47,6 +51,9 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece
|
|||||||
private boolean goesDown = false;
|
private boolean goesDown = false;
|
||||||
public double lastProgress = 1D;
|
public double lastProgress = 1D;
|
||||||
public double progress = 1D;
|
public double progress = 1D;
|
||||||
|
|
||||||
|
private ItemStack loadedItem;
|
||||||
|
private boolean hasLoaded = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
@ -93,7 +100,7 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece
|
|||||||
tiltFront = 0;
|
tiltFront = 0;
|
||||||
tiltLeft = 0;
|
tiltLeft = 0;
|
||||||
|
|
||||||
if(players.size() > 0 && progress == 1D) {
|
if(players.size() > 0 && !isCraneLoading()) {
|
||||||
EntityPlayer player = players.get(0);
|
EntityPlayer player = players.get(0);
|
||||||
HbmPlayerProps props = HbmPlayerProps.getData(player);
|
HbmPlayerProps props = HbmPlayerProps.getData(player);
|
||||||
boolean up = props.getKeyPressed(EnumKeybind.CRANE_UP);
|
boolean up = props.getKeyPressed(EnumKeybind.CRANE_UP);
|
||||||
@ -103,34 +110,28 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece
|
|||||||
|
|
||||||
if(up && !down) {
|
if(up && !down) {
|
||||||
tiltFront = 30;
|
tiltFront = 30;
|
||||||
posFront += speed;
|
if(!worldObj.isRemote) posFront += speed;
|
||||||
}
|
}
|
||||||
if(!up && down) {
|
if(!up && down) {
|
||||||
tiltFront = -30;
|
tiltFront = -30;
|
||||||
posFront -= speed;
|
if(!worldObj.isRemote) posFront -= speed;
|
||||||
}
|
}
|
||||||
if(left && !right) {
|
if(left && !right) {
|
||||||
tiltLeft = 30;
|
tiltLeft = 30;
|
||||||
posLeft += speed;
|
if(!worldObj.isRemote) posLeft += speed;
|
||||||
}
|
}
|
||||||
if(!left && right) {
|
if(!left && right) {
|
||||||
tiltLeft = -30;
|
tiltLeft = -30;
|
||||||
posLeft -= speed;
|
if(!worldObj.isRemote) posLeft -= speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(props.getKeyPressed(EnumKeybind.CRANE_LOAD)) {
|
if(props.getKeyPressed(EnumKeybind.CRANE_LOAD)) {
|
||||||
goesDown = true;
|
goesDown = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(posFront > spanF)
|
posFront = MathHelper.clamp_double(posFront, -spanB, spanF);
|
||||||
posFront = spanF;
|
posLeft = MathHelper.clamp_double(posFront, -spanR, spanL);
|
||||||
if(posFront < -spanB)
|
|
||||||
posFront = -spanB;
|
|
||||||
if(posLeft > spanL)
|
|
||||||
posLeft = spanL;
|
|
||||||
if(posLeft < -spanR)
|
|
||||||
posLeft = -spanR;
|
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
@ -146,11 +147,56 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece
|
|||||||
nbt.setInteger("spanL", spanL);
|
nbt.setInteger("spanL", spanL);
|
||||||
nbt.setInteger("spanR", spanR);
|
nbt.setInteger("spanR", spanR);
|
||||||
nbt.setInteger("height", height);
|
nbt.setInteger("height", height);
|
||||||
nbt.setInteger("height", height);
|
nbt.setDouble("posFront", posFront);
|
||||||
|
nbt.setDouble("posLeft", posLeft);
|
||||||
|
nbt.setBoolean("loaded", this.hasItemLoaded());
|
||||||
}
|
}
|
||||||
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 250));
|
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 250));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasItemLoaded() {
|
||||||
|
|
||||||
|
if(!worldObj.isRemote)
|
||||||
|
return this.loadedItem != null;
|
||||||
|
else
|
||||||
|
return this.hasLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCraneLoading() {
|
||||||
|
return this.progress != 1D;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAboveValidTarget() {
|
||||||
|
return getColumnAtPos() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canTargetInteract() {
|
||||||
|
|
||||||
|
IRBMKLoadable column = getColumnAtPos();
|
||||||
|
|
||||||
|
if(column == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(this.hasItemLoaded()) {
|
||||||
|
return column.canLoad(loadedItem);
|
||||||
|
} else {
|
||||||
|
return column.canUnload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRBMKLoadable getColumnAtPos() {
|
||||||
|
|
||||||
|
/*int x = this.centerX + this.
|
||||||
|
Block b = worldObj.getBlock(x, y, z);
|
||||||
|
|
||||||
|
if(b instanceof RBMKBase) {
|
||||||
|
|
||||||
|
int[] pos = ((BlockDummyable)b).findCore(world, x, y, z);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void networkUnpack(NBTTagCompound nbt) {
|
public void networkUnpack(NBTTagCompound nbt) {
|
||||||
@ -163,11 +209,14 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece
|
|||||||
this.spanL = nbt.getInteger("spanL");
|
this.spanL = nbt.getInteger("spanL");
|
||||||
this.spanR = nbt.getInteger("spanR");
|
this.spanR = nbt.getInteger("spanR");
|
||||||
this.height = nbt.getInteger("height");
|
this.height = nbt.getInteger("height");
|
||||||
|
this.posFront = nbt.getDouble("posFront");
|
||||||
|
this.posLeft = nbt.getDouble("posLeft");
|
||||||
|
this.hasLoaded = nbt.getBoolean("loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTarget(int x, int y, int z) {
|
public void setTarget(int x, int y, int z) {
|
||||||
this.centerX = x;
|
this.centerX = x;
|
||||||
this.centerY = y + 5;
|
this.centerY = y + RBMKDials.getColumnHeight(worldObj) + 1;
|
||||||
this.centerZ = z;
|
this.centerZ = z;
|
||||||
|
|
||||||
this.spanF = 7;
|
this.spanF = 7;
|
||||||
|
|||||||
@ -10,12 +10,13 @@ import com.hbm.items.machine.ItemRBMKRod;
|
|||||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
|
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
|
||||||
|
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBMKFluxReceiver {
|
public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBMKFluxReceiver, IRBMKLoadable {
|
||||||
|
|
||||||
//amount of "neutron energy" buffered for the next tick to use for the reaction
|
//amount of "neutron energy" buffered for the next tick to use for the reaction
|
||||||
public double fluxFast;
|
public double fluxFast;
|
||||||
@ -313,4 +314,31 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canLoad(ItemStack toLoad) {
|
||||||
|
return toLoad != null && slots[0] == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(ItemStack toLoad) {
|
||||||
|
slots[0] = toLoad.copy();
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUnload() {
|
||||||
|
return slots[0] != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack provideNext() {
|
||||||
|
return slots[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unload() {
|
||||||
|
slots[0] = null;
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Loading…
x
Reference in New Issue
Block a user