Search in sources :

Example 21 with Vector3

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

the class RoomBoss method addComponentParts.

@Override
public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox chunkBox) {
    for (int i = 0; i <= this.sizeX; i++) {
        for (int j = 0; j <= this.sizeY; j++) {
            for (int k = 0; k <= this.sizeZ; k++) {
                if (i == 0 || i == this.sizeX || j == 0 || j == this.sizeY || k == 0 || k == this.sizeZ) {
                    boolean placeBlock = true;
                    if (getDirection().getAxis() == EnumFacing.Axis.Z) {
                        int start = (this.boundingBox.maxX - this.boundingBox.minX) / 2 - 1;
                        int end = (this.boundingBox.maxX - this.boundingBox.minX) / 2 + 1;
                        if (i > start && i <= end && j < 3 && j > 0) {
                            if (getDirection() == EnumFacing.SOUTH && k == 0) {
                                placeBlock = false;
                            } else if (getDirection() == EnumFacing.NORTH && k == this.sizeZ) {
                                placeBlock = false;
                            }
                        }
                    } else {
                        int start = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 - 1;
                        int end = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 + 1;
                        if (k > start && k <= end && j < 3 && j > 0) {
                            if (getDirection() == EnumFacing.EAST && i == 0) {
                                placeBlock = false;
                            } else if (getDirection() == EnumFacing.WEST && i == this.sizeX) {
                                placeBlock = false;
                            }
                        }
                    }
                    if (placeBlock) {
                        this.setBlockState(worldIn, this.configuration.getBrickBlock(), i, j, k, chunkBox);
                    } else {
                        this.setBlockState(worldIn, Blocks.air.getDefaultState(), i, j, k, chunkBox);
                    }
                } else if ((i == 1 && k == 1) || (i == 1 && k == this.sizeZ - 1) || (i == this.sizeX - 1 && k == 1) || (i == this.sizeX - 1 && k == this.sizeZ - 1)) {
                    this.setBlockState(worldIn, Blocks.flowing_lava.getDefaultState(), i, j, k, chunkBox);
                } else if (j % 3 == 0 && j >= 2 && ((i == 1 || i == this.sizeX - 1 || k == 1 || k == this.sizeZ - 1) || (i == 2 && k == 2) || (i == 2 && k == this.sizeZ - 2) || (i == this.sizeX - 2 && k == 2) || (i == this.sizeX - 2 && k == this.sizeZ - 2))) {
                    // Horizontal bars
                    this.setBlockState(worldIn, Blocks.iron_bars.getDefaultState(), i, j, k, chunkBox);
                } else if ((i == 1 && k == 2) || (i == 2 && k == 1) || (i == 1 && k == this.sizeZ - 2) || (i == 2 && k == this.sizeZ - 1) || (i == this.sizeX - 1 && k == 2) || (i == this.sizeX - 2 && k == 1) || (i == this.sizeX - 1 && k == this.sizeZ - 2) || (i == this.sizeX - 2 && k == this.sizeZ - 1)) {
                    // Vertical bars
                    this.setBlockState(worldIn, Blocks.iron_bars.getDefaultState(), i, j, k, chunkBox);
                } else {
                    this.setBlockState(worldIn, Blocks.air.getDefaultState(), i, j, k, chunkBox);
                }
            }
        }
    }
    int spawnerX = this.sizeX / 2;
    int spawnerY = 1;
    int spawnerZ = this.sizeZ / 2;
    BlockPos blockpos = new BlockPos(this.getXWithOffset(spawnerX, spawnerZ), this.getYWithOffset(spawnerY), this.getZWithOffset(spawnerX, spawnerZ));
    // Is this position inside the chunk currently being generated?
    if (chunkBox.isVecInside(blockpos)) {
        worldIn.setBlockState(blockpos, GCBlocks.bossSpawner.getDefaultState(), 2);
        TileEntityDungeonSpawner spawner = (TileEntityDungeonSpawner) worldIn.getTileEntity(blockpos);
        if (spawner != null) {
            spawner.setRoom(new Vector3(this.boundingBox.minX + 1, this.boundingBox.minY + 1, this.boundingBox.minZ + 1), new Vector3(this.sizeX - 1, this.sizeY - 1, this.sizeZ - 1));
            spawner.setChestPos(this.chestPos);
        }
    }
    return true;
}
Also used : BlockPos(net.minecraft.util.BlockPos) TileEntityDungeonSpawner(micdoodle8.mods.galacticraft.core.tile.TileEntityDungeonSpawner) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 22 with Vector3

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

the class RenderTier3Rocket method doRender.

@Override
public void doRender(EntityTier3Rocket entity, double par2, double par4, double par6, float par8, float par9) {
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPushMatrix();
    final float var24 = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * par9 + 180;
    final float var25 = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * par9 + 45;
    GL11.glTranslatef((float) par2, (float) par4 + entity.getRenderOffsetY(), (float) par6);
    GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-var24, 0.0F, 0.0F, 1.0F);
    final float var28 = entity.rollAmplitude / 3 - par9;
    if (var28 > 0.0F) {
        final float i = entity.getLaunched() ? (5 - MathHelper.floor_double(entity.timeUntilLaunch / 85)) / 10F : 0.3F;
        GL11.glRotatef(MathHelper.sin(var28) * var28 * i * par9, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(MathHelper.sin(var28) * var28 * i * par9, 1.0F, 0.0F, 1.0F);
    }
    updateModel();
    RenderHelper.disableStandardItemLighting();
    this.bindTexture(TextureMap.locationBlocksTexture);
    if (Minecraft.isAmbientOcclusionEnabled()) {
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
    } else {
        GlStateManager.shadeModel(GL11.GL_FLAT);
    }
    GL11.glScalef(-1.0F, -1.0F, 1.0F);
    GL11.glScalef(0.8F, 0.8F, 0.8F);
    ClientUtil.drawBakedModel(rocketModel);
    Vector3 teamColor = ClientUtil.updateTeamColor(FMLClientHandler.instance().getClient().thePlayer.getName(), true);
    if (teamColor != null) {
        GL11.glColor3f(teamColor.floatX(), teamColor.floatY(), teamColor.floatZ());
    }
    if (FMLClientHandler.instance().getClient().thePlayer.ticksExisted / 10 % 2 < 1) {
        GL11.glColor3f(1, 0, 0);
    } else {
        GL11.glColor3f(0, 1, 0);
    }
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glColor3f(1, 1, 1);
    GL11.glPopMatrix();
    RenderHelper.enableStandardItemLighting();
}
Also used : Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 23 with Vector3

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

the class SpaceRace method loadFromNBT.

public void loadFromNBT(NBTTagCompound nbt) {
    this.teamName = nbt.getString("TeamName");
    if (ConfigManagerCore.enableDebug) {
        GCLog.info("Loading spacerace data for team " + this.teamName);
    }
    this.spaceRaceID = nbt.getInteger("SpaceRaceID");
    // Deal with legacy error
    this.ticksSpent = (int) nbt.getLong("TicksSpent");
    this.flagData = FlagData.readFlagData(nbt);
    this.teamColor = new Vector3(nbt.getDouble("teamColorR"), nbt.getDouble("teamColorG"), nbt.getDouble("teamColorB"));
    NBTTagList tagList = nbt.getTagList("PlayerList", 10);
    for (int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound tagAt = tagList.getCompoundTagAt(i);
        this.playerNames.add(tagAt.getString("PlayerName"));
    }
    tagList = nbt.getTagList("CelestialBodyList", 10);
    for (int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound tagAt = tagList.getCompoundTagAt(i);
        CelestialBody body = GalaxyRegistry.getCelestialBodyFromUnlocalizedName(tagAt.getString("CelestialBodyName"));
        if (body != null) {
            this.celestialBodyStatusList.put(body, tagAt.getInteger("TimeTaken"));
        }
    }
    tagList = nbt.getTagList("SchList", 10);
    for (int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound tagAt = tagList.getCompoundTagAt(i);
        String name = tagAt.getString("Mem");
        if (name != null && this.playerNames.contains(name)) {
            final NBTTagList itemList = tagAt.getTagList("Sch", 10);
            for (int j = 0; j < itemList.tagCount(); ++j) {
                addNewSchematic(name, ItemStack.loadItemStackFromNBT(itemList.getCompoundTagAt(j)));
            }
        }
    }
    if (ConfigManagerCore.enableDebug) {
        GCLog.info("Loaded spacerace team data OK.");
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CelestialBody(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 24 with Vector3

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

the class SpaceRaceManager method onPlayerRemoval.

public static void onPlayerRemoval(MinecraftServer server, String player, SpaceRace race) {
    for (String member : race.getPlayerNames()) {
        EntityPlayerMP memberObj = PlayerUtil.getPlayerForUsernameVanilla(server, member);
        if (memberObj != null) {
            memberObj.addChatMessage(new ChatComponentText(EnumColor.DARK_AQUA + GCCoreUtil.translateWithFormat("gui.space_race.chat.remove_success", EnumColor.RED + player + EnumColor.DARK_AQUA)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA)));
        }
    }
    List<String> playerList = new ArrayList<String>();
    playerList.add(player);
    SpaceRace newRace = SpaceRaceManager.addSpaceRace(new SpaceRace(playerList, SpaceRace.DEFAULT_NAME, new FlagData(48, 32), new Vector3(1, 1, 1)));
    EntityPlayerMP playerToRemove = PlayerUtil.getPlayerBaseServerFromPlayerUsername(server, player, true);
    if (playerToRemove != null) {
        SpaceRaceManager.sendSpaceRaceData(server, playerToRemove, newRace);
        SpaceRaceManager.sendSpaceRaceData(server, playerToRemove, race);
    }
}
Also used : ChatStyle(net.minecraft.util.ChatStyle) FlagData(micdoodle8.mods.galacticraft.core.wrappers.FlagData) ArrayList(java.util.ArrayList) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 25 with Vector3

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

the class EntityLander method getParticleMap.

@Override
public Map<Vector3, Vector3> getParticleMap() {
    double sinPitch = Math.sin(this.rotationPitch / Constants.RADIANS_TO_DEGREES_D);
    final double x1 = 4 * Math.cos(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * sinPitch;
    final double z1 = 4 * Math.sin(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * sinPitch;
    final double y1 = -4 * Math.abs(Math.cos(this.rotationPitch / Constants.RADIANS_TO_DEGREES_D));
    new Vector3(this);
    final Map<Vector3, Vector3> particleMap = new HashMap<Vector3, Vector3>();
    particleMap.put(new Vector3(this.posX, this.posY + 1D + this.motionY / 2, this.posZ), new Vector3(x1, y1 + this.motionY / 2, z1));
    return particleMap;
}
Also used : HashMap(java.util.HashMap) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Aggregations

Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)74 BlockPos (net.minecraft.util.BlockPos)13 Entity (net.minecraft.entity.Entity)12 TileEntity (net.minecraft.tileentity.TileEntity)11 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)8 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)6 IBlockState (net.minecraft.block.state.IBlockState)6 EntityLivingBase (net.minecraft.entity.EntityLivingBase)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)6 ItemStack (net.minecraft.item.ItemStack)6 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)4 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)4 FlagData (micdoodle8.mods.galacticraft.core.wrappers.FlagData)4 WorldServer (net.minecraft.world.WorldServer)4 GameProfile (com.mojang.authlib.GameProfile)3