Search in sources :

Example 21 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class StatsCapability method loadNBTData.

@Override
public void loadNBTData(NBTTagCompound nbt) {
    try {
        this.airRemaining = nbt.getInteger("playerAirRemaining");
        this.damageCounter = nbt.getInteger("damageCounter");
        this.oxygenSetupValid = this.lastOxygenSetupValid = nbt.getBoolean("OxygenSetupValid");
        this.thermalLevel = nbt.getInteger("thermalLevel");
        // Backwards compatibility
        NBTTagList nbttaglist = nbt.getTagList("Inventory", 10);
        this.extendedInventory.readFromNBTOld(nbttaglist);
        if (nbt.hasKey("ExtendedInventoryGC")) {
            this.extendedInventory.readFromNBT(nbt.getTagList("ExtendedInventoryGC", 10));
        }
        // Added for GCInv command - if tried to load an offline player's
        // inventory, load it now
        // (if there was no offline load, then the dontload flag in doLoad()
        // will make sure nothing happens)
        EntityPlayerMP p = this.player.get();
        if (p != null) {
            ItemStack[] saveinv = CommandGCInv.getSaveData(PlayerUtil.getName(p).toLowerCase());
            if (saveinv != null) {
                CommandGCInv.doLoad(p);
            }
        }
        if (nbt.hasKey("SpaceshipTier")) {
            this.spaceshipTier = nbt.getInteger("SpaceshipTier");
        }
        // New keys in version 3.0.5.220
        if (nbt.hasKey("FuelLevel")) {
            this.fuelLevel = nbt.getInteger("FuelLevel");
        }
        if (nbt.hasKey("ReturnRocket")) {
            ItemStack returnRocket = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("ReturnRocket"));
            if (returnRocket != null) {
                this.rocketItem = returnRocket.getItem();
                this.rocketType = returnRocket.getItemDamage();
            }
        }
        this.usingParachute = nbt.getBoolean("usingParachute2");
        this.usingPlanetSelectionGui = nbt.getBoolean("usingPlanetSelectionGui");
        this.teleportCooldown = nbt.getInteger("teleportCooldown");
        this.coordsTeleportedFromX = nbt.getDouble("coordsTeleportedFromX");
        this.coordsTeleportedFromZ = nbt.getDouble("coordsTeleportedFromZ");
        this.startDimension = nbt.hasKey("startDimension") ? nbt.getString("startDimension") : "";
        if (nbt.hasKey("spaceStationDimensionID")) {
            // If loading from an old save file, the home space station is always the overworld, so use 0 as home planet
            this.spaceStationDimensionData = WorldUtil.stringToSpaceStationData("0$" + nbt.getInteger("spaceStationDimensionID"));
        } else {
            this.spaceStationDimensionData = WorldUtil.stringToSpaceStationData(nbt.getString("spaceStationDimensionInfo"));
        }
        if (nbt.getBoolean("usingPlanetSelectionGui")) {
            this.openPlanetSelectionGuiCooldown = 20;
        }
        if (nbt.hasKey("RocketItems") && nbt.hasKey("rocketStacksLength")) {
            final NBTTagList var23 = nbt.getTagList("RocketItems", 10);
            int length = nbt.getInteger("rocketStacksLength");
            this.rocketStacks = new ItemStack[length];
            for (int var3 = 0; var3 < var23.tagCount(); ++var3) {
                final NBTTagCompound var4 = var23.getCompoundTagAt(var3);
                final int var5 = var4.getByte("Slot") & 255;
                if (var5 < this.rocketStacks.length) {
                    this.rocketStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
                }
            }
        }
        this.unlockedSchematics = new ArrayList<ISchematicPage>();
        if (p != null) {
            for (int i = 0; i < nbt.getTagList("Schematics", 10).tagCount(); ++i) {
                final NBTTagCompound nbttagcompound = nbt.getTagList("Schematics", 10).getCompoundTagAt(i);
                final int j = nbttagcompound.getInteger("UnlockedPage");
                SchematicRegistry.addUnlockedPage(p, SchematicRegistry.getMatchingRecipeForID(j));
            }
        }
        Collections.sort(this.unlockedSchematics);
        this.cryogenicChamberCooldown = nbt.getInteger("CryogenicChamberCooldown");
        if (nbt.hasKey("ReceivedSoundWarning")) {
            this.receivedSoundWarning = nbt.getBoolean("ReceivedSoundWarning");
        }
        if (nbt.hasKey("ReceivedBedWarning")) {
            this.receivedBedWarning = nbt.getBoolean("ReceivedBedWarning");
        }
        if (nbt.hasKey("LaunchpadStack")) {
            this.launchpadStack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("LaunchpadStack"));
            if (this.launchpadStack != null && this.launchpadStack.stackSize == 0) {
                this.launchpadStack = null;
            }
        } else {
            // for backwards compatibility with saves which don't have this tag - players can't lose launchpads
            this.launchpadStack = new ItemStack(GCBlocks.landingPad, 9, 0);
        }
        if (nbt.hasKey("BuildFlags")) {
            this.buildFlags = nbt.getInteger("BuildFlags");
        }
        if (nbt.hasKey("ShownSpaceRace")) {
            this.openedSpaceRaceManager = nbt.getBoolean("ShownSpaceRace");
        }
        if (nbt.hasKey("AstroMinerCount")) {
            this.astroMinerCount = nbt.getInteger("AstroMinerCount");
        }
        if (nbt.hasKey("AstroData")) {
            this.activeAstroMinerChunks.clear();
            NBTTagList astroList = nbt.getTagList("AstroData", 10);
            for (int i = 0; i < astroList.tagCount(); ++i) {
                final NBTTagCompound nbttagcompound = astroList.getCompoundTagAt(i);
                BlockVec3 data = BlockVec3.readFromNBT(nbttagcompound);
                this.activeAstroMinerChunks.add(data);
            }
            if (GalacticraftCore.isPlanetsLoaded) {
                AsteroidsTickHandlerServer.loadAstroChunkList(this.activeAstroMinerChunks);
            }
        }
        if (nbt.hasKey("GlassColor1")) {
            this.glassColor1 = nbt.getInteger("GlassColor1");
            this.glassColor2 = nbt.getInteger("GlassColor2");
            this.glassColor3 = nbt.getInteger("GlassColor3");
        }
        if (nbt.hasKey("PanLi")) {
            final NBTTagList panels = nbt.getTagList("PanLi", 10);
            for (int i = 0; i < panels.tagCount(); ++i) {
                if (i == BlockPanelLighting.PANELTYPES_LENGTH)
                    break;
                final NBTTagCompound stateNBT = panels.getCompoundTagAt(i);
                IBlockState bs = TileEntityPanelLight.readBlockState(stateNBT);
                this.panelLightingBases[i] = (bs.getBlock() == Blocks.air) ? null : bs;
            }
        }
        if (nbt.hasKey("PanCo")) {
            this.panelLightingColor = nbt.getInteger("PanCo");
        }
        GCLog.debug("Loading GC player data for " + PlayerUtil.getName(player.get()) + " : " + this.buildFlags);
        this.sentFlags = false;
    } catch (Exception e) {
        GCLog.severe("Found error in saved Galacticraft player data for " + PlayerUtil.getName(player.get()) + " - this should fix itself next relog.");
        e.printStackTrace();
    }
    GCLog.debug("Finished loading GC player data for " + PlayerUtil.getName(player.get()) + " : " + this.buildFlags);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) IBlockState(net.minecraft.block.state.IBlockState) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 22 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class TickHandlerClient method spawnLeakParticles.

private void spawnLeakParticles() {
    Random rand = new Random();
    for (int i = ClientProxyCore.leakTrace.size() - 1; i >= 1; i--) {
        BlockVec3 curr = ClientProxyCore.leakTrace.get(i);
        int nx = i - 2;
        if (i > 2 && rand.nextInt(3) == 0)
            nx--;
        BlockVec3 vec;
        if (i > 1)
            vec = ClientProxyCore.leakTrace.get(nx).clone();
        else {
            vec = curr.clone().translate(0, -2, 0);
        }
        Vector3 mot = new Vector3(vec.subtract(curr));
        Vector3 rnd = new Vector3(rand.nextDouble() / 2 - 0.25, rand.nextDouble() / 2 - 0.25, rand.nextDouble() / 2 - 0.25);
        GalacticraftCore.proxy.spawnParticle("oxygen", curr.midPoint().add(rnd), mot, new Object[] { new Vector3(0.7D, 0.7D, 1.0D) });
    }
}
Also used : Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 23 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class TileEntityOxygenSealer method updateClient.

@Override
public void updateClient(List<Object> data) {
    this.leaksClient = new ArrayList<>();
    if (data.size() > 1) {
        for (int i = 1; i < data.size(); i++) {
            int comp = (Integer) data.get(i);
            int dx = (comp >> 16) - 128;
            int dy = (comp >> 8) & 255;
            int dz = (comp & 255) - 128;
            this.leaksClient.add(new BlockVec3(this.pos.getX() + dx, dy, this.pos.getZ() + dz));
        }
    }
}
Also used : BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 24 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class TileEntityOxygenDistributor method invalidate.

@Override
public void invalidate() {
    if (!this.worldObj.isRemote) /* && this.oxygenBubble != null*/
    {
        int bubbleR = MathHelper.ceiling_double_int(bubbleSize);
        int bubbleR2 = (int) (bubbleSize * bubbleSize);
        final int xMin = this.getPos().getX() - bubbleR;
        final int xMax = this.getPos().getX() + bubbleR;
        final int yMin = this.getPos().getY() - bubbleR;
        final int yMax = this.getPos().getY() + bubbleR;
        final int zMin = this.getPos().getZ() - bubbleR;
        final int zMax = this.getPos().getZ() + bubbleR;
        for (int x = xMin; x < xMax; x++) {
            for (int z = zMin; z < zMax; z++) {
                // Doing y as the inner loop allows BlockVec3 to cache the chunks more efficiently
                for (int y = yMin; y < yMax; y++) {
                    Block block = new BlockVec3(x, y, z).getBlockID(this.worldObj);
                    if (block instanceof IOxygenReliantBlock && this.getDistanceFromServer(x, y, z) <= bubbleR2) {
                        this.worldObj.scheduleUpdate(new BlockPos(x, y, z), block, 0);
                    }
                }
            }
        }
        // this.oxygenBubble.setDead();
        TileEntityOxygenDistributor.loadedTiles.remove(new BlockVec3Dim(this));
    }
    super.invalidate();
}
Also used : IOxygenReliantBlock(micdoodle8.mods.galacticraft.api.block.IOxygenReliantBlock) Block(net.minecraft.block.Block) IOxygenReliantBlock(micdoodle8.mods.galacticraft.api.block.IOxygenReliantBlock) BlockVec3Dim(micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 25 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class OxygenUtil method checkTorchHasOxygen.

/*
     * A simplified version of the breathable air check which checks
     * all 6 sides of the given block (because a torch can pass air on all sides)
     * Used in BlockUnlitTorch.
     */
public static boolean checkTorchHasOxygen(World world, BlockPos pos) {
    if (OxygenUtil.inOxygenBubble(world, pos.getX() + 0.5D, pos.getY() + 0.6D, pos.getZ() + 0.5D)) {
        return true;
    }
    OxygenUtil.checked = new HashSet<>();
    BlockVec3 vec = new BlockVec3(pos);
    for (int side = 0; side < 6; side++) {
        BlockVec3 sidevec = vec.newVecSide(side);
        Block newblock = sidevec.getBlockID_noChunkLoad(world);
        if (OxygenUtil.testContactWithBreathableAir(world, newblock, sidevec.toBlockPos(), 1) >= 0) {
            return true;
        }
    }
    return false;
}
Also used : IPartialSealableBlock(micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Aggregations

BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)104 TileEntity (net.minecraft.tileentity.TileEntity)44 EnumFacing (net.minecraft.util.EnumFacing)20 IBlockState (net.minecraft.block.state.IBlockState)14 BlockPos (net.minecraft.util.BlockPos)13 World (net.minecraft.world.World)10 IPartialSealableBlock (micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock)9 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)9 Block (net.minecraft.block.Block)9 ArrayList (java.util.ArrayList)7 FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)7 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)7 NBTTagList (net.minecraft.nbt.NBTTagList)7 IConductor (micdoodle8.mods.galacticraft.api.transmission.tile.IConductor)6 TileEntityOxygenSealer (micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 Entity (net.minecraft.entity.Entity)5 LinkedList (java.util.LinkedList)4 INetworkProvider (micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider)4 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)4