Search in sources :

Example 1 with TileEntityLaunchController

use of micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController in project Galacticraft by micdoodle8.

the class BlockMachineMars method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    int metadata = getMetaFromState(state);
    final int angle = MathHelper.floor_double(placer.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
    int change = EnumFacing.getHorizontal(angle).getOpposite().getHorizontalIndex();
    worldIn.setBlockState(pos, getStateFromMeta((metadata & 12) + change), 3);
    switch(metadata & 12) {
        case BlockMachineMars.CRYOGENIC_CHAMBER_METADATA:
            BlockMulti.onPlacement(worldIn, pos, placer, this);
            break;
        case BlockMachineMars.LAUNCH_CONTROLLER_METADATA:
            WorldUtil.markAdjacentPadForUpdate(worldIn, pos);
            TileEntity var8 = worldIn.getTileEntity(pos);
            if (var8 instanceof IChunkLoader && !worldIn.isRemote && ConfigManagerMars.launchControllerChunkLoad && placer instanceof EntityPlayer) {
                ((IChunkLoader) var8).setOwnerName(((EntityPlayer) placer).getName());
                ((IChunkLoader) var8).onTicketLoaded(ForgeChunkManager.requestTicket(GalacticraftCore.instance, var8.getWorld(), Type.NORMAL), true);
            } else if (var8 instanceof TileEntityLaunchController && placer instanceof EntityPlayer) {
                ((TileEntityLaunchController) var8).setOwnerName(((EntityPlayer) placer).getName());
            }
            break;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IChunkLoader(micdoodle8.mods.galacticraft.core.world.IChunkLoader) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntityLaunchController(micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController)

Example 2 with TileEntityLaunchController

use of micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController in project Galacticraft by micdoodle8.

the class PacketSimpleMars method handleServerSide.

@Override
public void handleServerSide(EntityPlayer player) {
    EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
    switch(this.type) {
        case S_UPDATE_SLIMELING_DATA:
            Entity entity = player.worldObj.getEntityByID((Integer) this.data.get(0));
            if (entity instanceof EntitySlimeling) {
                EntitySlimeling slimeling = (EntitySlimeling) entity;
                int subType = (Integer) this.data.get(1);
                switch(subType) {
                    case 0:
                        if (player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
                            slimeling.setSittingAI(!slimeling.isSitting());
                            slimeling.setJumping(false);
                            slimeling.getNavigator().clearPathEntity();
                            slimeling.setAttackTarget(null);
                        }
                        break;
                    case 1:
                        if (player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
                            slimeling.slimelingName = (String) this.data.get(2);
                            slimeling.setName(slimeling.slimelingName);
                        }
                        break;
                    case 2:
                        if (player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
                            slimeling.age += 5000;
                        }
                        break;
                    case 3:
                        if (!slimeling.isInLove() && player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
                            slimeling.setInLove(playerBase);
                        }
                        break;
                    case 4:
                        if (player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
                            slimeling.attackDamage = Math.min(slimeling.attackDamage + 0.1F, 1.0F);
                        }
                        break;
                    case 5:
                        if (player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
                            slimeling.setHealth(slimeling.getHealth() + 5.0F);
                        }
                        break;
                    case 6:
                        if (player == slimeling.getOwner() && !slimeling.worldObj.isRemote) {
                            MarsUtil.openSlimelingInventory(playerBase, slimeling);
                        }
                        break;
                }
            }
            break;
        case S_WAKE_PLAYER:
            BlockPos c = playerBase.playerLocation;
            if (c != null) {
                EventWakePlayer event = new EventWakePlayer(playerBase, c, true, true, false, true);
                MinecraftForge.EVENT_BUS.post(event);
                playerBase.wakeUpPlayer(true, true, false);
            }
            break;
        case S_UPDATE_ADVANCED_GUI:
            TileEntity tile = player.worldObj.getTileEntity((BlockPos) this.data.get(1));
            switch((Integer) this.data.get(0)) {
                case 0:
                    if (tile instanceof TileEntityLaunchController) {
                        TileEntityLaunchController launchController = (TileEntityLaunchController) tile;
                        launchController.setFrequency((Integer) this.data.get(2));
                    }
                    break;
                case 1:
                    if (tile instanceof TileEntityLaunchController) {
                        TileEntityLaunchController launchController = (TileEntityLaunchController) tile;
                        launchController.setLaunchDropdownSelection((Integer) this.data.get(2));
                    }
                    break;
                case 2:
                    if (tile instanceof TileEntityLaunchController) {
                        TileEntityLaunchController launchController = (TileEntityLaunchController) tile;
                        launchController.setDestinationFrequency((Integer) this.data.get(2));
                    }
                    break;
                case 3:
                    if (tile instanceof TileEntityLaunchController) {
                        TileEntityLaunchController launchController = (TileEntityLaunchController) tile;
                        launchController.launchPadRemovalDisabled = (Integer) this.data.get(2) == 1;
                    }
                    break;
                case 4:
                    if (tile instanceof TileEntityLaunchController) {
                        TileEntityLaunchController launchController = (TileEntityLaunchController) tile;
                        launchController.setLaunchSchedulingEnabled((Integer) this.data.get(2) == 1);
                    }
                    break;
                case 5:
                    if (tile instanceof TileEntityLaunchController) {
                        TileEntityLaunchController launchController = (TileEntityLaunchController) tile;
                        launchController.requiresClientUpdate = true;
                    }
                    break;
                default:
                    break;
            }
            break;
        case S_UPDATE_CARGO_ROCKET_STATUS:
            Entity entity2 = player.worldObj.getEntityByID((Integer) this.data.get(0));
            if (entity2 instanceof EntityCargoRocket) {
                EntityCargoRocket rocket = (EntityCargoRocket) entity2;
                int subType = (Integer) this.data.get(1);
                switch(subType) {
                    default:
                        rocket.statusValid = rocket.checkLaunchValidity();
                        break;
                }
            }
            break;
        case S_SWITCH_LAUNCH_CONTROLLER_GUI:
            BlockPos pos = (BlockPos) this.data.get(0);
            TileEntity tile1 = player.worldObj.getTileEntity(pos);
            if (tile1 instanceof TileEntityLaunchController) {
                TileEntityLaunchController launchController = (TileEntityLaunchController) tile1;
                switch((Integer) this.data.get(1)) {
                    case 0:
                        MarsUtil.openAdvancedLaunchController(playerBase, launchController);
                        break;
                    case 1:
                        player.openGui(GalacticraftPlanets.instance, GuiIdsPlanets.MACHINE_MARS, player.worldObj, pos.getX(), pos.getY(), pos.getZ());
                        break;
                }
            }
            break;
        default:
            break;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EntityCargoRocket(micdoodle8.mods.galacticraft.planets.mars.entities.EntityCargoRocket) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntitySlimeling(micdoodle8.mods.galacticraft.planets.mars.entities.EntitySlimeling) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.BlockPos) EventWakePlayer(micdoodle8.mods.galacticraft.core.event.EventWakePlayer) TileEntityLaunchController(micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController)

Example 3 with TileEntityLaunchController

use of micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController in project Galacticraft by micdoodle8.

the class TileEntityLandingPad method testConnectedTile.

private void testConnectedTile(int x, int z, HashSet<ILandingPadAttachable> connectedTiles) {
    BlockPos testPos = new BlockPos(x, this.getPos().getY(), z);
    if (!this.worldObj.isBlockLoaded(testPos, false))
        return;
    final TileEntity tile = this.worldObj.getTileEntity(testPos);
    if (tile instanceof ILandingPadAttachable && ((ILandingPadAttachable) tile).canAttachToLandingPad(this.worldObj, this.getPos())) {
        connectedTiles.add((ILandingPadAttachable) tile);
        if (GalacticraftCore.isPlanetsLoaded && tile instanceof TileEntityLaunchController) {
            ((TileEntityLaunchController) tile).setAttachedPad(this);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ILandingPadAttachable(micdoodle8.mods.galacticraft.api.tile.ILandingPadAttachable) BlockPos(net.minecraft.util.BlockPos) TileEntityLaunchController(micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController)

Example 4 with TileEntityLaunchController

use of micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController in project Galacticraft by micdoodle8.

the class PacketSimpleMars method handleClientSide.

@SideOnly(Side.CLIENT)
@Override
public void handleClientSide(EntityPlayer player) {
    EntityPlayerSP playerBaseClient = null;
    if (player instanceof EntityPlayerSP) {
        playerBaseClient = (EntityPlayerSP) player;
    }
    switch(this.type) {
        case C_OPEN_CUSTOM_GUI:
            int entityID = 0;
            Entity entity = null;
            switch((Integer) this.data.get(1)) {
                case 0:
                    entityID = (Integer) this.data.get(2);
                    entity = player.worldObj.getEntityByID(entityID);
                    if (entity != null && entity instanceof EntitySlimeling) {
                        FMLClientHandler.instance().getClient().displayGuiScreen(new GuiSlimelingInventory(player, (EntitySlimeling) entity));
                    }
                    player.openContainer.windowId = (Integer) this.data.get(0);
                    break;
                case 1:
                    entityID = (Integer) this.data.get(2);
                    entity = player.worldObj.getEntityByID(entityID);
                    if (entity != null && entity instanceof EntityCargoRocket) {
                        FMLClientHandler.instance().getClient().displayGuiScreen(new GuiCargoRocket(player.inventory, (EntityCargoRocket) entity));
                    }
                    player.openContainer.windowId = (Integer) this.data.get(0);
                    break;
            }
            break;
        case C_OPEN_CUSTOM_GUI_TILE:
            BlockPos pos;
            TileEntity tile;
            switch((Integer) this.data.get(1)) {
                case 0:
                    pos = (BlockPos) this.data.get(2);
                    tile = player.worldObj.getTileEntity(pos);
                    if (tile != null && tile instanceof TileEntityLaunchController) {
                        FMLClientHandler.instance().getClient().displayGuiScreen(new GuiLaunchControllerAdvanced(player.inventory, (TileEntityLaunchController) tile));
                    }
                    player.openContainer.windowId = (Integer) this.data.get(0);
                    break;
            }
            break;
        case C_BEGIN_CRYOGENIC_SLEEP:
            pos = (BlockPos) this.data.get(0);
            tile = player.worldObj.getTileEntity(pos);
            if (tile instanceof TileEntityCryogenicChamber) {
                ((TileEntityCryogenicChamber) tile).sleepInBedAt(player, pos.getX(), pos.getY(), pos.getZ());
            }
        default:
            break;
    }
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityCryogenicChamber(micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityCryogenicChamber) GuiLaunchControllerAdvanced(micdoodle8.mods.galacticraft.planets.mars.client.gui.GuiLaunchControllerAdvanced) GuiSlimelingInventory(micdoodle8.mods.galacticraft.planets.mars.client.gui.GuiSlimelingInventory) EntityCargoRocket(micdoodle8.mods.galacticraft.planets.mars.entities.EntityCargoRocket) TileEntity(net.minecraft.tileentity.TileEntity) EntitySlimeling(micdoodle8.mods.galacticraft.planets.mars.entities.EntitySlimeling) BlockPos(net.minecraft.util.BlockPos) GuiCargoRocket(micdoodle8.mods.galacticraft.planets.mars.client.gui.GuiCargoRocket) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) TileEntityLaunchController(micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with TileEntityLaunchController

use of micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController in project Galacticraft by micdoodle8.

the class MarsUtil method openAdvancedLaunchController.

public static void openAdvancedLaunchController(EntityPlayerMP player, TileEntityLaunchController launchController) {
    player.getNextWindowId();
    player.closeContainer();
    int windowId = player.currentWindowId;
    GalacticraftCore.packetPipeline.sendTo(new PacketSimpleMars(EnumSimplePacketMars.C_OPEN_CUSTOM_GUI_TILE, GCCoreUtil.getDimensionID(player.worldObj), new Object[] { windowId, 0, launchController.getPos() }), player);
    player.openContainer = new ContainerLaunchControllerAdvanced(player.inventory, launchController, player);
    player.openContainer.windowId = windowId;
    player.openContainer.onCraftGuiOpened(player);
}
Also used : ContainerLaunchControllerAdvanced(micdoodle8.mods.galacticraft.planets.mars.inventory.ContainerLaunchControllerAdvanced) PacketSimpleMars(micdoodle8.mods.galacticraft.planets.mars.network.PacketSimpleMars)

Aggregations

TileEntityLaunchController (micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController)4 TileEntity (net.minecraft.tileentity.TileEntity)4 BlockPos (net.minecraft.util.BlockPos)3 EntityCargoRocket (micdoodle8.mods.galacticraft.planets.mars.entities.EntityCargoRocket)2 EntitySlimeling (micdoodle8.mods.galacticraft.planets.mars.entities.EntitySlimeling)2 Entity (net.minecraft.entity.Entity)2 ILandingPadAttachable (micdoodle8.mods.galacticraft.api.tile.ILandingPadAttachable)1 EventWakePlayer (micdoodle8.mods.galacticraft.core.event.EventWakePlayer)1 IChunkLoader (micdoodle8.mods.galacticraft.core.world.IChunkLoader)1 GuiCargoRocket (micdoodle8.mods.galacticraft.planets.mars.client.gui.GuiCargoRocket)1 GuiLaunchControllerAdvanced (micdoodle8.mods.galacticraft.planets.mars.client.gui.GuiLaunchControllerAdvanced)1 GuiSlimelingInventory (micdoodle8.mods.galacticraft.planets.mars.client.gui.GuiSlimelingInventory)1 ContainerLaunchControllerAdvanced (micdoodle8.mods.galacticraft.planets.mars.inventory.ContainerLaunchControllerAdvanced)1 PacketSimpleMars (micdoodle8.mods.galacticraft.planets.mars.network.PacketSimpleMars)1 TileEntityCryogenicChamber (micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityCryogenicChamber)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1