This commit is contained in:
Boblet 2025-03-17 17:00:12 +01:00
commit 360daaa524
7 changed files with 112 additions and 82 deletions

View File

@ -26,6 +26,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
public boolean enableHUD = true; public boolean enableHUD = true;
public boolean enableBackpack = true; public boolean enableBackpack = true;
public boolean enableMagnet = true;
private boolean[] keysPressed = new boolean[EnumKeybind.values().length]; private boolean[] keysPressed = new boolean[EnumKeybind.values().length];
@ -71,6 +72,10 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
return this.enableBackpack && getKeyPressed(EnumKeybind.JETPACK); return this.enableBackpack && getKeyPressed(EnumKeybind.JETPACK);
} }
public boolean isMagnetActive(){
return this.enableMagnet;
}
public void setKeyPressed(EnumKeybind key, boolean pressed) { public void setKeyPressed(EnumKeybind key, boolean pressed) {
if(!getKeyPressed(key) && pressed) { if(!getKeyPressed(key) && pressed) {
@ -86,6 +91,16 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
MainRegistry.proxy.displayTooltip(EnumChatFormatting.RED + "Jetpack OFF", MainRegistry.proxy.ID_JETPACK); MainRegistry.proxy.displayTooltip(EnumChatFormatting.RED + "Jetpack OFF", MainRegistry.proxy.ID_JETPACK);
} }
} }
if (key == EnumKeybind.TOGGLE_MAGNET){
if (!player.worldObj.isRemote){
this.enableMagnet = !this.enableMagnet;
if(this.enableMagnet)
MainRegistry.proxy.displayTooltip(EnumChatFormatting.GREEN + "Magnet ON", MainRegistry.proxy.ID_MAGNET);
else
MainRegistry.proxy.displayTooltip(EnumChatFormatting.RED + "Magnet OFF", MainRegistry.proxy.ID_MAGNET);
}
}
if(key == EnumKeybind.TOGGLE_HEAD) { if(key == EnumKeybind.TOGGLE_HEAD) {
if(!player.worldObj.isRemote) { if(!player.worldObj.isRemote) {
@ -174,6 +189,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
buf.writeBoolean(this.enableHUD); buf.writeBoolean(this.enableHUD);
buf.writeInt(this.reputation); buf.writeInt(this.reputation);
buf.writeBoolean(this.isOnLadder); buf.writeBoolean(this.isOnLadder);
buf.writeBoolean(this.enableMagnet);
} }
public void deserialize(ByteBuf buf) { public void deserialize(ByteBuf buf) {
@ -185,6 +201,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
this.enableHUD = buf.readBoolean(); this.enableHUD = buf.readBoolean();
this.reputation = buf.readInt(); this.reputation = buf.readInt();
this.isOnLadder = buf.readBoolean(); this.isOnLadder = buf.readBoolean();
this.enableMagnet = buf.readBoolean();
} }
} }
@ -198,6 +215,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
props.setFloat("shield", shield); props.setFloat("shield", shield);
props.setFloat("maxShield", maxShield); props.setFloat("maxShield", maxShield);
props.setBoolean("enableBackpack", enableBackpack); props.setBoolean("enableBackpack", enableBackpack);
props.setBoolean("enableMagnet", enableMagnet);
props.setBoolean("enableHUD", enableHUD); props.setBoolean("enableHUD", enableHUD);
props.setInteger("reputation", reputation); props.setInteger("reputation", reputation);
props.setBoolean("isOnLadder", isOnLadder); props.setBoolean("isOnLadder", isOnLadder);
@ -216,6 +234,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
this.shield = props.getFloat("shield"); this.shield = props.getFloat("shield");
this.maxShield = props.getFloat("maxShield"); this.maxShield = props.getFloat("maxShield");
this.enableBackpack = props.getBoolean("enableBackpack"); this.enableBackpack = props.getBoolean("enableBackpack");
this.enableMagnet = props.getBoolean("enableMagnet");
this.enableHUD = props.getBoolean("enableHUD"); this.enableHUD = props.getBoolean("enableHUD");
this.reputation = props.getInteger("reputation"); this.reputation = props.getInteger("reputation");
this.isOnLadder = props.getBoolean("isOnLadder"); this.isOnLadder = props.getBoolean("isOnLadder");

View File

@ -22,6 +22,7 @@ public class HbmKeybinds {
public static KeyBinding calculatorKey = new KeyBinding(category + ".calculator", Keyboard.KEY_N, category); public static KeyBinding calculatorKey = new KeyBinding(category + ".calculator", Keyboard.KEY_N, category);
public static KeyBinding jetpackKey = new KeyBinding(category + ".toggleBack", Keyboard.KEY_C, category); public static KeyBinding jetpackKey = new KeyBinding(category + ".toggleBack", Keyboard.KEY_C, category);
public static KeyBinding magnetKey = new KeyBinding(category + ".toggleMagnet", Keyboard.KEY_Z, category);
public static KeyBinding hudKey = new KeyBinding(category + ".toggleHUD", Keyboard.KEY_V, category); public static KeyBinding hudKey = new KeyBinding(category + ".toggleHUD", Keyboard.KEY_V, category);
public static KeyBinding dashKey = new KeyBinding(category + ".dash", Keyboard.KEY_LSHIFT, category); public static KeyBinding dashKey = new KeyBinding(category + ".dash", Keyboard.KEY_LSHIFT, category);
public static KeyBinding trainKey = new KeyBinding(category + ".trainInv", Keyboard.KEY_R, category); public static KeyBinding trainKey = new KeyBinding(category + ".trainInv", Keyboard.KEY_R, category);
@ -43,6 +44,7 @@ public class HbmKeybinds {
public static void register() { public static void register() {
ClientRegistry.registerKeyBinding(calculatorKey); ClientRegistry.registerKeyBinding(calculatorKey);
ClientRegistry.registerKeyBinding(jetpackKey); ClientRegistry.registerKeyBinding(jetpackKey);
ClientRegistry.registerKeyBinding(magnetKey);
ClientRegistry.registerKeyBinding(hudKey); ClientRegistry.registerKeyBinding(hudKey);
ClientRegistry.registerKeyBinding(dashKey); ClientRegistry.registerKeyBinding(dashKey);
ClientRegistry.registerKeyBinding(trainKey); ClientRegistry.registerKeyBinding(trainKey);
@ -98,6 +100,7 @@ public class HbmKeybinds {
public static enum EnumKeybind { public static enum EnumKeybind {
JETPACK, JETPACK,
TOGGLE_JETPACK, TOGGLE_JETPACK,
TOGGLE_MAGNET,
TOGGLE_HEAD, TOGGLE_HEAD,
DASH, DASH,
TRAIN, TRAIN,

View File

@ -2,6 +2,7 @@ package com.hbm.items.armor;
import java.util.List; import java.util.List;
import com.hbm.extprop.HbmPlayerProps;
import com.hbm.handler.ArmorModHandler; import com.hbm.handler.ArmorModHandler;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@ -36,7 +37,10 @@ public class ItemModLodestone extends ItemArmorMod {
@Override @Override
public void modUpdate(EntityLivingBase entity, ItemStack armor) { public void modUpdate(EntityLivingBase entity, ItemStack armor) {
// No magnet if keybind toggled
if (entity instanceof EntityPlayer && !HbmPlayerProps.getData((EntityPlayer) entity).isMagnetActive()) return;
List<EntityItem> items = entity.worldObj.getEntitiesWithinAABB(EntityItem.class, entity.boundingBox.expand(range, range, range)); List<EntityItem> items = entity.worldObj.getEntitiesWithinAABB(EntityItem.class, entity.boundingBox.expand(range, range, range));
for(EntityItem item : items) { for(EntityItem item : items) {

View File

@ -2038,6 +2038,7 @@ public class ClientProxy extends ServerProxy {
switch(key){ switch(key){
case JETPACK: return Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed(); case JETPACK: return Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed();
case TOGGLE_JETPACK: return HbmKeybinds.jetpackKey.getIsKeyPressed(); case TOGGLE_JETPACK: return HbmKeybinds.jetpackKey.getIsKeyPressed();
case TOGGLE_MAGNET: return HbmKeybinds.magnetKey.getIsKeyPressed();
case TOGGLE_HEAD: return HbmKeybinds.hudKey.getIsKeyPressed(); case TOGGLE_HEAD: return HbmKeybinds.hudKey.getIsKeyPressed();
case RELOAD: return HbmKeybinds.reloadKey.getIsKeyPressed(); case RELOAD: return HbmKeybinds.reloadKey.getIsKeyPressed();
case DASH: return HbmKeybinds.dashKey.getIsKeyPressed(); case DASH: return HbmKeybinds.dashKey.getIsKeyPressed();

View File

@ -21,12 +21,13 @@ public class ServerProxy {
public static final int ID_CABLE = 3; public static final int ID_CABLE = 3;
public static final int ID_DRONE = 4; public static final int ID_DRONE = 4;
public static final int ID_JETPACK = 5; public static final int ID_JETPACK = 5;
public static final int ID_HUD = 6; public static final int ID_MAGNET = 6;
public static final int ID_DETONATOR = 7; public static final int ID_HUD = 7;
public static final int ID_FLUID_ID = 8; public static final int ID_DETONATOR = 8;
public static final int ID_TOOLABILITY = 9; public static final int ID_FLUID_ID = 9;
public static final int ID_GUN_MODE = 10; public static final int ID_TOOLABILITY = 10;
public static final int ID_GAS_HAZARD = 11; public static final int ID_GUN_MODE = 11;
public static final int ID_GAS_HAZARD = 12;
public void registerPreRenderInfo() { } public void registerPreRenderInfo() { }
public void registerRenderInfo() { } public void registerRenderInfo() { }

View File

@ -14,7 +14,7 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
public abstract class RenderPylonBase extends TileEntitySpecialRenderer { public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
/** /**
* The closest we have to a does-all solution. It will figure out if it needs to draw multiple lines, * The closest we have to a does-all solution. It will figure out if it needs to draw multiple lines,
* iterate through all the mounting points, try to find the matching mounting points and then draw the lines. * iterate through all the mounting points, try to find the matching mounting points and then draw the lines.
@ -24,27 +24,25 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
* @param z * @param z
*/ */
public void renderLinesGeneric(TileEntityPylonBase pyl, double x, double y, double z) { public void renderLinesGeneric(TileEntityPylonBase pyl, double x, double y, double z) {
this.bindTexture(pyl.color == 0 ? ResourceManager.wire_tex : ResourceManager.wire_greyscale_tex);
for(int i = 0; i < pyl.connected.size(); i++) {
int[] wire = pyl.connected.get(i); this.bindTexture(pyl.color == 0 ? ResourceManager.wire_tex : ResourceManager.wire_greyscale_tex);
pyl.getConnected().forEach(wire -> {
TileEntity tile = pyl.getWorldObj().getTileEntity(wire[0], wire[1], wire[2]); TileEntity tile = pyl.getWorldObj().getTileEntity(wire[0], wire[1], wire[2]);
if(tile instanceof TileEntityPylonBase) { if(tile instanceof TileEntityPylonBase) {
TileEntityPylonBase pylon = (TileEntityPylonBase) tile; TileEntityPylonBase pylon = (TileEntityPylonBase) tile;
Vec3[] m1 = pyl.getMountPos(); Vec3[] m1 = pyl.getMountPos();
Vec3[] m2 = pylon.getMountPos(); Vec3[] m2 = pylon.getMountPos();
int lineCount = Math.min(m1.length, m2.length); int lineCount = Math.min(m1.length, m2.length);
for(int line = 0; line < lineCount; line++) { for(int line = 0; line < lineCount; line++) {
Vec3 first = m1[line % m1.length]; Vec3 first = m1[line % m1.length];
int secondIndex = line % m2.length; int secondIndex = line % m2.length;
/* /*
* hacky hacky hack * hacky hacky hack
* this will shift the mount point order by 2 to prevent wires from crossing * this will shift the mount point order by 2 to prevent wires from crossing
@ -55,17 +53,17 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
if(lineCount == 4 && ( if(lineCount == 4 && (
(pyl.getBlockMetadata() - 10 == 5 && pylon.getBlockMetadata() - 10 == 2) || (pyl.getBlockMetadata() - 10 == 5 && pylon.getBlockMetadata() - 10 == 2) ||
(pyl.getBlockMetadata() - 10 == 2 && pylon.getBlockMetadata() - 10 == 5))) { (pyl.getBlockMetadata() - 10 == 2 && pylon.getBlockMetadata() - 10 == 5))) {
secondIndex += 2; secondIndex += 2;
secondIndex %= m2.length; secondIndex %= m2.length;
} }
Vec3 second = m2[secondIndex]; Vec3 second = m2[secondIndex];
double sX = second.xCoord + pylon.xCoord - pyl.xCoord; double sX = second.xCoord + pylon.xCoord - pyl.xCoord;
double sY = second.yCoord + pylon.yCoord - pyl.yCoord; double sY = second.yCoord + pylon.yCoord - pyl.yCoord;
double sZ = second.zCoord + pylon.zCoord - pyl.zCoord; double sZ = second.zCoord + pylon.zCoord - pyl.zCoord;
renderLine(pyl.getWorldObj(), pyl, x, y, z, renderLine(pyl.getWorldObj(), pyl, x, y, z,
first.xCoord, first.xCoord,
first.yCoord, first.yCoord,
@ -75,9 +73,9 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
first.zCoord + (sZ - first.zCoord) * 0.5); first.zCoord + (sZ - first.zCoord) * 0.5);
} }
} }
} });
} }
/** /**
* Renders half a line * Renders half a line
* First coords: the relative render position * First coords: the relative render position
@ -101,12 +99,12 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
GL11.glTranslated(x, y, z); GL11.glTranslated(x, y, z);
float count = 10; float count = 10;
Tessellator tess = Tessellator.instance; Tessellator tess = Tessellator.instance;
GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_CULL_FACE);
tess.startDrawingQuads(); tess.startDrawingQuads();
Vec3 delta = Vec3.createVectorHelper(x0 - x1, y0 - y1, z0 - z1); Vec3 delta = Vec3.createVectorHelper(x0 - x1, y0 - y1, z0 - z1);
double girth = 0.03125D; double girth = 0.03125D;
double hyp = Math.sqrt(delta.xCoord * delta.xCoord + delta.zCoord * delta.zCoord); double hyp = Math.sqrt(delta.xCoord * delta.xCoord + delta.zCoord * delta.zCoord);
double yaw = Math.atan2(delta.xCoord, delta.zCoord); double yaw = Math.atan2(delta.xCoord, delta.zCoord);
@ -124,31 +122,31 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
tess.setColorOpaque_I(pyl.color == 0 ? 0xffffff : pyl.color); tess.setColorOpaque_I(pyl.color == 0 ? 0xffffff : pyl.color);
drawLineSegment(tess, x0, y0, z0, x1, y1, z1, iX, iY, iZ, jX, jZ); drawLineSegment(tess, x0, y0, z0, x1, y1, z1, iX, iY, iZ, jX, jZ);
} else { } else {
double hang = Math.min(delta.lengthVector() / 15D, 2.5D); double hang = Math.min(delta.lengthVector() / 15D, 2.5D);
for(float j = 0; j < count; j++) { for(float j = 0; j < count; j++) {
float k = j + 1; float k = j + 1;
double sagJ = Math.sin(j / count * Math.PI * 0.5) * hang; double sagJ = Math.sin(j / count * Math.PI * 0.5) * hang;
double sagK = Math.sin(k / count * Math.PI * 0.5) * hang; double sagK = Math.sin(k / count * Math.PI * 0.5) * hang;
double sagMean = (sagJ + sagK) / 2D; double sagMean = (sagJ + sagK) / 2D;
double deltaX = x1 - x0; double deltaX = x1 - x0;
double deltaY = y1 - y0; double deltaY = y1 - y0;
double deltaZ = z1 - z0; double deltaZ = z1 - z0;
double ja = j + 0.5D; double ja = j + 0.5D;
double ix = pyl.xCoord + x0 + deltaX / (double)(count) * ja; double ix = pyl.xCoord + x0 + deltaX / (double)(count) * ja;
double iy = pyl.yCoord + y0 + deltaY / (double)(count) * ja - sagMean; double iy = pyl.yCoord + y0 + deltaY / (double)(count) * ja - sagMean;
double iz = pyl.zCoord + z0 + deltaZ / (double)(count) * ja; double iz = pyl.zCoord + z0 + deltaZ / (double)(count) * ja;
int brightness = world.getLightBrightnessForSkyBlocks(MathHelper.floor_double(ix), MathHelper.floor_double(iy), MathHelper.floor_double(iz), 0); int brightness = world.getLightBrightnessForSkyBlocks(MathHelper.floor_double(ix), MathHelper.floor_double(iy), MathHelper.floor_double(iz), 0);
tess.setBrightness(brightness); tess.setBrightness(brightness);
tess.setColorOpaque_I(pyl.color == 0 ? 0xffffff : pyl.color); tess.setColorOpaque_I(pyl.color == 0 ? 0xffffff : pyl.color);
drawLineSegment(tess, drawLineSegment(tess,
x0 + (deltaX * j / count), x0 + (deltaX * j / count),
y0 + (deltaY * j / count) - sagJ, y0 + (deltaY * j / count) - sagJ,
@ -162,10 +160,10 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
tess.draw(); tess.draw();
GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
/** /**
* Draws a single segment from the first to the second 3D coordinate. * Draws a single segment from the first to the second 3D coordinate.
* Not fantastic but it looks good enough. * Not fantastic but it looks good enough.
@ -178,19 +176,19 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
* @param c * @param c
*/ */
public void drawLineSegment(Tessellator tessellator, double x, double y, double z, double a, double b, double c, double iX, double iY, double iZ, double jX, double jZ) { public void drawLineSegment(Tessellator tessellator, double x, double y, double z, double a, double b, double c, double iX, double iY, double iZ, double jX, double jZ) {
double deltaX = a - x; double deltaX = a - x;
double deltaY = b - y; double deltaY = b - y;
double deltaZ = c - z; double deltaZ = c - z;
double length = Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); double length = Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
int wrap = (int) Math.ceil(length * 8); int wrap = (int) Math.ceil(length * 8);
if(deltaX + deltaZ < 0) { if(deltaX + deltaZ < 0) {
wrap *= -1; wrap *= -1;
jZ *= -1; jZ *= -1;
jX *= -1; jX *= -1;
} }
tessellator.addVertexWithUV(x + iX, y + iY, z + iZ, 0, 0); tessellator.addVertexWithUV(x + iX, y + iY, z + iZ, 0, 0);
tessellator.addVertexWithUV(x - iX, y - iY, z - iZ, 0, 1); tessellator.addVertexWithUV(x - iX, y - iY, z - iZ, 0, 1);
tessellator.addVertexWithUV(a - iX, b - iY, c - iZ, wrap, 1); tessellator.addVertexWithUV(a - iX, b - iY, c - iZ, wrap, 1);
@ -200,6 +198,6 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
tessellator.addVertexWithUV(a - jX, b, c - jZ, wrap, 1); tessellator.addVertexWithUV(a - jX, b, c - jZ, wrap, 1);
tessellator.addVertexWithUV(a + jX, b, c + jZ, wrap, 0); tessellator.addVertexWithUV(a + jX, b, c + jZ, wrap, 0);
} }
public static final int LINE_COLOR = 0xBB3311; public static final int LINE_COLOR = 0xBB3311;
} }

View File

@ -23,45 +23,45 @@ import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public abstract class TileEntityPylonBase extends TileEntityCableBaseNT { public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
public List<int[]> connected = new ArrayList<int[]>(); protected List<int[]> connected = new ArrayList<>();
public int color; public int color;
public static int canConnect(TileEntityPylonBase first, TileEntityPylonBase second) { public static int canConnect(TileEntityPylonBase first, TileEntityPylonBase second) {
if(first.getConnectionType() != second.getConnectionType()) if(first.getConnectionType() != second.getConnectionType())
return 1; return 1;
if(first == second) if(first == second)
return 2; return 2;
double len = Math.min(first.getMaxWireLength(), second.getMaxWireLength()); double len = Math.min(first.getMaxWireLength(), second.getMaxWireLength());
Vec3 firstPos = first.getConnectionPoint(); Vec3 firstPos = first.getConnectionPoint();
Vec3 secondPos = second.getConnectionPoint(); Vec3 secondPos = second.getConnectionPoint();
Vec3 delta = Vec3.createVectorHelper( Vec3 delta = Vec3.createVectorHelper(
(secondPos.xCoord) - (firstPos.xCoord), (secondPos.xCoord) - (firstPos.xCoord),
(secondPos.yCoord) - (firstPos.yCoord), (secondPos.yCoord) - (firstPos.yCoord),
(secondPos.zCoord) - (firstPos.zCoord) (secondPos.zCoord) - (firstPos.zCoord)
); );
return len >= delta.lengthVector() ? 0 : 3; return len >= delta.lengthVector() ? 0 : 3;
} }
public boolean setColor(ItemStack stack) { public boolean setColor(ItemStack stack) {
if(stack == null) return false; if(stack == null) return false;
int color = ColorUtil.getColorFromDye(stack); int color = ColorUtil.getColorFromDye(stack);
if(color == 0 || color == this.color) return false; if(color == 0 || color == this.color) return false;
stack.stackSize--; stack.stackSize--;
this.color = color; this.color = color;
this.markDirty(); this.markDirty();
if(worldObj instanceof WorldServer) { if(worldObj instanceof WorldServer) {
WorldServer world = (WorldServer) worldObj; WorldServer world = (WorldServer) worldObj;
world.getPlayerManager().markBlockForUpdate(xCoord, yCoord, zCoord); world.getPlayerManager().markBlockForUpdate(xCoord, yCoord, zCoord);
} }
return true; return true;
} }
@ -72,91 +72,95 @@ public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
for(int[] pos : this.connected) node.addConnection(new DirPos(pos[0], pos[1], pos[2], ForgeDirection.UNKNOWN)); for(int[] pos : this.connected) node.addConnection(new DirPos(pos[0], pos[1], pos[2], ForgeDirection.UNKNOWN));
return node; return node;
} }
public void addConnection(int x, int y, int z) { public void addConnection(int x, int y, int z) {
connected.add(new int[] {x, y, z}); connected.add(new int[] {x, y, z});
PowerNode node = Nodespace.getNode(worldObj, xCoord, yCoord, zCoord); PowerNode node = Nodespace.getNode(worldObj, xCoord, yCoord, zCoord);
node.recentlyChanged = true; node.recentlyChanged = true;
node.addConnection(new DirPos(x, y, z, ForgeDirection.UNKNOWN)); node.addConnection(new DirPos(x, y, z, ForgeDirection.UNKNOWN));
this.markDirty(); this.markDirty();
if(worldObj instanceof WorldServer) { if(worldObj instanceof WorldServer) {
WorldServer world = (WorldServer) worldObj; WorldServer world = (WorldServer) worldObj;
world.getPlayerManager().markBlockForUpdate(xCoord, yCoord, zCoord); world.getPlayerManager().markBlockForUpdate(xCoord, yCoord, zCoord);
} }
} }
public void disconnectAll() { public void disconnectAll() {
for(int[] pos : connected) { for(int[] pos : connected) {
TileEntity te = worldObj.getTileEntity(pos[0], pos[1], pos[2]); TileEntity te = worldObj.getTileEntity(pos[0], pos[1], pos[2]);
if(te == this) if(te == this)
continue; continue;
if(te instanceof TileEntityPylonBase) { if(te instanceof TileEntityPylonBase) {
TileEntityPylonBase pylon = (TileEntityPylonBase) te; TileEntityPylonBase pylon = (TileEntityPylonBase) te;
Nodespace.destroyNode(worldObj, pos[0], pos[1], pos[2]); Nodespace.destroyNode(worldObj, pos[0], pos[1], pos[2]);
for(int i = 0; i < pylon.connected.size(); i++) { for(int i = 0; i < pylon.connected.size(); i++) {
int[] conPos = pylon.connected.get(i); int[] conPos = pylon.connected.get(i);
if(conPos[0] == xCoord && conPos[1] == yCoord && conPos[2] == zCoord) { if(conPos[0] == xCoord && conPos[1] == yCoord && conPos[2] == zCoord) {
pylon.connected.remove(i); pylon.connected.remove(i);
i--; i--;
} }
} }
pylon.markDirty(); pylon.markDirty();
if(worldObj instanceof WorldServer) { if(worldObj instanceof WorldServer) {
WorldServer world = (WorldServer) worldObj; WorldServer world = (WorldServer) worldObj;
world.getPlayerManager().markBlockForUpdate(pylon.xCoord, pylon.yCoord, pylon.zCoord); world.getPlayerManager().markBlockForUpdate(pylon.xCoord, pylon.yCoord, pylon.zCoord);
} }
} }
} }
Nodespace.destroyNode(worldObj, xCoord, yCoord, zCoord); Nodespace.destroyNode(worldObj, xCoord, yCoord, zCoord);
} }
public abstract ConnectionType getConnectionType(); public abstract ConnectionType getConnectionType();
public abstract Vec3[] getMountPos(); public abstract Vec3[] getMountPos();
public abstract double getMaxWireLength(); public abstract double getMaxWireLength();
public Vec3 getConnectionPoint() { public Vec3 getConnectionPoint() {
Vec3[] mounts = this.getMountPos(); Vec3[] mounts = this.getMountPos();
if(mounts == null || mounts.length == 0) if(mounts == null || mounts.length == 0)
return Vec3.createVectorHelper(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); return Vec3.createVectorHelper(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
return mounts[0].addVector(xCoord, yCoord, zCoord); return mounts[0].addVector(xCoord, yCoord, zCoord);
} }
public List<int[]> getConnected() {
return connected;
}
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setInteger("conCount", connected.size()); nbt.setInteger("conCount", connected.size());
nbt.setInteger("color", color); nbt.setInteger("color", color);
for(int i = 0; i < connected.size(); i++) { for(int i = 0; i < connected.size(); i++) {
nbt.setIntArray("con" + i, connected.get(i)); nbt.setIntArray("con" + i, connected.get(i));
} }
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
int count = nbt.getInteger("conCount"); int count = nbt.getInteger("conCount");
this.color = nbt.getInteger("color"); this.color = nbt.getInteger("color");
this.connected.clear(); this.connected.clear();
for(int i = 0; i < count; i++) { for(int i = 0; i < count; i++) {
connected.add(nbt.getIntArray("con" + i)); connected.add(nbt.getIntArray("con" + i));
} }
@ -164,24 +168,24 @@ public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
@Override @Override
public Packet getDescriptionPacket() { public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound(); NBTTagCompound nbt = new NBTTagCompound();
this.writeToNBT(nbt); this.writeToNBT(nbt);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
} }
@Override @Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
this.readFromNBT(pkt.func_148857_g()); this.readFromNBT(pkt.func_148857_g());
} }
public static enum ConnectionType { public enum ConnectionType {
SINGLE, SINGLE,
TRIPLE, TRIPLE,
QUAD QUAD
//more to follow //more to follow
} }
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
return TileEntity.INFINITE_EXTENT_AABB; return TileEntity.INFINITE_EXTENT_AABB;