mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
fixed a lot of the new power garbage, better pylons
This commit is contained in:
parent
f39a6f9ca1
commit
fa78371f2b
@ -1,5 +1,10 @@
|
||||
package api.hbm.energy;
|
||||
|
||||
import com.hbm.packet.AuxParticlePacketNT;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@ -49,13 +54,23 @@ public interface IEnergyConnector {
|
||||
public default void trySubscribe(World world, int x, int y, int z) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
boolean red = false;
|
||||
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
IEnergyConductor con = (IEnergyConductor) te;
|
||||
|
||||
if(con.getPowerNet() != null && !con.getPowerNet().isSubscribed(this))
|
||||
con.getPowerNet().subscribe(this);
|
||||
|
||||
if(con.getPowerNet() != null)
|
||||
red = true;
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "vanillaExt");
|
||||
data.setString("mode", red ? "reddust" : "bluedust");
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, x + world.rand.nextDouble(), y + world.rand.nextDouble(), z + world.rand.nextDouble()), new TargetPoint(world.provider.dimensionId, x + 0.5, y + 0.5, z + 0.5, 25));
|
||||
}
|
||||
public default void tryUnsubscribe(World world, int x, int y, int z) {
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package api.hbm.energy;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
package api.hbm.energy;
|
||||
|
||||
import com.hbm.packet.AuxParticlePacketNT;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@ -47,6 +52,7 @@ public interface IEnergyUser extends IEnergyConnector {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
boolean wasSubscribed = false;
|
||||
boolean red = false;
|
||||
|
||||
// first we make sure we're not subscribed to the network that we'll be supplying
|
||||
if(te instanceof IEnergyConductor) {
|
||||
@ -66,6 +72,7 @@ public interface IEnergyUser extends IEnergyConnector {
|
||||
long oldPower = this.getPower();
|
||||
long transfer = oldPower - con.transferPower(oldPower);
|
||||
this.setPower(oldPower - transfer);
|
||||
red = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,6 +84,11 @@ public interface IEnergyUser extends IEnergyConnector {
|
||||
con.getPowerNet().subscribe(this);
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "vanillaExt");
|
||||
data.setString("mode", red ? "reddust" : "greendust");
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, x + world.rand.nextDouble(), y + world.rand.nextDouble(), z + world.rand.nextDouble()), new TargetPoint(world.provider.dimensionId, x + 0.5, y + 0.5, z + 0.5, 25));
|
||||
}
|
||||
|
||||
public default void updateStandardConnections(World world, int x, int y, int z) {
|
||||
|
||||
@ -1786,7 +1786,7 @@ public class ModBlocks {
|
||||
machine_powerrtg = new MachineMiniRTG(Material.iron).setBlockName("machine_powerrtg").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":rtg_polonium");
|
||||
|
||||
red_wire_coated = new WireCoated(Material.iron).setBlockName("red_wire_coated").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":red_wire_coated");
|
||||
red_cable = new BlockCable(Material.iron).setBlockName("red_cable").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":red_cable_icon");
|
||||
red_cable = new BlockCable(Material.iron).setBlockName("red_cable").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":cable_neo");
|
||||
rf_cable = new BlockRFCable(Material.iron).setBlockName("rf_cable").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":rf_cable_icon");
|
||||
red_pylon = new PylonRedWire(Material.iron).setBlockName("red_pylon").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":red_pylon");
|
||||
cable_switch = new CableSwitch(Material.iron).setBlockName("cable_switch").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":cable_switch_off");
|
||||
|
||||
@ -79,7 +79,7 @@ public class BlockBobble extends BlockContainer {
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,6 +169,7 @@ public class BlockBobble extends BlockContainer {
|
||||
PU238("Pu-238", "Pu-238", "Improved Tom impact mechanics", null, false),
|
||||
VT("VT-6/24", "VT-6/24", "Balefire warhead model and general texturework", "You cannot unfuck a horse.", true),
|
||||
DOC("The Doctor", "Doctor17PH", "Russian localization, lunar miner", "Perhaps the moon rocks were too expensive", true),
|
||||
BLUEHAT("The Blue Hat", "The Blue Hat", "Textures", "there's a listening device in this bobblehead$don't touch it thanks", true),
|
||||
//testing garbage. why is she so dumb?
|
||||
CIRNO("Cirno", "Cirno", "being a dumb ice fairy", "No brain. Head empty.", true);
|
||||
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.tileentity.conductor.TileEntityPylonRedWire;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PylonRedWire extends BlockContainer {
|
||||
|
||||
public PylonRedWire(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
return new TileEntityPylonRedWire();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType(){
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,11 +1,15 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.test.TestConductor;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.network.TileEntityCableBaseNT;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@ -36,4 +40,48 @@ public class BlockCable extends BlockContainer {
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
|
||||
boolean posX = Library.canConnect(world, x + 1, y, z, Library.POS_X);
|
||||
boolean negX = Library.canConnect(world, x - 1, y, z, Library.NEG_X);
|
||||
boolean posY = Library.canConnect(world, x, y + 1, z, Library.POS_Y);
|
||||
boolean negY = Library.canConnect(world, x, y - 1, z, Library.NEG_Y);
|
||||
boolean posZ = Library.canConnect(world, x, y, z + 1, Library.POS_Z);
|
||||
boolean negZ = Library.canConnect(world, x, y, z - 1, Library.NEG_Z);
|
||||
|
||||
setBlockBounds(posX, negX, posY, negY, posZ, negZ);
|
||||
|
||||
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||
|
||||
boolean posX = Library.canConnect(world, x + 1, y, z, Library.POS_X);
|
||||
boolean negX = Library.canConnect(world, x - 1, y, z, Library.NEG_X);
|
||||
boolean posY = Library.canConnect(world, x, y + 1, z, Library.POS_Y);
|
||||
boolean negY = Library.canConnect(world, x, y - 1, z, Library.NEG_Y);
|
||||
boolean posZ = Library.canConnect(world, x, y, z + 1, Library.POS_Z);
|
||||
boolean negZ = Library.canConnect(world, x, y, z - 1, Library.NEG_Z);
|
||||
|
||||
setBlockBounds(posX, negX, posY, negY, posZ, negZ);
|
||||
}
|
||||
|
||||
private void setBlockBounds(boolean posX, boolean negX, boolean posY, boolean negY, boolean posZ, boolean negZ) {
|
||||
|
||||
float pixel = 0.0625F;
|
||||
float min = pixel * 5.5F;
|
||||
float max = pixel * 10.5F;
|
||||
|
||||
float minX = negX ? 0F : min;
|
||||
float maxX = posX ? 1F : max;
|
||||
float minY = negY ? 0F : min;
|
||||
float maxY = posY ? 1F : max;
|
||||
float minZ = negZ ? 0F : min;
|
||||
float maxZ = posZ ? 1F : max;
|
||||
|
||||
this.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
}
|
||||
|
||||
43
src/main/java/com/hbm/blocks/network/PylonBase.java
Normal file
43
src/main/java/com/hbm/blocks/network/PylonBase.java
Normal file
@ -0,0 +1,43 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.tileentity.network.TileEntityPylonBase;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class PylonBase extends BlockContainer {
|
||||
|
||||
protected PylonBase(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block b, int m) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te instanceof TileEntityPylonBase) {
|
||||
((TileEntityPylonBase)te).disconnectAll();
|
||||
}
|
||||
|
||||
super.breakBlock(world, x, y, z, b, m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType(){
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
20
src/main/java/com/hbm/blocks/network/PylonRedWire.java
Normal file
20
src/main/java/com/hbm/blocks/network/PylonRedWire.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.hbm.blocks.network;
|
||||
|
||||
import com.hbm.tileentity.network.TileEntityPylon;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PylonRedWire extends PylonBase {
|
||||
|
||||
public PylonRedWire(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
return new TileEntityPylon();
|
||||
}
|
||||
}
|
||||
@ -5,9 +5,9 @@ import java.util.List;
|
||||
import com.hbm.interfaces.IFluidContainer;
|
||||
import com.hbm.interfaces.IFluidDuct;
|
||||
import com.hbm.inventory.FluidTank;
|
||||
import com.hbm.tileentity.conductor.TileEntityPylonRedWire;
|
||||
import com.hbm.tileentity.machine.TileEntityDummy;
|
||||
import com.hbm.tileentity.machine.TileEntityLockableBase;
|
||||
import com.hbm.tileentity.network.TileEntityPylon;
|
||||
|
||||
import api.hbm.energy.IEnergyConnector;
|
||||
import net.minecraft.block.Block;
|
||||
@ -95,7 +95,7 @@ public class ItemAnalyzer extends Item {
|
||||
"Duct Type: " + I18n.format(((IFluidDuct)te).getType().getUnlocalizedName())));
|
||||
}
|
||||
|
||||
if(te instanceof TileEntityPylonRedWire) {
|
||||
if(te instanceof TileEntityPylon) {
|
||||
|
||||
/**
|
||||
* this is a smoldering crater
|
||||
|
||||
@ -2,7 +2,7 @@ package com.hbm.items.tool;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.tileentity.conductor.TileEntityPylonRedWire;
|
||||
import com.hbm.tileentity.network.TileEntityPylonBase;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@ -15,12 +15,12 @@ import net.minecraft.world.World;
|
||||
public class ItemWiring extends Item {
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_,
|
||||
float p_77648_8_, float p_77648_9_, float p_77648_10_) {
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
|
||||
|
||||
if (!player.isSneaking()) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if (te != null && te instanceof TileEntityPylonRedWire) {
|
||||
if (te != null && te instanceof TileEntityPylonBase) {
|
||||
|
||||
if (stack.stackTagCompound == null) {
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
@ -29,33 +29,37 @@ public class ItemWiring extends Item {
|
||||
stack.stackTagCompound.setInteger("y", y);
|
||||
stack.stackTagCompound.setInteger("z", z);
|
||||
|
||||
if (world.isRemote)
|
||||
player.addChatMessage(new ChatComponentText(
|
||||
"Wire start"));
|
||||
} else {
|
||||
if(!world.isRemote) {
|
||||
player.addChatMessage(new ChatComponentText( "Wire start"));
|
||||
}
|
||||
} else if(!world.isRemote) {
|
||||
|
||||
int x1 = stack.stackTagCompound.getInteger("x");
|
||||
int y1 = stack.stackTagCompound.getInteger("y");
|
||||
int z1 = stack.stackTagCompound.getInteger("z");
|
||||
|
||||
if (world.getTileEntity(x1, y1, z1) != null && world.getTileEntity(x1, y1, z1) instanceof TileEntityPylonRedWire && this.isLengthValid(x, y, z, x1, y1, z1, 25)) {
|
||||
if (world.getTileEntity(x1, y1, z1) instanceof TileEntityPylonBase) {
|
||||
|
||||
TileEntityPylonRedWire first = (TileEntityPylonRedWire) world.getTileEntity(x1, y1, z1);
|
||||
TileEntityPylonRedWire second = ((TileEntityPylonRedWire) te);
|
||||
TileEntityPylonBase first = (TileEntityPylonBase) world.getTileEntity(x1, y1, z1);
|
||||
TileEntityPylonBase second = ((TileEntityPylonBase) te);
|
||||
|
||||
first.addTileEntityBasedOnCoords(x, y, z);
|
||||
second.addTileEntityBasedOnCoords(x1, y1, z1);
|
||||
first.markDirty();
|
||||
second.markDirty();
|
||||
|
||||
if (world.isRemote)
|
||||
player.addChatMessage(
|
||||
new ChatComponentText("Wire end"));
|
||||
if(TileEntityPylonBase.canConnect(first, second)) {
|
||||
|
||||
first.addConnection(x, y, z);
|
||||
second.addConnection(x1, y1, z1);
|
||||
player.addChatMessage(new ChatComponentText("Wire end"));
|
||||
|
||||
} else {
|
||||
player.addChatMessage(new ChatComponentText("Wire error"));
|
||||
}
|
||||
|
||||
stack.stackTagCompound = null;
|
||||
|
||||
} else {
|
||||
if (world.isRemote)
|
||||
player.addChatMessage(new ChatComponentText(
|
||||
"Wire error"));
|
||||
|
||||
if(!world.isRemote) {
|
||||
player.addChatMessage(new ChatComponentText("Wire error"));
|
||||
}
|
||||
stack.stackTagCompound = null;
|
||||
}
|
||||
}
|
||||
@ -78,11 +82,4 @@ public class ItemWiring extends Item {
|
||||
list.add("Right-click poles to connect");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLengthValid(int x1, int y1, int z1, int x2, int y2, int z2, int length) {
|
||||
double l = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2) + Math.pow(z2 - z1, 2));
|
||||
|
||||
return l <= length;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,10 +22,10 @@ import com.hbm.tileentity.conductor.TileEntityGasDuct;
|
||||
import com.hbm.tileentity.conductor.TileEntityGasDuctSolid;
|
||||
import com.hbm.tileentity.conductor.TileEntityOilDuct;
|
||||
import com.hbm.tileentity.conductor.TileEntityOilDuctSolid;
|
||||
import com.hbm.tileentity.conductor.TileEntityPylonRedWire;
|
||||
import com.hbm.tileentity.machine.TileEntityDummy;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineBattery;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineTransformer;
|
||||
import com.hbm.tileentity.network.TileEntityPylon;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyConnector;
|
||||
@ -119,7 +119,7 @@ public class Library {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(te instanceof IEnergyConnectorBlock) {
|
||||
if(te instanceof IEnergyConnector) {
|
||||
IEnergyConnector con = (IEnergyConnector) te;
|
||||
|
||||
if(con.canConnect(dir))
|
||||
|
||||
@ -86,6 +86,7 @@ import com.hbm.tileentity.machine.oil.TileEntityMachinePumpjack;
|
||||
import com.hbm.tileentity.machine.oil.TileEntityMachineRefinery;
|
||||
import com.hbm.tileentity.machine.oil.TileEntitySpacer;
|
||||
import com.hbm.tileentity.machine.rbmk.*;
|
||||
import com.hbm.tileentity.network.TileEntityPylon;
|
||||
import com.hbm.tileentity.turret.*;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
@ -234,7 +235,7 @@ public class ClientProxy extends ServerProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityGasDuct.class, new RenderGasDuct());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFluidDuct.class, new RenderFluidDuct());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRFDuct.class, new RenderRFCable());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPylonRedWire.class, new RenderPylon());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPylon.class, new RenderPylon());
|
||||
//multiblocks
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityStructureMarker.class, new RenderStructureMaker());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMultiblock.class, new RenderMultiblock());
|
||||
|
||||
@ -16,9 +16,9 @@ public class PacketDispatcher {
|
||||
int i = 0;
|
||||
|
||||
//Packet sent for every connected electricity pole, for wire rendering
|
||||
wrapper.registerMessage(TEPylonSenderPacket.Handler.class, TEPylonSenderPacket.class, i++, Side.CLIENT);
|
||||
//wrapper.registerMessage(TEPylonSenderPacket.Handler.class, TEPylonSenderPacket.class, i++, Side.CLIENT);
|
||||
//Resets connection list in client-sided pole rendering
|
||||
wrapper.registerMessage(TEPylonDestructorPacket.Handler.class, TEPylonDestructorPacket.class, i++, Side.CLIENT);
|
||||
//wrapper.registerMessage(TEPylonDestructorPacket.Handler.class, TEPylonDestructorPacket.class, i++, Side.CLIENT);
|
||||
//Machine type for marker rendering
|
||||
wrapper.registerMessage(TEStructurePacket.Handler.class, TEStructurePacket.class, i++, Side.CLIENT);
|
||||
//Mining drill rotation for rendering
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
package com.hbm.packet;
|
||||
|
||||
import com.hbm.tileentity.conductor.TileEntityPylonRedWire;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TEPylonDestructorPacket implements IMessage {
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
|
||||
public TEPylonDestructorPacket()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TEPylonDestructorPacket(int x, int y, int z)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<TEPylonDestructorPacket, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(TEPylonDestructorPacket m, MessageContext ctx) {
|
||||
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
|
||||
|
||||
if (te != null && te instanceof TileEntityPylonRedWire) {
|
||||
|
||||
TileEntityPylonRedWire pyl = (TileEntityPylonRedWire) te;
|
||||
pyl.connected.clear();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,77 +0,0 @@
|
||||
package com.hbm.packet;
|
||||
|
||||
import com.hbm.tileentity.conductor.TileEntityPylonRedWire;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TEPylonSenderPacket implements IMessage {
|
||||
|
||||
//Pylon connection synchronization packet, Mk.III
|
||||
//1: try sending list, every entry gets noted in the bit buffer
|
||||
//2: Up to 3 entries (9 variables in total, not counting origin coordiantes) sync all connections at once
|
||||
//3: One packet sent for each connection, packets are lighter and work fine for rendering
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
int conX;
|
||||
int conY;
|
||||
int conZ;
|
||||
|
||||
public TEPylonSenderPacket()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TEPylonSenderPacket(int x, int y, int z, int conX, int conY, int conZ)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.conX = conX;
|
||||
this.conY = conY;
|
||||
this.conZ = conZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
conX = buf.readInt();
|
||||
conY = buf.readInt();
|
||||
conZ = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(conX);
|
||||
buf.writeInt(conY);
|
||||
buf.writeInt(conZ);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<TEPylonSenderPacket, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(TEPylonSenderPacket m, MessageContext ctx) {
|
||||
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
|
||||
|
||||
try {
|
||||
if (te != null && te instanceof TileEntityPylonRedWire) {
|
||||
|
||||
TileEntityPylonRedWire pyl = (TileEntityPylonRedWire) te;
|
||||
pyl.addTileEntityBasedOnCoords(m.conX, m.conY, m.conZ);
|
||||
}
|
||||
} catch(Exception x) {}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -32,6 +32,7 @@ public class RenderBobble extends TileEntitySpecialRenderer {
|
||||
public static final ResourceLocation bobble_frizzle = new ResourceLocation(RefStrings.MODID, "textures/models/trinkets/frizzle.png");
|
||||
public static final ResourceLocation bobble_vt = new ResourceLocation(RefStrings.MODID, "textures/models/trinkets/vt.png");
|
||||
public static final ResourceLocation bobble_doc = new ResourceLocation(RefStrings.MODID, "textures/models/trinkets/doctor17ph.png");
|
||||
public static final ResourceLocation bobble_blue = new ResourceLocation(RefStrings.MODID, "textures/models/trinkets/thebluehat.png");
|
||||
public static final ResourceLocation bobble_cirno = new ResourceLocation(RefStrings.MODID, "textures/models/trinkets/cirno.png");
|
||||
|
||||
@Override
|
||||
@ -57,9 +58,7 @@ public class RenderBobble extends TileEntitySpecialRenderer {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
TextureManager texman = Minecraft.getMinecraft().getTextureManager();
|
||||
|
||||
texman.bindTexture(socket);
|
||||
bindTexture(socket);
|
||||
bobble.renderPart("Socket");
|
||||
|
||||
switch(type) {
|
||||
@ -69,15 +68,16 @@ public class RenderBobble extends TileEntitySpecialRenderer {
|
||||
case CHARISMA:
|
||||
case INTELLIGENCE:
|
||||
case AGILITY:
|
||||
case LUCK: texman.bindTexture(bobble_vaultboy); break;
|
||||
case LUCK: bindTexture(bobble_vaultboy); break;
|
||||
|
||||
case BOB: texman.bindTexture(bobble_hbm); break;
|
||||
case PU238: texman.bindTexture(bobble_pu238); break;
|
||||
case FRIZZLE: texman.bindTexture(bobble_frizzle); break;
|
||||
case VT: texman.bindTexture(bobble_vt); break;
|
||||
case DOC: texman.bindTexture(bobble_doc); break;
|
||||
case CIRNO: texman.bindTexture(bobble_cirno); break;
|
||||
default: texman.bindTexture(ResourceManager.universal);
|
||||
case BOB: bindTexture(bobble_hbm); break;
|
||||
case PU238: bindTexture(bobble_pu238); break;
|
||||
case FRIZZLE: bindTexture(bobble_frizzle); break;
|
||||
case VT: bindTexture(bobble_vt); break;
|
||||
case DOC: bindTexture(bobble_doc); break;
|
||||
case BLUEHAT: bindTexture(bobble_blue); break;
|
||||
case CIRNO: bindTexture(bobble_cirno); break;
|
||||
default: bindTexture(ResourceManager.universal);
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
@ -85,6 +85,10 @@ public class RenderBobble extends TileEntitySpecialRenderer {
|
||||
default: renderGuy(type);
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
renderPost(type);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
renderSocket(type);
|
||||
}
|
||||
|
||||
@ -157,6 +161,9 @@ public class RenderBobble extends TileEntitySpecialRenderer {
|
||||
rotLeftLeg = new double[]{2, 0, 0};
|
||||
rotRightLeg = new double[]{-2, 0, 0};
|
||||
break;
|
||||
case BLUEHAT:
|
||||
rotLeftArm = new double[]{0, 90, 60};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,6 +285,24 @@ public class RenderBobble extends TileEntitySpecialRenderer {
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
/*
|
||||
* RENDER ADDITIONAL ITEMS
|
||||
*/
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public void renderPost(BobbleType type) {
|
||||
switch(type) {
|
||||
case BLUEHAT:
|
||||
double scale = 0.0625D;
|
||||
GL11.glTranslated(0D, 0.875D, -0.5D);
|
||||
GL11.glRotated(-90, 0, 1, 0);
|
||||
GL11.glRotated(-160, 0, 0, 1);
|
||||
GL11.glScaled(scale, scale, scale);
|
||||
bindTexture(ResourceManager.hev_helmet);
|
||||
ResourceManager.armor_hev.renderPart("Head");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void renderOrigin() {
|
||||
|
||||
@ -344,4 +369,8 @@ public class RenderBobble extends TileEntitySpecialRenderer {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindTexture(ResourceLocation loc) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(loc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.ModEventHandler;
|
||||
import com.hbm.render.model.ModelPylon;
|
||||
import com.hbm.tileentity.conductor.TileEntityPylonRedWire;
|
||||
import com.hbm.tileentity.network.TileEntityPylon;
|
||||
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@ -28,7 +28,7 @@ public class RenderPylon extends TileEntitySpecialRenderer {
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
|
||||
TileEntityPylonRedWire pyl = (TileEntityPylonRedWire)te;
|
||||
TileEntityPylon pyl = (TileEntityPylon)te;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F - ((1F / 16F) * 14F), (float) z + 0.5F);
|
||||
GL11.glRotatef(180, 0F, 0F, 1F);
|
||||
|
||||
@ -73,7 +73,7 @@ public class TileMappings {
|
||||
put(TileEntityGasDuct.class, "tileentity_gas_duct");
|
||||
put(TileEntityGasDuctSolid.class, "tileentity_gas_duct_solid");
|
||||
put(TileEntityMachineRTG.class, "tileentity_machine_rtg");
|
||||
put(TileEntityPylonRedWire.class, "tileentity_pylon_redwire");
|
||||
put(TileEntityPylon.class, "tileentity_pylon_redwire");
|
||||
put(TileEntityStructureMarker.class, "tileentity_structure_marker");
|
||||
put(TileEntityMachineMiningDrill.class, "tileentity_mining_drill");
|
||||
put(TileEntityMachineAssembler.class, "tileentity_assembly_machine");
|
||||
|
||||
@ -1,176 +0,0 @@
|
||||
package com.hbm.tileentity.conductor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.interfaces.Spaghetti;
|
||||
import com.hbm.interfaces.Untested;
|
||||
import com.hbm.packet.NBTPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.TEPylonDestructorPacket;
|
||||
import com.hbm.packet.TEPylonSenderPacket;
|
||||
import com.hbm.tileentity.INBTPacketReceiver;
|
||||
import com.hbm.tileentity.network.TileEntityCableBaseNT;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityPylonRedWire extends TileEntityCableBaseNT implements INBTPacketReceiver {
|
||||
|
||||
public List<int[]> connected = new ArrayList<int[]>();
|
||||
public boolean scheduleConnectionCheck = false;
|
||||
public int[][] scheduleBuffer;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
for(int i = connected.size() - 1; i >= 0; i--) {
|
||||
|
||||
int[] con = connected.get(i);
|
||||
|
||||
if(con == null) {
|
||||
connected.remove(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
TileEntity pylon = worldObj.getTileEntity(con[0], con[1], con[2]);
|
||||
|
||||
if(worldObj.blockExists(con[0], con[1], con[2]) && (pylon == null || pylon.isInvalid())) {
|
||||
connected.remove(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(scheduleConnectionCheck && this.scheduleBuffer != null) {
|
||||
scheduleConnectionCheck = false;
|
||||
this.connected = convertArrayToList(this.scheduleBuffer, worldObj);
|
||||
}
|
||||
|
||||
if(worldObj.getTotalWorldTime() % 10 == 0) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setInteger("count", this.connected.size());
|
||||
|
||||
for(int i = 0; i < connected.size(); i++) {
|
||||
|
||||
int[] pos = connected.get(i);
|
||||
|
||||
TileEntity te = worldObj.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
|
||||
if(te instanceof TileEntityPylonRedWire) {
|
||||
data.setIntArray("c" + i, new int[] { pos[0], pos[1], pos[2] });
|
||||
}
|
||||
}
|
||||
|
||||
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(data, xCoord, yCoord, zCoord), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
|
||||
this.connected.clear();
|
||||
|
||||
int count = nbt.getInteger("count");
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
|
||||
if(nbt.hasKey("c" + i)) {
|
||||
int[] pos = nbt.getIntArray("c" + i);
|
||||
this.connected.add(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
int[] conX = nbt.getIntArray("conX");
|
||||
int[] conY = nbt.getIntArray("conY");
|
||||
int[] conZ = nbt.getIntArray("conZ");
|
||||
|
||||
int[][] con = new int[conX.length][3];
|
||||
|
||||
for(int i = 0; i < conX.length; i++) {
|
||||
con[i][0] = conX[i];
|
||||
con[i][1] = conY[i];
|
||||
con[i][2] = conZ[i];
|
||||
}
|
||||
|
||||
scheduleConnectionCheck = true;
|
||||
scheduleBuffer = con;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
int[][] con = TileEntityPylonRedWire.convertListToArray(connected);
|
||||
|
||||
int[] conX = new int[con.length];
|
||||
int[] conY = new int[con.length];
|
||||
int[] conZ = new int[con.length];
|
||||
|
||||
for(int i = 0; i < conX.length; i++) {
|
||||
conX[i] = con[i][0];
|
||||
conY[i] = con[i][1];
|
||||
conZ[i] = con[i][2];
|
||||
}
|
||||
|
||||
nbt.setIntArray("conX", conX);
|
||||
nbt.setIntArray("conY", conY);
|
||||
nbt.setIntArray("conZ", conZ);
|
||||
}
|
||||
|
||||
public static List<int[]> convertArrayToList(int[][] array, World worldObj) {
|
||||
|
||||
List<int[]> list = new ArrayList<int[]>();
|
||||
|
||||
for(int i = 0; i < array.length; i++) {
|
||||
list.add(new int[] {array[i][0], array[i][1], array[i][2]});
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static int[][] convertListToArray(List<int[]> list) {
|
||||
|
||||
int[][] array = new int[list.size()][3];
|
||||
|
||||
for(int i = 0; i < list.size(); i++) {
|
||||
int[] pos = list.get(i);
|
||||
array[i][0] = pos[0];
|
||||
array[i][1] = pos[1];
|
||||
array[i][2] = pos[2];
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public void addTileEntityBasedOnCoords(int x, int y, int z) {
|
||||
|
||||
TileEntity te = worldObj.getTileEntity(x, y, z);
|
||||
if(te != null && te instanceof TileEntityPylonRedWire)
|
||||
this.connected.add(new int[]{x, y, z});
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return TileEntity.INFINITE_EXTENT_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getMaxRenderDistanceSquared()
|
||||
{
|
||||
return 65536.0D;
|
||||
}
|
||||
}
|
||||
@ -64,7 +64,7 @@ public class TileEntityChungus extends TileEntity implements IFluidAcceptor, IFl
|
||||
power += (Integer)outs[3] * cycles;
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||
this.sendPower(worldObj, xCoord + dir.offsetX * 11, yCoord, zCoord + dir.offsetZ * 11, dir);
|
||||
this.sendPower(worldObj, xCoord - dir.offsetX * 11, yCoord, zCoord - dir.offsetZ * 11, dir);
|
||||
|
||||
if(power > maxPower)
|
||||
power = maxPower;
|
||||
|
||||
@ -29,7 +29,7 @@ public class TileEntityMachineMiniRTG extends TileEntity implements IEnergyGener
|
||||
power = getMaxPower();
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
this.sendPower(worldObj, xCoord, yCoord, zCoord, dir);
|
||||
this.sendPower(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -128,7 +128,7 @@ public class TileEntityMachinePlasmaHeater extends TileEntityMachineBase impleme
|
||||
|
||||
this.getBlockMetadata();
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.blockMetadata);
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.blockMetadata - BlockDummyable.offset);
|
||||
ForgeDirection side = dir.getRotation(ForgeDirection.UP);
|
||||
|
||||
for(int i = 1; i < 4; i++) {
|
||||
|
||||
@ -25,13 +25,13 @@ public class TileEntityMachinePumpjack extends TileEntityOilDrillBase {
|
||||
@Override
|
||||
protected void updateConnections() {
|
||||
this.getBlockMetadata();
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.blockMetadata);
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.blockMetadata - BlockDummyable.offset);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN);
|
||||
|
||||
this.trySubscribe(worldObj, xCoord + rot.offsetX * 3 + 1, yCoord, zCoord + rot.offsetZ * 3 + 1);
|
||||
this.trySubscribe(worldObj, xCoord + rot.offsetX * 3 + 1, yCoord, zCoord + rot.offsetZ * 3 - 1);
|
||||
this.trySubscribe(worldObj, xCoord + rot.offsetX * 3 - 1, yCoord, zCoord + rot.offsetZ * 3 + 1);
|
||||
this.trySubscribe(worldObj, xCoord + rot.offsetX * 3 - 1, yCoord, zCoord + rot.offsetZ * 3 - 1);
|
||||
this.trySubscribe(worldObj, xCoord + rot.offsetX * 2 + dir.offsetX * 2, yCoord, zCoord + rot.offsetZ * 2 + dir.offsetZ * 2);
|
||||
this.trySubscribe(worldObj, xCoord + rot.offsetX * 2 + dir.offsetX * 2, yCoord, zCoord + rot.offsetZ * 4 - dir.offsetZ * 2);
|
||||
this.trySubscribe(worldObj, xCoord + rot.offsetX * 4 - dir.offsetX * 2, yCoord, zCoord + rot.offsetZ * 4 + dir.offsetZ * 2);
|
||||
this.trySubscribe(worldObj, xCoord + rot.offsetX * 4 - dir.offsetX * 2, yCoord, zCoord + rot.offsetZ * 2 - dir.offsetZ * 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -18,29 +18,34 @@ public class TileEntityCableBaseNT extends TileEntity implements IEnergyConducto
|
||||
//we got here either because the net doesn't exist or because it's not valid, so that's safe to assume
|
||||
this.setPowerNet(null);
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
|
||||
TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
|
||||
IEnergyConductor conductor = (IEnergyConductor) te;
|
||||
|
||||
if(this.getPowerNet() == null && conductor.getPowerNet() != null) {
|
||||
conductor.getPowerNet().joinLink(this);
|
||||
}
|
||||
|
||||
if(this.getPowerNet() != null && conductor.getPowerNet() != null && this.getPowerNet() != conductor.getPowerNet()) {
|
||||
conductor.getPowerNet().joinNetworks(this.getPowerNet());
|
||||
}
|
||||
}
|
||||
}
|
||||
this.connect();
|
||||
|
||||
if(this.getPowerNet() == null) {
|
||||
new PowerNet().joinLink(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void connect() {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
|
||||
TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
|
||||
IEnergyConductor conductor = (IEnergyConductor) te;
|
||||
|
||||
if(this.getPowerNet() == null && conductor.getPowerNet() != null) {
|
||||
conductor.getPowerNet().joinLink(this);
|
||||
}
|
||||
|
||||
if(this.getPowerNet() != null && conductor.getPowerNet() != null && this.getPowerNet() != conductor.getPowerNet()) {
|
||||
conductor.getPowerNet().joinNetworks(this.getPowerNet());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import api.hbm.energy.PowerNet;
|
||||
|
||||
public class TileEntityCableSwitch extends TileEntityCableBaseNT {
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
//only update if the meta is 1 (ON), updating causes the net to form and allows transmission
|
||||
return this.getBlockMetadata() == 1 && super.canUpdate();
|
||||
return this.worldObj != null && this.getBlockMetadata() == 1 && super.canUpdate();
|
||||
}
|
||||
|
||||
public void updateState() {
|
||||
@ -18,5 +17,13 @@ public class TileEntityCableSwitch extends TileEntityCableBaseNT {
|
||||
this.network.destroy();
|
||||
this.network = null;
|
||||
}
|
||||
|
||||
if(this.getBlockMetadata() == 1) {
|
||||
this.connect();
|
||||
|
||||
if(this.getPowerNet() == null) {
|
||||
new PowerNet().joinLink(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import api.hbm.energy.IEnergyConductor;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityPylon extends TileEntityPylonBase {
|
||||
|
||||
@Override
|
||||
public ConnectionType getConnectionType() {
|
||||
return ConnectionType.SINGLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getMountPos() {
|
||||
return Vec3.createVectorHelper(xCoord + 0.5, yCoord + 5.4, zCoord + 0.5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxWireLength() {
|
||||
return 25D;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void connect() {
|
||||
|
||||
/*
|
||||
* Apparently super.super does not exist, and the mentally damaged folk from heckoverflow pretend like that's a good thing.
|
||||
* Look at this shit, you think that's good? "Write Everything Twice"? You like that, huh?
|
||||
*/
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
|
||||
TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
|
||||
IEnergyConductor conductor = (IEnergyConductor) te;
|
||||
|
||||
if(this.getPowerNet() == null && conductor.getPowerNet() != null) {
|
||||
conductor.getPowerNet().joinLink(this);
|
||||
}
|
||||
|
||||
if(this.getPowerNet() != null && conductor.getPowerNet() != null && this.getPowerNet() != conductor.getPowerNet()) {
|
||||
conductor.getPowerNet().joinNetworks(this.getPowerNet());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.connect();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,161 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import api.hbm.energy.IEnergyConductor;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
|
||||
|
||||
public List<int[]> connected = new ArrayList<int[]>();
|
||||
|
||||
public static boolean canConnect(TileEntityPylonBase first, TileEntityPylonBase second) {
|
||||
|
||||
if(first.getConnectionType() != second.getConnectionType())
|
||||
return false;
|
||||
|
||||
double len = Math.min(first.getMaxWireLength(), second.getMaxWireLength());
|
||||
double lenSq = len * len;
|
||||
|
||||
Vec3 firstPos = first.getMountPos();
|
||||
Vec3 secondPos = second.getMountPos();
|
||||
|
||||
double deltaSq = Math.pow(secondPos.xCoord - firstPos.xCoord, 2) + Math.pow(secondPos.yCoord - firstPos.yCoord, 2) + Math.pow(secondPos.zCoord - firstPos.zCoord, 2);
|
||||
|
||||
return lenSq >= deltaSq;
|
||||
}
|
||||
|
||||
public void addConnection(int x, int y, int z) {
|
||||
|
||||
connected.add(new int[] {x, y, z});
|
||||
|
||||
if(this.getPowerNet() != null) {
|
||||
this.getPowerNet().destroy();
|
||||
this.setPowerNet(null);
|
||||
}
|
||||
|
||||
this.markDirty();
|
||||
|
||||
if(worldObj instanceof WorldServer) {
|
||||
WorldServer world = (WorldServer) worldObj;
|
||||
world.getPlayerManager().markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnectAll() {
|
||||
|
||||
for(int[] pos : connected) {
|
||||
|
||||
TileEntity te = worldObj.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
|
||||
if(te instanceof TileEntityPylonBase) {
|
||||
TileEntityPylonBase pylon = (TileEntityPylonBase) te;
|
||||
|
||||
for(int i = 0; i < pylon.connected.size(); i++) {
|
||||
int[] conPos = pylon.connected.get(i);
|
||||
|
||||
if(conPos[0] == xCoord && conPos[1] == yCoord && conPos[2] == zCoord) {
|
||||
pylon.connected.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
pylon.markDirty();
|
||||
|
||||
if(worldObj instanceof WorldServer) {
|
||||
WorldServer world = (WorldServer) worldObj;
|
||||
world.getPlayerManager().markBlockForUpdate(pylon.xCoord, pylon.yCoord, pylon.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void connect() {
|
||||
|
||||
for(int[] pos : connected) {
|
||||
|
||||
TileEntity te = worldObj.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
|
||||
IEnergyConductor conductor = (IEnergyConductor) te;
|
||||
|
||||
if(this.getPowerNet() == null && conductor.getPowerNet() != null) {
|
||||
conductor.getPowerNet().joinLink(this);
|
||||
}
|
||||
|
||||
if(this.getPowerNet() != null && conductor.getPowerNet() != null && this.getPowerNet() != conductor.getPowerNet()) {
|
||||
conductor.getPowerNet().joinNetworks(this.getPowerNet());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract ConnectionType getConnectionType();
|
||||
public abstract Vec3 getMountPos();
|
||||
public abstract double getMaxWireLength();
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
nbt.setInteger("conCount", connected.size());
|
||||
|
||||
for(int i = 0; i < connected.size(); i++) {
|
||||
nbt.setIntArray("con" + i, connected.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
int count = nbt.getInteger("conCount");
|
||||
|
||||
this.connected.clear();
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
connected.add(nbt.getIntArray("con" + i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
this.writeToNBT(nbt);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
this.readFromNBT(pkt.func_148857_g());
|
||||
}
|
||||
|
||||
public static enum ConnectionType {
|
||||
SINGLE
|
||||
//more to follow
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return TileEntity.INFINITE_EXTENT_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 65536.0D;
|
||||
}
|
||||
}
|
||||
@ -240,7 +240,7 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
|
||||
}
|
||||
|
||||
private void updateConnections() {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite();
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
|
||||
this.trySubscribe(worldObj, xCoord + dir.offsetX * -1 + rot.offsetX * 0, yCoord, zCoord + dir.offsetZ * -1 + rot.offsetZ * 0);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 810 B After Width: | Height: | Size: 825 B |
Loading…
x
Reference in New Issue
Block a user