Search in sources :

Example 1 with EntitySlimeling

use of micdoodle8.mods.galacticraft.planets.mars.entities.EntitySlimeling in project Galacticraft by micdoodle8.

the class MarsUtil method openSlimelingInventory.

public static void openSlimelingInventory(EntityPlayerMP player, EntitySlimeling slimeling) {
    player.getNextWindowId();
    player.closeContainer();
    int windowId = player.currentWindowId;
    GalacticraftCore.packetPipeline.sendTo(new PacketSimpleMars(EnumSimplePacketMars.C_OPEN_CUSTOM_GUI, GCCoreUtil.getDimensionID(player.worldObj), new Object[] { windowId, 0, slimeling.getEntityId() }), player);
    player.openContainer = new ContainerSlimeling(player.inventory, slimeling, player);
    player.openContainer.windowId = windowId;
    player.openContainer.onCraftGuiOpened(player);
}
Also used : ContainerSlimeling(micdoodle8.mods.galacticraft.planets.mars.inventory.ContainerSlimeling) PacketSimpleMars(micdoodle8.mods.galacticraft.planets.mars.network.PacketSimpleMars)

Example 2 with EntitySlimeling

use of micdoodle8.mods.galacticraft.planets.mars.entities.EntitySlimeling 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 EntitySlimeling

use of micdoodle8.mods.galacticraft.planets.mars.entities.EntitySlimeling in project Galacticraft by micdoodle8.

the class EntitySlimeling method spawnBabyAnimal.

public EntitySlimeling spawnBabyAnimal(EntityAgeable par1EntityAgeable) {
    if (par1EntityAgeable instanceof EntitySlimeling) {
        EntitySlimeling otherSlimeling = (EntitySlimeling) par1EntityAgeable;
        Vector3 colorParentA = new Vector3(this.getColorRed(), this.getColorGreen(), this.getColorBlue());
        Vector3 colorParentB = new Vector3(otherSlimeling.getColorRed(), otherSlimeling.getColorGreen(), otherSlimeling.getColorBlue());
        Vector3 newColor = ColorUtil.addColorsRealistically(colorParentA, colorParentB);
        newColor.x = Math.max(Math.min(newColor.x, 1.0F), 0);
        newColor.y = Math.max(Math.min(newColor.y, 1.0F), 0);
        newColor.z = Math.max(Math.min(newColor.z, 1.0F), 0);
        EntitySlimeling newSlimeling = new EntitySlimeling(this.worldObj, (float) newColor.x, (float) newColor.y, (float) newColor.z);
        String s = this.getOwnerId();
        if (s != null && s.trim().length() > 0) {
            newSlimeling.setOwnerId(s);
            newSlimeling.setTamed(true);
        }
        return newSlimeling;
    }
    return null;
}
Also used : Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 4 with EntitySlimeling

use of micdoodle8.mods.galacticraft.planets.mars.entities.EntitySlimeling 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 EntitySlimeling

use of micdoodle8.mods.galacticraft.planets.mars.entities.EntitySlimeling in project Galacticraft by micdoodle8.

the class ContainerSlimeling method addSlots.

public static void addSlots(ContainerSlimeling container, InventoryPlayer playerInventory, EntitySlimeling slimeling) {
    Slot slot = new SlotSpecific(slimeling.slimelingInventory, 1, 9, 30, new ItemStack(MarsItems.marsItemBasic, 1, 4));
    container.addSlotToContainer(slot);
    int var3;
    for (var3 = 0; var3 < 3; ++var3) {
        for (int var4 = 0; var4 < 9; ++var4) {
            slot = new Slot(playerInventory, var4 + var3 * 9 + 9, 8 + var4 * 18, 129 + var3 * 18);
            container.addSlotToContainer(slot);
        }
    }
    for (var3 = 0; var3 < 9; ++var3) {
        slot = new Slot(playerInventory, var3, 8 + var3 * 18, 187);
        container.addSlotToContainer(slot);
    }
}
Also used : SlotSpecific(micdoodle8.mods.galacticraft.core.inventory.SlotSpecific) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityCargoRocket (micdoodle8.mods.galacticraft.planets.mars.entities.EntityCargoRocket)2 EntitySlimeling (micdoodle8.mods.galacticraft.planets.mars.entities.EntitySlimeling)2 TileEntityLaunchController (micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController)2 Entity (net.minecraft.entity.Entity)2 TileEntity (net.minecraft.tileentity.TileEntity)2 BlockPos (net.minecraft.util.BlockPos)2 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)1 EventWakePlayer (micdoodle8.mods.galacticraft.core.event.EventWakePlayer)1 SlotSpecific (micdoodle8.mods.galacticraft.core.inventory.SlotSpecific)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 ContainerSlimeling (micdoodle8.mods.galacticraft.planets.mars.inventory.ContainerSlimeling)1 InventorySlimeling (micdoodle8.mods.galacticraft.planets.mars.inventory.InventorySlimeling)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 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 Slot (net.minecraft.inventory.Slot)1 ItemStack (net.minecraft.item.ItemStack)1