Search in sources :

Example 26 with IGalacticraftWorldProvider

use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.

the class CommandGCHouston method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    EntityPlayerMP playerBase = null;
    MinecraftServer server = MinecraftServer.getServer();
    boolean isOp = false;
    Entity entitySender = sender.getCommandSenderEntity();
    if (entitySender == null) {
        isOp = true;
    } else if (entitySender instanceof EntityPlayer) {
        GameProfile prof = ((EntityPlayer) entitySender).getGameProfile();
        isOp = server.getConfigurationManager().canSendCommands(prof);
    }
    if (args.length < 2) {
        try {
            if (args.length == 0) {
                playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), true);
                if (!playerBase.capabilities.isCreativeMode) {
                    if (ConfigManagerCore.challengeMode || !(playerBase.worldObj.provider instanceof IGalacticraftWorldProvider)) {
                        CommandBase.notifyOperators(sender, this, "commands.gchouston.fail");
                        return;
                    }
                }
                if (timerList.contains(playerBase)) {
                    timerList.remove(playerBase);
                } else {
                    timerList.add(playerBase);
                    TickHandlerServer.timerHoustonCommand = 250;
                    String msg = EnumColor.YELLOW + GCCoreUtil.translate("commands.gchouston.confirm.1") + " " + EnumColor.WHITE + GCCoreUtil.translate("commands.gchouston.confirm.2");
                    CommandBase.notifyOperators(sender, this, msg);
                    return;
                }
            } else {
                if (!isOp) {
                    CommandBase.notifyOperators(sender, this, "commands.gchouston.noop");
                    return;
                }
                playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(args[0], true);
            }
            if (playerBase != null) {
                int dimID = ConfigManagerCore.idDimensionOverworld;
                WorldServer worldserver = server.worldServerForDimension(dimID);
                if (worldserver == null) {
                    worldserver = server.worldServerForDimension(0);
                    if (worldserver == null) {
                        throw new Exception("/gchouston could not find Overworld.");
                    }
                    dimID = 0;
                }
                BlockPos spawnPoint = null;
                BlockPos bedPos = playerBase.getBedLocation(dimID);
                if (bedPos != null) {
                    spawnPoint = EntityPlayer.getBedSpawnLocation(worldserver, bedPos, false);
                }
                if (spawnPoint == null) {
                    spawnPoint = worldserver.getTopSolidOrLiquidBlock(worldserver.getSpawnPoint());
                }
                GCPlayerStats stats = GCPlayerStats.get(playerBase);
                stats.setRocketStacks(new ItemStack[0]);
                stats.setRocketType(IRocketType.EnumRocketType.DEFAULT.ordinal());
                stats.setRocketItem(null);
                stats.setFuelLevel(0);
                stats.setCoordsTeleportedFromX(spawnPoint.getX());
                stats.setCoordsTeleportedFromZ(spawnPoint.getZ());
                stats.setUsingPlanetSelectionGui(false);
                playerBase.closeScreen();
                Vector3 spawnPos = new Vector3(spawnPoint.getX() + 0.5D, spawnPoint.getY() + 0.25D, spawnPoint.getZ() + 0.5D);
                try {
                    WorldUtil.teleportEntitySimple(worldserver, dimID, playerBase, spawnPos);
                } catch (Exception e) {
                    e.printStackTrace();
                    throw e;
                }
                CommandBase.notifyOperators(sender, this, "commands.gchouston.success", new Object[] { String.valueOf(EnumColor.GREY + "" + playerBase.getName()) });
            } else {
                throw new Exception("Could not find player with name: " + args[0]);
            }
        } catch (final Exception var6) {
            throw new CommandException(var6.getMessage(), new Object[0]);
        }
    } else {
        throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.dimensiontp.too_many", this.getCommandUsage(sender)), new Object[0]);
    }
}
Also used : Entity(net.minecraft.entity.Entity) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) WorldServer(net.minecraft.world.WorldServer) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) CommandException(net.minecraft.command.CommandException) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException) MinecraftServer(net.minecraft.server.MinecraftServer) WrongUsageException(net.minecraft.command.WrongUsageException) GameProfile(com.mojang.authlib.GameProfile) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.BlockPos)

Example 27 with IGalacticraftWorldProvider

use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.

the class BlockIceAsteroids method harvestBlock.

@Override
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te) {
    player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1);
    player.addExhaustion(0.025F);
    if (this.canSilkHarvest(worldIn, pos, worldIn.getBlockState(pos), player) && EnchantmentHelper.getSilkTouchModifier(player)) {
        ArrayList<ItemStack> items = new ArrayList<ItemStack>();
        ItemStack itemstack = this.createStackedBlock(state);
        if (itemstack != null) {
            items.add(itemstack);
        }
        ForgeEventFactory.fireBlockHarvesting(items, worldIn, pos, state, 0, 1.0f, true, player);
        for (ItemStack is : items) {
            Block.spawnAsEntity(worldIn, pos, is);
        }
    } else {
        if (GCCoreUtil.getDimensionID(worldIn) == -1 || worldIn.provider instanceof IGalacticraftWorldProvider) {
            worldIn.setBlockToAir(pos);
            return;
        }
        int i1 = EnchantmentHelper.getFortuneModifier(player);
        harvesters.set(player);
        this.dropBlockAsItem(worldIn, pos, state, i1);
        harvesters.set(null);
        Material material = worldIn.getBlockState(pos.down()).getBlock().getMaterial();
        if (material.blocksMovement() || material.isLiquid()) {
            worldIn.setBlockState(pos, Blocks.flowing_water.getDefaultState());
        }
    }
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) ArrayList(java.util.ArrayList) Material(net.minecraft.block.material.Material) ItemStack(net.minecraft.item.ItemStack)

Example 28 with IGalacticraftWorldProvider

use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project MorePlanets by SteveKunG.

the class TileEntityTreasureChestMP method update.

@Override
public void update() {
    int i = this.pos.getX();
    int j = this.pos.getY();
    int k = this.pos.getZ();
    ++this.ticksSinceSync;
    float f;
    if (this.locked) {
        this.numPlayersUsing = 0;
    }
    if (!this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + i + j + k) % 200 == 0) {
        this.numPlayersUsing = 0;
        f = 5.0F;
        List<EntityPlayer> list = this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(i - f, j - f, k - f, i + 1 + f, j + 1 + f, k + 1 + f));
        Iterator<EntityPlayer> iterator = list.iterator();
        while (iterator.hasNext()) {
            EntityPlayer player = iterator.next();
            if (player.openContainer instanceof ContainerChest) {
                IInventory iinventory = ((ContainerChest) player.openContainer).getLowerChestInventory();
                if (iinventory == this || iinventory instanceof InventoryLargeChest && ((InventoryLargeChest) iinventory).isPartOfLargeChest(this)) {
                    ++this.numPlayersUsing;
                }
            }
        }
    }
    this.prevLidAngle = this.lidAngle;
    f = this.world.provider instanceof IGalacticraftWorldProvider ? 0.05F : 0.1F;
    double d2;
    if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F) {
        double d1 = i + 0.5D;
        d2 = k + 0.5D;
        this.world.playSound(null, d1, j + 0.5D, d2, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.provider instanceof IGalacticraftWorldProvider ? this.world.rand.nextFloat() * 0.1F + 0.6F : this.world.rand.nextFloat() * 0.1F + 0.9F);
    }
    if ((this.numPlayersUsing == 0 || this.locked) && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) {
        float f1 = this.lidAngle;
        if (this.numPlayersUsing == 0 || this.locked) {
            this.lidAngle -= f;
        } else {
            this.lidAngle += f;
        }
        if (this.lidAngle > 1.0F) {
            this.lidAngle = 1.0F;
        }
        float f2 = 0.5F;
        if (this.lidAngle < f2 && f1 >= f2) {
            d2 = i + 0.5D;
            double d0 = k + 0.5D;
            this.world.playSound(null, d2, j + 0.5D, d0, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.provider instanceof IGalacticraftWorldProvider ? this.world.rand.nextFloat() * 0.1F + 0.6F : this.world.rand.nextFloat() * 0.1F + 0.9F);
        }
        if (this.lidAngle < 0.0F) {
            this.lidAngle = 0.0F;
        }
    }
    super.update();
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IInventory(net.minecraft.inventory.IInventory) InventoryLargeChest(net.minecraft.inventory.InventoryLargeChest) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) ContainerChest(net.minecraft.inventory.ContainerChest) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 29 with IGalacticraftWorldProvider

use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.

the class CommandGCHouston method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    EntityPlayerMP playerBase = null;
    boolean isOp = this.isOp(server, sender);
    if (args.length < 2) {
        try {
            if (args.length == 0) {
                playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), true);
                if (!playerBase.capabilities.isCreativeMode) {
                    if (ConfigManagerCore.challengeMode || !(playerBase.world.provider instanceof IGalacticraftWorldProvider)) {
                        CommandBase.notifyCommandListener(sender, this, "commands.gchouston.fail");
                        return;
                    }
                }
                if (timerList.contains(playerBase)) {
                    timerList.remove(playerBase);
                } else {
                    timerList.add(playerBase);
                    TickHandlerServer.timerHoustonCommand = 250;
                    String msg = EnumColor.YELLOW + GCCoreUtil.translate("commands.gchouston.confirm.1") + " " + EnumColor.WHITE + GCCoreUtil.translate("commands.gchouston.confirm.2");
                    CommandBase.notifyCommandListener(sender, this, msg);
                    return;
                }
            } else {
                if (!isOp) {
                    CommandBase.notifyCommandListener(sender, this, "commands.gchouston.noop");
                    return;
                }
                playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(args[0], true);
            }
            if (playerBase != null) {
                int dimID = ConfigManagerCore.idDimensionOverworld;
                WorldServer worldserver = server.getWorld(dimID);
                if (worldserver == null) {
                    worldserver = server.getWorld(0);
                    if (worldserver == null) {
                        throw new Exception("/gchouston could not find Overworld.");
                    }
                    dimID = 0;
                }
                BlockPos spawnPoint = null;
                BlockPos bedPos = playerBase.getBedLocation(dimID);
                if (bedPos != null) {
                    spawnPoint = EntityPlayer.getBedSpawnLocation(worldserver, bedPos, false);
                }
                if (spawnPoint == null) {
                    spawnPoint = worldserver.getTopSolidOrLiquidBlock(worldserver.getSpawnPoint());
                }
                GCPlayerStats stats = GCPlayerStats.get(playerBase);
                stats.setRocketStacks(NonNullList.withSize(0, ItemStack.EMPTY));
                stats.setRocketType(IRocketType.EnumRocketType.DEFAULT.ordinal());
                stats.setRocketItem(null);
                stats.setFuelLevel(0);
                stats.setCoordsTeleportedFromX(spawnPoint.getX());
                stats.setCoordsTeleportedFromZ(spawnPoint.getZ());
                stats.setUsingPlanetSelectionGui(false);
                playerBase.closeScreen();
                Vector3 spawnPos = new Vector3(spawnPoint.getX() + 0.5D, spawnPoint.getY() + 0.25D, spawnPoint.getZ() + 0.5D);
                try {
                    WorldUtil.teleportEntitySimple(worldserver, dimID, playerBase, spawnPos);
                } catch (Exception e) {
                    e.printStackTrace();
                    throw e;
                }
                CommandBase.notifyCommandListener(sender, this, "commands.gchouston.success", new Object[] { String.valueOf(EnumColor.GREY + "" + playerBase.getName()) });
            } else {
                throw new Exception("Could not find player with name: " + args[0]);
            }
        } catch (final Exception var6) {
            throw new CommandException(var6.getMessage(), new Object[0]);
        }
    } else {
        throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.dimensiontp.too_many", this.getUsage(sender)), new Object[0]);
    }
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) WorldServer(net.minecraft.world.WorldServer) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) CommandException(net.minecraft.command.CommandException) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException) WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos)

Example 30 with IGalacticraftWorldProvider

use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.

the class ModelBipedGC method setRotationAngles.

public static void setRotationAngles(ModelBiped biped, float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) {
    if (!(par7Entity instanceof EntityPlayer))
        return;
    final EntityPlayer player = (EntityPlayer) par7Entity;
    final ItemStack currentItemStack = player.inventory.getCurrentItem();
    final float floatPI = 3.1415927F;
    if (!par7Entity.onGround && par7Entity.world.provider instanceof IGalacticraftWorldProvider && par7Entity.getRidingEntity() == null && !(currentItemStack != null && currentItemStack.getItem() instanceof IHoldableItem)) {
        float speedModifier = 0.1162F * 2;
        float angularSwingArm = MathHelper.cos(par1 * (speedModifier / 2));
        float rightMod = biped.rightArmPose == ModelBiped.ArmPose.ITEM ? 1 : 2;
        biped.bipedRightArm.rotateAngleX -= MathHelper.cos(par1 * 0.6662F + floatPI) * rightMod * par2 * 0.5F;
        biped.bipedLeftArm.rotateAngleX -= MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
        biped.bipedRightArm.rotateAngleX += -angularSwingArm * 4.0F * par2 * 0.5F;
        biped.bipedLeftArm.rotateAngleX += angularSwingArm * 4.0F * par2 * 0.5F;
        biped.bipedLeftLeg.rotateAngleX -= MathHelper.cos(par1 * 0.6662F + floatPI) * 1.4F * par2;
        biped.bipedLeftLeg.rotateAngleX += MathHelper.cos(par1 * 0.1162F * 2 + floatPI) * 1.4F * par2;
        biped.bipedRightLeg.rotateAngleX -= MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;
        biped.bipedRightLeg.rotateAngleX += MathHelper.cos(par1 * 0.1162F * 2) * 1.4F * par2;
    }
    PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
    if (gearData != null) {
        if (gearData.getParachute() != null) {
            // Parachute is equipped
            biped.bipedLeftArm.rotateAngleX += floatPI;
            biped.bipedLeftArm.rotateAngleZ += floatPI / 10;
            biped.bipedRightArm.rotateAngleX += floatPI;
            biped.bipedRightArm.rotateAngleZ -= floatPI / 10;
        }
    }
    ItemStack heldItemStack = null;
    for (EnumHand hand : EnumHand.values()) {
        ItemStack item = player.getHeldItem(hand);
        if (item != null && item.getItem() instanceof IHoldableItem) {
            heldItemStack = item;
        }
    }
    if (heldItemStack != null && !(player.getRidingEntity() instanceof ICameraZoomEntity)) {
        Item heldItem = heldItemStack.getItem();
        IHoldableItem holdableItem = (IHoldableItem) heldItem;
        IHoldableItemCustom holdableItemCustom = heldItem instanceof IHoldableItemCustom ? (IHoldableItemCustom) heldItem : null;
        if (holdableItem.shouldHoldLeftHandUp(player)) {
            Vector3 angle = null;
            if (holdableItemCustom != null) {
                angle = holdableItemCustom.getLeftHandRotation(player);
            }
            if (angle == null) {
                angle = new Vector3(floatPI + 0.3F, 0.0F, floatPI / 10.0F);
            }
            biped.bipedLeftArm.rotateAngleX = angle.floatX();
            biped.bipedLeftArm.rotateAngleY = angle.floatY();
            biped.bipedLeftArm.rotateAngleZ = angle.floatZ();
        }
        if (holdableItem.shouldHoldRightHandUp(player)) {
            Vector3 angle = null;
            if (holdableItemCustom != null) {
                angle = holdableItemCustom.getRightHandRotation(player);
            }
            if (angle == null) {
                angle = new Vector3(floatPI + 0.3F, 0.0F, (float) -Math.PI / 10.0F);
            }
            biped.bipedRightArm.rotateAngleX = angle.floatX();
            biped.bipedRightArm.rotateAngleY = angle.floatY();
            biped.bipedRightArm.rotateAngleZ = angle.floatZ();
        }
    }
    for (Entity e : player.world.loadedEntityList) {
        if (e instanceof EntityTieredRocket && e.getDistanceSq(player) < 200) {
            final EntityTieredRocket ship = (EntityTieredRocket) e;
            if (!ship.getPassengers().isEmpty() && !ship.getPassengers().contains(player) && (ship.getLaunched() || ship.timeUntilLaunch < 390)) {
                biped.bipedRightArm.rotateAngleZ -= floatPI / 8F + MathHelper.sin(par3 * 0.9F) * 0.2F;
                biped.bipedRightArm.rotateAngleX = floatPI;
                break;
            }
        }
    }
    if (player.isPlayerSleeping() && GalacticraftCore.isPlanetsLoaded) {
        RenderPlayerGC.RotatePlayerEvent event = new RenderPlayerGC.RotatePlayerEvent((AbstractClientPlayer) player);
        MinecraftForge.EVENT_BUS.post(event);
        if (event.vanillaOverride && (event.shouldRotate == null || event.shouldRotate)) {
            biped.bipedHead.rotateAngleX = (float) (20.0F - Math.sin(player.ticksExisted / 10.0F) / 7.0F);
            biped.bipedHead.rotateAngleY = 0.0F;
            biped.bipedHead.rotateAngleZ = 0.0F;
            biped.bipedLeftArm.rotateAngleX = 0.0F;
            biped.bipedLeftArm.rotateAngleY = 0.0F;
            biped.bipedLeftArm.rotateAngleZ = 0.0F;
            biped.bipedRightArm.rotateAngleX = 0.0F;
            biped.bipedRightArm.rotateAngleY = 0.0F;
            biped.bipedRightArm.rotateAngleZ = 0.0F;
        }
    }
    ModelBiped.copyModelAngles(biped.bipedHead, biped.bipedHeadwear);
}
Also used : Entity(net.minecraft.entity.Entity) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) EntityTieredRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket) RenderPlayerGC(micdoodle8.mods.galacticraft.core.client.render.entities.RenderPlayerGC) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) IHoldableItemCustom(micdoodle8.mods.galacticraft.api.item.IHoldableItemCustom) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) Item(net.minecraft.item.Item) IHoldableItem(micdoodle8.mods.galacticraft.api.item.IHoldableItem) IHoldableItem(micdoodle8.mods.galacticraft.api.item.IHoldableItem) EnumHand(net.minecraft.util.EnumHand) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

Aggregations

IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)52 ItemStack (net.minecraft.item.ItemStack)16 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)14 BlockPos (net.minecraft.util.math.BlockPos)13 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)9 EntityPlayer (net.minecraft.entity.player.EntityPlayer)9 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)8 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)7 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)7 ResourceLocation (net.minecraft.util.ResourceLocation)7 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)6 IBlockState (net.minecraft.block.state.IBlockState)6 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 Block (net.minecraft.block.Block)5 WorldClient (net.minecraft.client.multiplayer.WorldClient)5 EnumFacing (net.minecraft.util.EnumFacing)5 WorldServer (net.minecraft.world.WorldServer)5 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)4 TileEntity (net.minecraft.tileentity.TileEntity)4