Search in sources :

Example 1 with ItemArmorAsteroids

use of micdoodle8.mods.galacticraft.planets.asteroids.items.ItemArmorAsteroids in project Galacticraft by micdoodle8.

the class AsteroidsItems method initItems.

public static void initItems() {
    AsteroidsItems.grapple = new ItemGrappleHook("grapple");
    AsteroidsItems.tier3Rocket = new ItemTier3Rocket("rocket_t3");
    AsteroidsItems.astroMiner = new ItemAstroMiner("astro_miner");
    AsteroidsItems.thermalPadding = new ItemThermalPadding("thermal_padding");
    AsteroidsItems.basicItem = new ItemBasicAsteroids("item_basic_asteroids");
    AsteroidsItems.methaneCanister = new ItemCanisterMethane("methane_canister_partial");
    AsteroidsItems.canisterLOX = new ItemCanisterLiquidOxygen("canister_partial_lox");
    AsteroidsItems.canisterLN2 = new ItemCanisterLiquidNitrogen("canister_partial_ln2");
    // AsteroidsItems.canisterLAr = new ItemCanisterLiquidArgon("canisterPartialLAr");
    AsteroidsItems.atmosphericValve = new ItemAtmosphericValve("atmospheric_valve");
    AsteroidsItems.heavyNoseCone = new ItemHeavyNoseCone("heavy_nose_cone");
    AsteroidsItems.orionDrive = new ItemOrionDrive("orion_drive");
    AsteroidsItems.titaniumHelmet = new ItemArmorAsteroids(0, "helmet");
    AsteroidsItems.titaniumChestplate = new ItemArmorAsteroids(1, "chestplate");
    AsteroidsItems.titaniumLeggings = new ItemArmorAsteroids(2, "leggings");
    AsteroidsItems.titaniumBoots = new ItemArmorAsteroids(3, "boots");
    AsteroidsItems.titaniumAxe = new ItemAxeAsteroids("titanium_axe");
    AsteroidsItems.titaniumPickaxe = new ItemPickaxeAsteroids("titanium_pickaxe");
    AsteroidsItems.titaniumSpade = new ItemSpadeAsteroids("titanium_shovel");
    AsteroidsItems.titaniumHoe = new ItemHoeAsteroids("titanium_hoe");
    AsteroidsItems.titaniumSword = new ItemSwordAsteroids("titanium_sword");
    AsteroidsItems.strangeSeed = new ItemStrangeSeed("strange_seed");
    AsteroidsItems.registerItems();
    OreDictionary.registerOre("compressedTitanium", new ItemStack(AsteroidsItems.basicItem, 1, 6));
    OreDictionary.registerOre("ingotTitanium", new ItemStack(AsteroidsItems.basicItem, 1, 0));
    OreDictionary.registerOre("shardTitanium", new ItemStack(AsteroidsItems.basicItem, 1, 4));
    OreDictionary.registerOre("shardIron", new ItemStack(AsteroidsItems.basicItem, 1, 3));
    OreDictionary.registerOre("dustTitanium", new ItemStack(AsteroidsItems.basicItem, 1, 9));
    AsteroidsItems.registerHarvestLevels();
    GalacticraftCore.proxy.registerCanister(new PartialCanister(AsteroidsItems.methaneCanister, Constants.MOD_ID_PLANETS, "methane_canister_partial", 7));
    GalacticraftCore.proxy.registerCanister(new PartialCanister(AsteroidsItems.canisterLOX, Constants.MOD_ID_PLANETS, "canister_partial_lox", 7));
    GalacticraftCore.proxy.registerCanister(new PartialCanister(AsteroidsItems.canisterLN2, Constants.MOD_ID_PLANETS, "canister_partial_ln2", 7));
}
Also used : PartialCanister(micdoodle8.mods.galacticraft.core.wrappers.PartialCanister) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ItemArmorAsteroids

use of micdoodle8.mods.galacticraft.planets.asteroids.items.ItemArmorAsteroids in project Galacticraft by micdoodle8.

the class GCPlayerHandler method onPlayerUpdate.

public void onPlayerUpdate(EntityPlayerMP player) {
    int tick = player.ticksExisted - 1;
    // This will speed things up a little
    GCPlayerStats stats = GCPlayerStats.get(player);
    if ((ConfigManagerCore.challengeSpawnHandling) && stats.getUnlockedSchematics().size() == 0) {
        if (stats.getStartDimension().length() > 0) {
            stats.setStartDimension("");
        } else {
            // PlayerAPI is installed
            WorldServer worldOld = (WorldServer) player.worldObj;
            try {
                worldOld.getPlayerManager().removePlayer(player);
            } catch (Exception e) {
            }
            worldOld.playerEntities.remove(player);
            worldOld.updateAllPlayersSleepingFlag();
            worldOld.loadedEntityList.remove(player);
            worldOld.onEntityRemoved(player);
            worldOld.getEntityTracker().untrackEntity(player);
            if (player.addedToChunk && worldOld.getChunkProvider().chunkExists(player.chunkCoordX, player.chunkCoordZ)) {
                Chunk chunkOld = worldOld.getChunkFromChunkCoords(player.chunkCoordX, player.chunkCoordZ);
                chunkOld.removeEntity(player);
                chunkOld.setChunkModified();
            }
            WorldServer worldNew = WorldUtil.getStartWorld(worldOld);
            int dimID = GCCoreUtil.getDimensionID(worldNew);
            player.dimension = dimID;
            GCLog.debug("DEBUG: Sending respawn packet to player for dim " + dimID);
            player.playerNetServerHandler.sendPacket(new S07PacketRespawn(dimID, player.worldObj.getDifficulty(), player.worldObj.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType()));
            if (worldNew.provider instanceof WorldProviderSpaceStation) {
                GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_RESET_THIRD_PERSON, GCCoreUtil.getDimensionID(player.worldObj), new Object[] {}), player);
            }
            worldNew.spawnEntityInWorld(player);
            player.setWorld(worldNew);
            player.mcServer.getConfigurationManager().preparePlayer(player, (WorldServer) worldOld);
        }
        // This is a mini version of the code at WorldUtil.teleportEntity
        player.theItemInWorldManager.setWorld((WorldServer) player.worldObj);
        final ITeleportType type = GalacticraftRegistry.getTeleportTypeForDimension(player.worldObj.provider.getClass());
        Vector3 spawnPos = type.getPlayerSpawnLocation((WorldServer) player.worldObj, player);
        ChunkCoordIntPair pair = player.worldObj.getChunkFromChunkCoords(spawnPos.intX() >> 4, spawnPos.intZ() >> 4).getChunkCoordIntPair();
        GCLog.debug("Loading first chunk in new dimension.");
        ((WorldServer) player.worldObj).theChunkProviderServer.loadChunk(pair.chunkXPos, pair.chunkZPos);
        player.setLocationAndAngles(spawnPos.x, spawnPos.y, spawnPos.z, player.rotationYaw, player.rotationPitch);
        type.setupAdventureSpawn(player);
        type.onSpaceDimensionChanged(player.worldObj, player, false);
        player.setSpawnChunk(new BlockPos(spawnPos.intX(), spawnPos.intY(), spawnPos.intZ()), true, GCCoreUtil.getDimensionID(player.worldObj));
        stats.setNewAdventureSpawn(true);
    }
    final boolean isInGCDimension = player.worldObj.provider instanceof IGalacticraftWorldProvider;
    if (tick >= 25) {
        if (ConfigManagerCore.enableSpaceRaceManagerPopup && !stats.hasOpenedSpaceRaceManager()) {
            SpaceRace race = SpaceRaceManager.getSpaceRaceFromPlayer(PlayerUtil.getName(player));
            if (race == null || race.teamName.equals(SpaceRace.DEFAULT_NAME)) {
                GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_OPEN_SPACE_RACE_GUI, GCCoreUtil.getDimensionID(player.worldObj), new Object[] {}), player);
            }
            stats.setOpenedSpaceRaceManager(true);
        }
        if (!stats.hasSentFlags()) {
            GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_STATS, GCCoreUtil.getDimensionID(player.worldObj), stats.getMiscNetworkedStats()), player);
            stats.setSentFlags(true);
        }
    }
    if (stats.getCryogenicChamberCooldown() > 0) {
        stats.setCryogenicChamberCooldown(stats.getCryogenicChamberCooldown() - 1);
    }
    if (!player.onGround && stats.isLastOnGround()) {
        stats.setTouchedGround(true);
    }
    if (stats.getTeleportCooldown() > 0) {
        stats.setTeleportCooldown(stats.getTeleportCooldown() - 1);
    }
    if (stats.getChatCooldown() > 0) {
        stats.setChatCooldown(stats.getChatCooldown() - 1);
    }
    if (stats.getOpenPlanetSelectionGuiCooldown() > 0) {
        stats.setOpenPlanetSelectionGuiCooldown(stats.getOpenPlanetSelectionGuiCooldown() - 1);
        if (stats.getOpenPlanetSelectionGuiCooldown() == 1 && !stats.hasOpenedPlanetSelectionGui()) {
            WorldUtil.toCelestialSelection(player, stats, stats.getSpaceshipTier());
            stats.setHasOpenedPlanetSelectionGui(true);
        }
    }
    if (stats.isUsingParachute()) {
        if (stats.getLastParachuteInSlot() != null) {
            player.fallDistance = 0.0F;
        }
        if (player.onGround) {
            GCPlayerHandler.setUsingParachute(player, stats, false);
        }
    }
    this.checkCurrentItem(player);
    if (stats.isUsingPlanetSelectionGui()) {
        // This sends the planets list again periodically (forcing the Celestial Selection screen to open) in case of server/client lag
        // #PACKETSPAM
        this.sendPlanetList(player, stats);
    }
    /*		if (isInGCDimension || player.usingPlanetSelectionGui)
                {
					player.playerNetServerHandler.ticksForFloatKick = 0;
				}	
		*/
    if (stats.getDamageCounter() > 0) {
        stats.setDamageCounter(stats.getDamageCounter() - 1);
    }
    if (isInGCDimension) {
        if (tick % 10 == 0) {
            boolean doneDungeon = false;
            ItemStack current = player.inventory.getCurrentItem();
            if (current != null && current.getItem() == GCItems.dungeonFinder) {
                this.sendDungeonDirectionPacket(player, stats);
                doneDungeon = true;
            }
            if (tick % 30 == 0) {
                GCPlayerHandler.sendAirRemainingPacket(player, stats);
                this.sendThermalLevelPacket(player, stats);
                if (!doneDungeon) {
                    for (ItemStack stack : player.inventory.mainInventory) {
                        if (stack != null && stack.getItem() == GCItems.dungeonFinder) {
                            this.sendDungeonDirectionPacket(player, stats);
                            break;
                        }
                    }
                }
            }
        }
        if (player.ridingEntity instanceof EntityLanderBase) {
            stats.setInLander(true);
            stats.setJustLanded(false);
        } else {
            if (stats.isInLander()) {
                stats.setJustLanded(true);
            }
            stats.setInLander(false);
        }
        if (player.onGround && stats.hasJustLanded()) {
            stats.setJustLanded(false);
            // Set spawn point here if just descended from a lander for the first time
            if (player.getBedLocation(GCCoreUtil.getDimensionID(player.worldObj)) == null || stats.isNewAdventureSpawn()) {
                int i = 30000000;
                int j = Math.min(i, Math.max(-i, MathHelper.floor_double(player.posX + 0.5D)));
                int k = Math.min(256, Math.max(0, MathHelper.floor_double(player.posY + 1.5D)));
                int l = Math.min(i, Math.max(-i, MathHelper.floor_double(player.posZ + 0.5D)));
                BlockPos coords = new BlockPos(j, k, l);
                player.setSpawnChunk(coords, true, GCCoreUtil.getDimensionID(player.worldObj));
                stats.setNewAdventureSpawn(false);
            }
            GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_RESET_THIRD_PERSON, GCCoreUtil.getDimensionID(player.worldObj), new Object[] {}), player);
        }
        if (player.worldObj.provider instanceof WorldProviderSpaceStation || player.worldObj.provider instanceof IZeroGDimension || GalacticraftCore.isPlanetsLoaded && player.worldObj.provider instanceof WorldProviderAsteroids) {
            this.preventFlyingKicks(player);
            if (player.worldObj.provider instanceof WorldProviderSpaceStation && stats.isNewInOrbit()) {
                ((WorldProviderSpaceStation) player.worldObj.provider).getSpinManager().sendPackets(player);
                stats.setNewInOrbit(false);
            }
        } else {
            stats.setNewInOrbit(true);
        }
    } else {
        stats.setNewInOrbit(true);
    }
    checkGear(player, stats, false);
    if (stats.getChestSpawnCooldown() > 0) {
        stats.setChestSpawnCooldown(stats.getChestSpawnCooldown() - 1);
        if (stats.getChestSpawnCooldown() == 180) {
            if (stats.getChestSpawnVector() != null) {
                EntityParachest chest = new EntityParachest(player.worldObj, stats.getRocketStacks(), stats.getFuelLevel());
                chest.setPosition(stats.getChestSpawnVector().x, stats.getChestSpawnVector().y, stats.getChestSpawnVector().z);
                chest.color = stats.getParachuteInSlot() == null ? EnumDyeColor.WHITE : ItemParaChute.getDyeEnumFromParachuteDamage(stats.getParachuteInSlot().getItemDamage());
                if (!player.worldObj.isRemote) {
                    player.worldObj.spawnEntityInWorld(chest);
                }
            }
        }
    }
    if (stats.getLaunchAttempts() > 0 && player.ridingEntity == null) {
        stats.setLaunchAttempts(0);
    }
    this.checkThermalStatus(player, stats);
    this.checkOxygen(player, stats);
    this.checkShield(player, stats);
    if (isInGCDimension && (stats.isOxygenSetupValid() != stats.isLastOxygenSetupValid() || tick % 100 == 0)) {
        GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_OXYGEN_VALIDITY, GCCoreUtil.getDimensionID(player.worldObj), new Object[] { stats.isOxygenSetupValid() }), player);
    }
    this.throwMeteors(player);
    this.updateSchematics(player, stats);
    if (tick % 250 == 0 && stats.getFrequencyModuleInSlot() == null && !stats.hasReceivedSoundWarning() && isInGCDimension && player.onGround && tick > 0 && ((IGalacticraftWorldProvider) player.worldObj.provider).getSoundVolReductionAmount() > 1.0F) {
        String[] string2 = GCCoreUtil.translate("gui.frequencymodule.warning1").split(" ");
        StringBuilder sb = new StringBuilder();
        for (String aString2 : string2) {
            sb.append(" ").append(EnumColor.YELLOW).append(aString2);
        }
        player.addChatMessage(new ChatComponentText(EnumColor.YELLOW + GCCoreUtil.translate("gui.frequencymodule.warning0") + " " + EnumColor.AQUA + GCItems.basicItem.getItemStackDisplayName(new ItemStack(GCItems.basicItem, 1, 19)) + sb.toString()));
        stats.setReceivedSoundWarning(true);
    }
    // Player moves and sprints 18% faster with full set of Titanium Armor
    if (GalacticraftCore.isPlanetsLoaded && tick % 40 == 1 && player.inventory != null) {
        int titaniumCount = 0;
        for (int i = 0; i < 4; i++) {
            ItemStack armorPiece = player.getCurrentArmor(i);
            if (armorPiece != null && armorPiece.getItem() instanceof ItemArmorAsteroids) {
                titaniumCount++;
            }
        }
        if (stats.getSavedSpeed() == 0F) {
            if (titaniumCount == 4) {
                float speed = player.capabilities.getWalkSpeed();
                if (speed < 0.118F) {
                    try {
                        Field f = player.capabilities.getClass().getDeclaredField(GCCoreUtil.isDeobfuscated() ? "walkSpeed" : "field_75097_g");
                        f.setAccessible(true);
                        f.set(player.capabilities, 0.118F);
                        stats.setSavedSpeed(speed);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        } else if (titaniumCount < 4) {
            try {
                Field f = player.capabilities.getClass().getDeclaredField(GCCoreUtil.isDeobfuscated() ? "walkSpeed" : "field_75097_g");
                f.setAccessible(true);
                f.set(player.capabilities, stats.getSavedSpeed());
                stats.setSavedSpeed(0F);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    stats.setLastOxygenSetupValid(stats.isOxygenSetupValid());
    stats.setLastUnlockedSchematics(stats.getUnlockedSchematics());
    stats.setLastOnGround(player.onGround);
}
Also used : SpaceRace(micdoodle8.mods.galacticraft.core.dimension.SpaceRace) ChunkCoordIntPair(net.minecraft.world.ChunkCoordIntPair) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) WorldServer(net.minecraft.world.WorldServer) WorldProviderAsteroids(micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids) ItemArmorAsteroids(micdoodle8.mods.galacticraft.planets.asteroids.items.ItemArmorAsteroids) Field(java.lang.reflect.Field) WorldProviderSpaceStation(micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation) BlockPos(net.minecraft.util.BlockPos) ChatComponentText(net.minecraft.util.ChatComponentText) S07PacketRespawn(net.minecraft.network.play.server.S07PacketRespawn) ITeleportType(micdoodle8.mods.galacticraft.api.world.ITeleportType) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) Chunk(net.minecraft.world.chunk.Chunk) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) EntityLanderBase(micdoodle8.mods.galacticraft.core.entities.EntityLanderBase) EntityParachest(micdoodle8.mods.galacticraft.core.entities.EntityParachest) ItemStack(net.minecraft.item.ItemStack) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension)

Aggregations

ItemStack (net.minecraft.item.ItemStack)2 Field (java.lang.reflect.Field)1 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)1 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)1 ITeleportType (micdoodle8.mods.galacticraft.api.world.ITeleportType)1 IZeroGDimension (micdoodle8.mods.galacticraft.api.world.IZeroGDimension)1 SpaceRace (micdoodle8.mods.galacticraft.core.dimension.SpaceRace)1 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)1 EntityLanderBase (micdoodle8.mods.galacticraft.core.entities.EntityLanderBase)1 EntityParachest (micdoodle8.mods.galacticraft.core.entities.EntityParachest)1 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)1 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)1 PartialCanister (micdoodle8.mods.galacticraft.core.wrappers.PartialCanister)1 WorldProviderAsteroids (micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids)1 ItemArmorAsteroids (micdoodle8.mods.galacticraft.planets.asteroids.items.ItemArmorAsteroids)1 S07PacketRespawn (net.minecraft.network.play.server.S07PacketRespawn)1 BlockPos (net.minecraft.util.BlockPos)1 ChatComponentText (net.minecraft.util.ChatComponentText)1 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)1 WorldServer (net.minecraft.world.WorldServer)1