use of blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection in project ImmersiveEngineering by BluSunrize.
the class TileEntityImmersiveConnectable method removeCable.
@Override
public void removeCable(Connection connection) {
WireType type = connection != null ? connection.cableType : null;
Set<Connection> outputs = ImmersiveNetHandler.INSTANCE.getConnections(worldObj, Utils.toCC(this));
if (outputs == null || outputs.size() == 0) {
if (type == limitType || type == null)
this.limitType = null;
}
this.markDirty();
if (worldObj != null) {
IBlockState state = worldObj.getBlockState(pos);
worldObj.notifyBlockUpdate(pos, state, state, 3);
}
}
use of blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection in project ImmersiveEngineering by BluSunrize.
the class EntitySkylineHook method reachedTarget.
public void reachedTarget(TileEntity end) {
this.setDead();
IELogger.debug("last tick at " + System.currentTimeMillis());
List<Entity> list = this.getPassengers();
if (list.isEmpty() || !(list.get(0) instanceof EntityPlayer))
return;
// if(!(this.getControllingPassenger() instanceof EntityPlayer))
// return;
// EntityPlayer player = (EntityPlayer)this.getControllingPassenger();
EntityPlayer player = (EntityPlayer) list.get(0);
ItemStack hook = player.getActiveItemStack();
if (hook == null || !(hook.getItem() instanceof ItemSkyhook))
return;
Connection line = SkylineHelper.getTargetConnection(worldObj, target, player, connection);
if (line != null) {
player.setActiveHand(player.getActiveHand());
// setItemInUse(hook, hook.getItem().getMaxItemUseDuration(hook));
SkylineHelper.spawnHook(player, end, line);
// ChunkCoordinates cc0 = line.end==target?line.start:line.end;
// ChunkCoordinates cc1 = line.end==target?line.end:line.start;
// double dx = cc0.posX-cc1.posX;
// double dy = cc0.posY-cc1.posY;
// double dz = cc0.posZ-cc1.posZ;
//
// EntityZiplineHook zip = new EntityZiplineHook(worldObj, target.posX+.5,target.posY+.5,target.posZ+.5, line, cc0);
// zip.motionX = dx*.05f;
// zip.motionY = dy*.05f;
// zip.motionZ = dz*.05f;
// if(!worldObj.isRemote)
// worldObj.spawnEntityInWorld(zip);
// ItemSkyHook.existingHooks.put(this.riddenByEntity.getCommandSenderName(), zip);
// this.riddenByEntity.mountEntity(zip);
} else {
player.motionX = motionX;
player.motionY = motionY;
player.motionZ = motionZ;
IELogger.debug("player motion: " + player.motionX + "," + player.motionY + "," + player.motionZ);
}
}
use of blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection in project ImmersiveEngineering by BluSunrize.
the class IESaveData method writeToNBT.
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
Integer[] relDim = ImmersiveNetHandler.INSTANCE.getRelevantDimensions().toArray(new Integer[0]);
int[] savedDimensions = new int[relDim.length];
for (int ii = 0; ii < relDim.length; ii++) savedDimensions[ii] = relDim[ii];
nbt.setIntArray("savedDimensions", savedDimensions);
for (int dim : savedDimensions) {
NBTTagList connectionList = new NBTTagList();
for (Connection con : ImmersiveNetHandler.INSTANCE.getAllConnections(dim)) {
connectionList.appendTag(con.writeToNBT());
}
nbt.setTag("connectionList" + dim, connectionList);
}
NBTTagList proxies = new NBTTagList();
for (IICProxy iic : ImmersiveNetHandler.INSTANCE.proxies.values()) proxies.appendTag(iic.writeToNBT());
nbt.setTag("iicProxies", proxies);
NBTTagList mineralList = new NBTTagList();
for (Map.Entry<DimensionChunkCoords, MineralWorldInfo> e : ExcavatorHandler.mineralCache.entrySet()) if (e.getKey() != null && e.getValue() != null) {
NBTTagCompound tag = e.getKey().writeToNBT();
tag.setTag("info", e.getValue().writeToNBT());
mineralList.appendTag(tag);
}
nbt.setTag("mineralDepletion", mineralList);
NBTTagList receivedShaderList = new NBTTagList();
for (String player : ShaderRegistry.receivedShaders.keySet()) {
NBTTagCompound tag = new NBTTagCompound();
tag.setString("player", player);
NBTTagList playerReceived = new NBTTagList();
for (String shader : ShaderRegistry.receivedShaders.get(player)) if (shader != null && !shader.isEmpty())
playerReceived.appendTag(new NBTTagString(shader));
tag.setTag("received", playerReceived);
receivedShaderList.appendTag(tag);
}
nbt.setTag("receivedShaderList", receivedShaderList);
return nbt;
}
use of blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection in project ImmersiveEngineering by BluSunrize.
the class IESaveData method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound nbt) {
int[] savedDimensions = nbt.getIntArray("savedDimensions");
for (int dim : savedDimensions) {
NBTTagList connectionList = nbt.getTagList("connectionList" + dim, 10);
ImmersiveNetHandler.INSTANCE.clearAllConnections(dim);
for (int i = 0; i < connectionList.tagCount(); i++) {
NBTTagCompound conTag = connectionList.getCompoundTagAt(i);
Connection con = Connection.readFromNBT(conTag);
if (con != null) {
ImmersiveNetHandler.INSTANCE.addConnection(dim, con.start, con);
}
}
}
NBTTagList proxies = nbt.getTagList("iicProxies", 10);
for (int i = 0; i < proxies.tagCount(); i++) ImmersiveNetHandler.INSTANCE.addProxy(IICProxy.readFromNBT(proxies.getCompoundTagAt(i)));
EventHandler.validateConnsNextTick = true;
NBTTagList mineralList = nbt.getTagList("mineralDepletion", 10);
ExcavatorHandler.mineralCache.clear();
for (int i = 0; i < mineralList.tagCount(); i++) {
NBTTagCompound tag = mineralList.getCompoundTagAt(i);
DimensionChunkCoords coords = DimensionChunkCoords.readFromNBT(tag);
if (coords != null) {
MineralWorldInfo info = MineralWorldInfo.readFromNBT(tag.getCompoundTag("info"));
ExcavatorHandler.mineralCache.put(coords, info);
}
}
NBTTagList receivedShaderList = nbt.getTagList("receivedShaderList", 10);
for (int i = 0; i < receivedShaderList.tagCount(); i++) {
NBTTagCompound tag = receivedShaderList.getCompoundTagAt(i);
String player = tag.getString("player");
ShaderRegistry.receivedShaders.get(player).clear();
NBTTagList playerReceived = tag.getTagList("received", 8);
for (int j = 0; j < playerReceived.tagCount(); j++) {
String s = playerReceived.getStringTagAt(j);
if (s != null && !s.isEmpty())
ShaderRegistry.receivedShaders.put(player, s);
}
}
}
use of blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection in project ImmersiveEngineering by BluSunrize.
the class ClientUtils method convertConnectionFromBlockstate.
public static List<BakedQuad>[] convertConnectionFromBlockstate(IExtendedBlockState s, TextureAtlasSprite t) {
List<BakedQuad>[] ret = new List[2];
ret[0] = new ArrayList<>();
ret[1] = new ArrayList<>();
Set<Connection> conns = s.getValue(IEProperties.CONNECTIONS);
if (conns == null)
return ret;
Vector3f dir = new Vector3f();
Vector3f cross = new Vector3f();
Vector3f up = new Vector3f(0, 1, 0);
BlockPos pos = null;
for (Connection conn : conns) {
if (pos == null)
pos = conn.start;
Vec3d[] f = conn.catenaryVertices;
if (f == null || f.length < 1)
continue;
int color = conn.cableType.getColour(conn);
float[] rgb = { (color >> 16 & 255) / 255f, (color >> 8 & 255) / 255f, (color & 255) / 255f, (color >> 24 & 255) / 255f };
if (rgb[3] == 0)
rgb[3] = 1;
Vector3f start = new Vector3f(conn.start.getX(), conn.start.getY(), conn.start.getZ());
float radius = (float) (conn.cableType.getRenderDiameter() / 2);
List<Integer> crossings = new ArrayList<>();
for (int i = 1; i < f.length; i++) if (crossesChunkBoundary(f[i], f[i - 1]))
crossings.add(i);
int index = crossings.size() / 2;
boolean greater = conn.start.compareTo(conn.end) > 0;
if (crossings.size() % 2 == 0 && greater)
index--;
int max = (crossings.size() > 0 ? (crossings.get(index) + (greater ? 1 : 2)) : (greater ? f.length + 1 : 0));
for (int i = 1; i < max && i < f.length; i++) {
boolean fading = i == max - 1;
List<BakedQuad> curr = ret[fading ? 1 : 0];
int j = i - 1;
Vector3f here = new Vector3f((float) f[i].xCoord, (float) f[i].yCoord, (float) f[i].zCoord);
Vector3f.sub(here, start, here);
Vector3f there = new Vector3f((float) f[j].xCoord, (float) f[j].yCoord, (float) f[j].zCoord);
Vector3f.sub(there, start, there);
if (fading) {
Vector3f.add(here, fadingOffset, here);
Vector3f.add(there, fadingOffset, there);
}
boolean vertical = here.x == there.x && here.z == there.z;
if (!vertical) {
Vector3f.sub(here, there, dir);
Vector3f.cross(up, dir, cross);
cross.scale(radius / cross.length());
} else
cross.set(radius, 0, 0);
Vector3f[] vertices = { Vector3f.add(here, cross, null), Vector3f.sub(here, cross, null), Vector3f.sub(there, cross, null), Vector3f.add(there, cross, null) };
curr.add(createSmartLightingBakedQuad(DefaultVertexFormats.ITEM, vertices, EnumFacing.DOWN, t, rgb, false, fading ? alphaFirst2Fading : alphaNoFading, pos));
curr.add(createSmartLightingBakedQuad(DefaultVertexFormats.ITEM, vertices, EnumFacing.UP, t, rgb, true, fading ? alphaFirst2Fading : alphaNoFading, pos));
if (!vertical) {
Vector3f.cross(cross, dir, cross);
cross.scale(radius / cross.length());
} else
cross.set(0, 0, radius);
vertices = new Vector3f[] { Vector3f.add(here, cross, null), Vector3f.sub(here, cross, null), Vector3f.sub(there, cross, null), Vector3f.add(there, cross, null) };
curr.add(createSmartLightingBakedQuad(DefaultVertexFormats.ITEM, vertices, EnumFacing.WEST, t, rgb, false, fading ? alphaFirst2Fading : alphaNoFading, pos));
curr.add(createSmartLightingBakedQuad(DefaultVertexFormats.ITEM, vertices, EnumFacing.EAST, t, rgb, true, fading ? alphaFirst2Fading : alphaNoFading, pos));
}
}
return ret;
}
Aggregations