Search in sources :

Example 86 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class EnergyPlusBarClientScreenModule method setupCoordinateFromNBT.

@Override
protected void setupCoordinateFromNBT(NBTTagCompound tagCompound, int dim, int x, int y, int z) {
    coordinate = Coordinate.INVALID;
    if (tagCompound.hasKey("monitorx")) {
        this.dim = tagCompound.getInteger("dim");
        coordinate = new Coordinate(tagCompound.getInteger("monitorx"), tagCompound.getInteger("monitory"), tagCompound.getInteger("monitorz"));
    }
}
Also used : Coordinate(mcjty.lib.varia.Coordinate)

Example 87 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class FavoriteDestinationsProperties method writeFavoritesToNBT.

private static void writeFavoritesToNBT(NBTTagCompound tagCompound, Collection<GlobalCoordinate> destinations) {
    NBTTagList lst = new NBTTagList();
    for (GlobalCoordinate destination : destinations) {
        NBTTagCompound tc = new NBTTagCompound();
        Coordinate c = destination.getCoordinate();
        tc.setInteger("x", c.getX());
        tc.setInteger("y", c.getY());
        tc.setInteger("z", c.getZ());
        tc.setInteger("dim", destination.getDimension());
        lst.appendTag(tc);
    }
    tagCompound.setTag("destinations", lst);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 88 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class FavoriteDestinationsProperties method readCoordinatesFromNBT.

private static void readCoordinatesFromNBT(NBTTagCompound tagCompound, Set<GlobalCoordinate> destinations) {
    NBTTagList lst = tagCompound.getTagList("destinations", net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < lst.tagCount(); i++) {
        NBTTagCompound tc = lst.getCompoundTagAt(i);
        Coordinate c = new Coordinate(tc.getInteger("x"), tc.getInteger("y"), tc.getInteger("z"));
        destinations.add(new GlobalCoordinate(c, tc.getInteger("dim")));
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 89 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class PeacefulAreaManager method isPeaceful.

public static boolean isPeaceful(GlobalCoordinate coordinate) {
    if (areas.isEmpty()) {
        return false;
    }
    List<GlobalCoordinate> toRemove = new ArrayList<GlobalCoordinate>();
    boolean peaceful = false;
    long curtime = System.currentTimeMillis() - 10000;
    for (Map.Entry<GlobalCoordinate, PeacefulArea> entry : areas.entrySet()) {
        PeacefulArea area = entry.getValue();
        GlobalCoordinate entryCoordinate = entry.getKey();
        if (area.in(coordinate, entryCoordinate)) {
            peaceful = true;
        }
        if (area.getLastTouched() < curtime) {
            // Hasn't been touched for at least 10 seconds. Probably no longer valid.
            // To be sure we will first check this by testing if the environmental controller is still active and running.
            WorldServer world = DimensionManager.getWorld(entryCoordinate.getDimension());
            if (world != null) {
                Coordinate c = entryCoordinate.getCoordinate();
                // If the world is not loaded we don't do anything and we also don't remove the area since we have no information about it.
                if (!world.getChunkProvider().chunkExists(c.getX() >> 4, c.getZ() >> 4)) {
                    boolean removeArea = true;
                    TileEntity te = world.getTileEntity(c.getX(), c.getY(), c.getZ());
                    if (te instanceof EnvironmentalControllerTileEntity) {
                        EnvironmentalControllerTileEntity controllerTileEntity = (EnvironmentalControllerTileEntity) te;
                        for (EnvironmentModule module : controllerTileEntity.getEnvironmentModules()) {
                            if (module instanceof PeacefulEModule) {
                                if (((PeacefulEModule) module).isActive()) {
                                    removeArea = false;
                                    break;
                                }
                            }
                        }
                    }
                    if (removeArea) {
                        toRemove.add(entryCoordinate);
                    }
                }
            }
        }
    }
    for (GlobalCoordinate globalCoordinate : toRemove) {
        areas.remove(globalCoordinate);
    }
    return peaceful;
}
Also used : EnvironmentModule(mcjty.rftools.blocks.environmental.modules.EnvironmentModule) ArrayList(java.util.ArrayList) PeacefulEModule(mcjty.rftools.blocks.environmental.modules.PeacefulEModule) WorldServer(net.minecraft.world.WorldServer) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) TileEntity(net.minecraft.tileentity.TileEntity) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) Map(java.util.Map) HashMap(java.util.HashMap)

Example 90 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class EndergenicRenderer method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
    ResourceLocation txt;
    Coordinate coord = new Coordinate(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
    if (coord.equals(RFTools.instance.clientInfo.getSelectedTE())) {
        txt = redglow;
    } else if (coord.equals(RFTools.instance.clientInfo.getDestinationTE())) {
        txt = blueglow;
    } else {
        return;
    }
    this.bindTexture(txt);
    Tessellator tessellator = Tessellator.instance;
    GL11.glPushMatrix();
    GL11.glTranslated(x, y, z);
    tessellator.startDrawingQuads();
    tessellator.setColorRGBA(255, 255, 255, 128);
    tessellator.setBrightness(240);
    boolean blending = GL11.glIsEnabled(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.UP.ordinal(), 1.1f, -0.05f);
    DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.DOWN.ordinal(), 1.1f, -0.05f);
    DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.NORTH.ordinal(), 1.1f, -0.05f);
    DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.SOUTH.ordinal(), 1.1f, -0.05f);
    DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.WEST.ordinal(), 1.1f, -0.05f);
    DefaultISBRH.addSideFullTexture(tessellator, ForgeDirection.EAST.ordinal(), 1.1f, -0.05f);
    tessellator.draw();
    GL11.glPopMatrix();
    if (!blending) {
        GL11.glDisable(GL11.GL_BLEND);
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) Coordinate(mcjty.lib.varia.Coordinate) ResourceLocation(net.minecraft.util.ResourceLocation)

Aggregations

Coordinate (mcjty.lib.varia.Coordinate)181 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)63 TileEntity (net.minecraft.tileentity.TileEntity)30 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)19 Block (net.minecraft.block.Block)14 HashMap (java.util.HashMap)13 Map (java.util.Map)13 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)13 World (net.minecraft.world.World)12 NBTTagList (net.minecraft.nbt.NBTTagList)11 Callback (li.cil.oc.api.machine.Callback)10 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)10 Panel (mcjty.lib.gui.widgets.Panel)10 ItemStack (net.minecraft.item.ItemStack)10 ArrayList (java.util.ArrayList)9 Label (mcjty.lib.gui.widgets.Label)8 BlockInfo (mcjty.rftools.BlockInfo)7 SyncedCoordinate (mcjty.lib.entity.SyncedCoordinate)5 ChoiceEvent (mcjty.lib.gui.events.ChoiceEvent)4 TeleportDestinationClientInfo (mcjty.rftools.blocks.teleporter.TeleportDestinationClientInfo)4