mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
movable crane, crane texture, wokring keybinds
This commit is contained in:
parent
83bb0fd16f
commit
8090108257
@ -86,7 +86,8 @@ public class BlockVacuum extends Block {
|
||||
if(b == this)
|
||||
continue;
|
||||
|
||||
if(b.getBlockBoundsMinX() > 0 || b.getBlockBoundsMinY() > 0 || b.getBlockBoundsMinZ() > 0 ||
|
||||
if(b.getMaterial() == Material.air ||
|
||||
b.getBlockBoundsMinX() > 0 || b.getBlockBoundsMinY() > 0 || b.getBlockBoundsMinZ() > 0 ||
|
||||
b.getBlockBoundsMaxX() < 1 || b.getBlockBoundsMaxY() < 1 || b.getBlockBoundsMaxZ() < 1) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
return;
|
||||
|
||||
@ -6,6 +6,7 @@ import com.google.common.collect.Multimap;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.machine.rbmk.RBMKBase;
|
||||
import com.hbm.tileentity.machine.rbmk.TileEntityCraneConsole;
|
||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
@ -65,8 +66,25 @@ public class ItemRBMKTool extends Item {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(b == ModBlocks.rbmk_crane_console && stack.hasTagCompound()) {
|
||||
|
||||
if(!world.isRemote) {
|
||||
|
||||
int[] pos = ((BlockDummyable)b).findCore(world, x, y, z);
|
||||
|
||||
TileEntityCraneConsole console = (TileEntityCraneConsole)world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
int tx = stack.stackTagCompound.getInteger("posX");
|
||||
int ty = stack.stackTagCompound.getInteger("posY");
|
||||
int tz = stack.stackTagCompound.getInteger("posZ");
|
||||
console.setTarget(tx, ty, tz);
|
||||
player.addChatComponentMessage(new ChatComponentTranslation(this.getUnlocalizedName() + ".set").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
|
||||
|
||||
@ -407,14 +407,17 @@ public class ModEventHandlerClient {
|
||||
|
||||
EntityPlayer player = MainRegistry.proxy.me();
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
int i = MathHelper.floor_double(mc.thePlayer.posX);
|
||||
int j = MathHelper.floor_double(mc.thePlayer.posY);
|
||||
int k = MathHelper.floor_double(mc.thePlayer.posZ);
|
||||
Block block = mc.theWorld.getBlock(i, j, k);
|
||||
|
||||
if(block == ModBlocks.vacuum) {
|
||||
e.result = null;
|
||||
return;
|
||||
if(player != null) {
|
||||
int i = MathHelper.floor_double(player.posX);
|
||||
int j = MathHelper.floor_double(player.posY);
|
||||
int k = MathHelper.floor_double(player.posZ);
|
||||
Block block = mc.theWorld.getBlock(i, j, k);
|
||||
|
||||
if(block == ModBlocks.vacuum) {
|
||||
e.result = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ResourceLocation r = e.sound.getPositionedSoundLocation();
|
||||
|
||||
@ -1082,9 +1082,11 @@ public class ResourceManager {
|
||||
public static final IModelCustom rbmk_reflector = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_reflector.obj"));
|
||||
public static final IModelCustom rbmk_rods = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_rods.obj"));
|
||||
public static final IModelCustom rbmk_crane_console = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/crane_console.obj"));
|
||||
public static final IModelCustom rbmk_crane = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/crane.obj"));
|
||||
public static final IModelCustom rbmk_console = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/rbmk/rbmk_console.obj"));
|
||||
public static final IModelCustom rbmk_debris = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/rbmk/debris.obj"));
|
||||
public static final ResourceLocation rbmk_crane_console_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/crane_console.png");
|
||||
public static final ResourceLocation rbmk_crane_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/rbmk_crane.png");
|
||||
public static final ResourceLocation rbmk_console_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/rbmk_control.png");
|
||||
public static final IModelCustom hev_battery = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/battery.obj"));
|
||||
public static final IModelCustom anvil = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/anvil.obj"));
|
||||
|
||||
@ -4,6 +4,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.tileentity.machine.rbmk.TileEntityCraneConsole;
|
||||
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
@ -18,7 +19,7 @@ public class RenderCraneConsole extends TileEntitySpecialRenderer {
|
||||
|
||||
GL11.glTranslatef((float)x + 0.5F, (float)y, (float)z + 0.5F);
|
||||
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
switch(te.getBlockMetadata() - BlockDummyable.offset) {
|
||||
@ -28,12 +29,21 @@ public class RenderCraneConsole extends TileEntitySpecialRenderer {
|
||||
case 5: GL11.glRotatef(0, 0F, 1F, 0F); break;
|
||||
}
|
||||
|
||||
TileEntityCraneConsole console = (TileEntityCraneConsole) te;
|
||||
|
||||
GL11.glTranslated(0.5, 0, 0);
|
||||
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
bindTexture(ResourceManager.rbmk_crane_console_tex);
|
||||
ResourceManager.rbmk_crane_console.renderPart("Console_Coonsole");
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0.75, 1, 0);
|
||||
GL11.glRotated(console.lastTiltFront + (console.tiltFront - console.lastTiltFront) * interp, 0, 0, 1);
|
||||
GL11.glRotated(console.lastTiltLeft + (console.tiltLeft - console.lastTiltLeft) * interp, 1, 0, 0);
|
||||
GL11.glTranslated(-0.75, -1.015, 0);
|
||||
ResourceManager.rbmk_crane_console.renderPart("JoyStick");
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0, 1.25, 0.75);
|
||||
@ -65,9 +75,59 @@ public class RenderCraneConsole extends TileEntitySpecialRenderer {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopAttrib();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glColor3f(1F, 1F, 1F);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if(console.setUpCrane) {
|
||||
GL11.glTranslated(x + 0.5, y - 1, z + 0.5);
|
||||
bindTexture(ResourceManager.rbmk_crane_tex);
|
||||
|
||||
int height = console.height - 6;
|
||||
double cranePosX = (-te.xCoord + console.centerX);
|
||||
double cranePosY = (-te.yCoord + console.centerY);
|
||||
double cranePosZ = (-te.zCoord + console.centerZ);
|
||||
|
||||
GL11.glTranslated(cranePosX, cranePosY, cranePosZ);
|
||||
switch(te.getBlockMetadata() - BlockDummyable.offset) {
|
||||
case 2: GL11.glRotatef(90, 0F, 1F, 0F); break;
|
||||
case 4: GL11.glRotatef(180, 0F, 1F, 0F); break;
|
||||
case 3: GL11.glRotatef(270, 0F, 1F, 0F); break;
|
||||
case 5: GL11.glRotatef(0, 0F, 1F, 0F); break;
|
||||
}
|
||||
|
||||
double posX = (console.lastPosFront + (console.posFront - console.lastPosFront) * interp);
|
||||
double posZ = (console.lastPosLeft + (console.posLeft - console.lastPosLeft) * interp);
|
||||
GL11.glTranslated(0, 0, posZ);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(-console.spanL, height - 1, 0);
|
||||
|
||||
for(int i = -console.spanL; i <= console.spanR; i++) {
|
||||
ResourceManager.rbmk_crane.renderPart("Girder");
|
||||
GL11.glTranslated(1, 0, 0);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glTranslated(-posX, 0, 0);
|
||||
ResourceManager.rbmk_crane.renderPart("Main");
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
for(int i = 0; i < height; i++) {
|
||||
ResourceManager.rbmk_crane.renderPart("Tube");
|
||||
GL11.glTranslated(0, 1, 0);
|
||||
}
|
||||
GL11.glTranslated(0, -1, 0);
|
||||
ResourceManager.rbmk_crane.renderPart("Carriage");
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glTranslated(0, -3.25 * (1 - (console.lastProgress + (console.progress - console.lastProgress) * interp)), 0);
|
||||
ResourceManager.rbmk_crane.renderPart("Lift");
|
||||
}
|
||||
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
@ -1,15 +1,189 @@
|
||||
package com.hbm.tileentity.machine.rbmk;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.extprop.HbmPlayerProps;
|
||||
import com.hbm.handler.HbmKeybinds.EnumKeybind;
|
||||
import com.hbm.packet.NBTPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.tileentity.INBTPacketReceiver;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityCraneConsole extends TileEntity {
|
||||
public class TileEntityCraneConsole extends TileEntity implements INBTPacketReceiver {
|
||||
|
||||
public int centerX;
|
||||
public int centerY;
|
||||
public int centerZ;
|
||||
|
||||
public int spanF;
|
||||
public int spanB;
|
||||
public int spanL;
|
||||
public int spanR;
|
||||
|
||||
public int height;
|
||||
|
||||
public boolean setUpCrane = false;
|
||||
|
||||
public double lastTiltFront = 0;
|
||||
public double lastTiltLeft = 0;
|
||||
public double tiltFront = 0;
|
||||
public double tiltLeft = 0;
|
||||
|
||||
public double lastPosFront = 0;
|
||||
public double lastPosLeft = 0;
|
||||
public double posFront = 0;
|
||||
public double posLeft = 0;
|
||||
private static final double speed = 0.05D;
|
||||
|
||||
private boolean goesDown = false;
|
||||
public double lastProgress = 1D;
|
||||
public double progress = 1D;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(worldObj.isRemote) {
|
||||
lastTiltFront = tiltFront;
|
||||
lastTiltLeft = tiltLeft;
|
||||
lastPosFront = posFront;
|
||||
lastPosLeft = posLeft;
|
||||
lastProgress = progress;
|
||||
}
|
||||
|
||||
if(goesDown) {
|
||||
|
||||
if(progress > 0) {
|
||||
progress -= 0.04D;
|
||||
} else {
|
||||
progress = 0;
|
||||
goesDown = false;
|
||||
}
|
||||
} else if(progress != 1) {
|
||||
|
||||
progress += 0.04D;
|
||||
|
||||
if(progress > 1D) {
|
||||
progress = 1D;
|
||||
}
|
||||
}
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||
ForgeDirection side = dir.getRotation(ForgeDirection.UP);
|
||||
double minX = xCoord + 0.5 - side.offsetX * 1.5;
|
||||
double maxX = xCoord + 0.5 + side.offsetX * 1.5 + dir.offsetX * 2;
|
||||
double minZ = zCoord + 0.5 - side.offsetZ * 1.5;
|
||||
double maxZ = zCoord + 0.5 + side.offsetZ * 1.5 + dir.offsetZ * 2;
|
||||
|
||||
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(
|
||||
Math.min(minX, maxX),
|
||||
yCoord,
|
||||
Math.min(minZ, maxZ),
|
||||
Math.max(minX, maxX),
|
||||
yCoord + 2,
|
||||
Math.max(minZ, maxZ)));
|
||||
tiltFront = 0;
|
||||
tiltLeft = 0;
|
||||
|
||||
if(players.size() > 0 && progress == 1D) {
|
||||
EntityPlayer player = players.get(0);
|
||||
HbmPlayerProps props = HbmPlayerProps.getData(player);
|
||||
boolean up = props.getKeyPressed(EnumKeybind.CRANE_UP);
|
||||
boolean down = props.getKeyPressed(EnumKeybind.CRANE_DOWN);
|
||||
boolean left = props.getKeyPressed(EnumKeybind.CRANE_LEFT);
|
||||
boolean right = props.getKeyPressed(EnumKeybind.CRANE_RIGHT);
|
||||
|
||||
if(up && !down) {
|
||||
tiltFront = 30;
|
||||
posFront += speed;
|
||||
}
|
||||
if(!up && down) {
|
||||
tiltFront = -30;
|
||||
posFront -= speed;
|
||||
}
|
||||
if(left && !right) {
|
||||
tiltLeft = 30;
|
||||
posLeft += speed;
|
||||
}
|
||||
if(!left && right) {
|
||||
tiltLeft = -30;
|
||||
posLeft -= speed;
|
||||
}
|
||||
|
||||
if(props.getKeyPressed(EnumKeybind.CRANE_LOAD)) {
|
||||
goesDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(posFront > spanF)
|
||||
posFront = spanF;
|
||||
if(posFront < -spanB)
|
||||
posFront = -spanB;
|
||||
if(posLeft > spanL)
|
||||
posLeft = spanL;
|
||||
if(posLeft < -spanR)
|
||||
posLeft = -spanR;
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setBoolean("crane", setUpCrane);
|
||||
|
||||
if(setUpCrane) { //no need to send any of this if there's NO FUCKING CRANE THERE
|
||||
nbt.setInteger("centerX", centerX);
|
||||
nbt.setInteger("centerY", centerY);
|
||||
nbt.setInteger("centerZ", centerZ);
|
||||
nbt.setInteger("spanF", spanF);
|
||||
nbt.setInteger("spanB", spanB);
|
||||
nbt.setInteger("spanL", spanL);
|
||||
nbt.setInteger("spanR", spanR);
|
||||
nbt.setInteger("height", height);
|
||||
nbt.setInteger("height", height);
|
||||
}
|
||||
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 250));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
this.setUpCrane = nbt.getBoolean("crane");
|
||||
this.centerX = nbt.getInteger("centerX");
|
||||
this.centerY = nbt.getInteger("centerY");
|
||||
this.centerZ = nbt.getInteger("centerZ");
|
||||
this.spanF = nbt.getInteger("spanF");
|
||||
this.spanB = nbt.getInteger("spanB");
|
||||
this.spanL = nbt.getInteger("spanL");
|
||||
this.spanR = nbt.getInteger("spanR");
|
||||
this.height = nbt.getInteger("height");
|
||||
}
|
||||
|
||||
public void setTarget(int x, int y, int z) {
|
||||
this.centerX = x;
|
||||
this.centerY = y + 5;
|
||||
this.centerZ = z;
|
||||
|
||||
this.spanF = 7;
|
||||
this.spanB = 7;
|
||||
this.spanL = 7;
|
||||
this.spanR = 7;
|
||||
|
||||
this.height = 7;
|
||||
this.setUpCrane = true;
|
||||
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return AxisAlignedBB.getBoundingBox(xCoord - 1.5, yCoord, zCoord - 1.5, xCoord + 2.5, yCoord + 1.5, zCoord + 2.5);
|
||||
return this.INFINITE_EXTENT_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
4188
src/main/resources/assets/hbm/models/rbmk/crane.obj
Normal file
4188
src/main/resources/assets/hbm/models/rbmk/crane.obj
Normal file
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 134 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.8 KiB |
Loading…
x
Reference in New Issue
Block a user