Search in sources :

Example 1 with EventWakePlayer

use of micdoodle8.mods.galacticraft.core.event.EventWakePlayer 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 2 with EventWakePlayer

use of micdoodle8.mods.galacticraft.core.event.EventWakePlayer in project Galacticraft by micdoodle8.

the class PlayerServer method wakeUpPlayer.

public boolean wakeUpPlayer(EntityPlayerMP player, boolean par1, boolean par2, boolean par3, boolean bypass) {
    BlockPos c = player.playerLocation;
    if (c != null) {
        EventWakePlayer event = new EventWakePlayer(player, c, par1, par2, par3, bypass);
        MinecraftForge.EVENT_BUS.post(event);
        if (bypass || event.result == null || event.result == EntityPlayer.EnumStatus.OK) {
            return false;
        }
    }
    return true;
}
Also used : BlockPos(net.minecraft.util.BlockPos) EventWakePlayer(micdoodle8.mods.galacticraft.core.event.EventWakePlayer)

Example 3 with EventWakePlayer

use of micdoodle8.mods.galacticraft.core.event.EventWakePlayer in project Galacticraft by micdoodle8.

the class PlayerClient method wakeUpPlayer.

public boolean wakeUpPlayer(EntityPlayerSP player, boolean par1, boolean par2, boolean par3, boolean bypass) {
    BlockPos c = player.playerLocation;
    if (c != null) {
        EventWakePlayer event = new EventWakePlayer(player, c, par1, par2, par3, bypass);
        MinecraftForge.EVENT_BUS.post(event);
        if (bypass || event.result == null || event.result == EntityPlayer.EnumStatus.OK) {
            return false;
        }
    }
    return true;
}
Also used : EventWakePlayer(micdoodle8.mods.galacticraft.core.event.EventWakePlayer)

Example 4 with EventWakePlayer

use of micdoodle8.mods.galacticraft.core.event.EventWakePlayer in project Galacticraft by micdoodle8.

the class EventHandlerGC method onLeaveBedButtonClicked.

// @SideOnly(Side.CLIENT)
// @SubscribeEvent
// public void onMinecraftLoaded(MinecraftLoadedEvent event)
// {
// ;
// }
// @SideOnly(Side.CLIENT)
// @SubscribeEvent
// public void onSoundLoad(SoundLoadEvent event)
// {
// event.manager.addSound(Constants.TEXTURE_PREFIX + "ambience/scaryscape.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "ambience/singledrip1.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "ambience/singledrip2.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "ambience/singledrip3.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "ambience/singledrip4.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "ambience/singledrip5.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "ambience/singledrip6.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "ambience/singledrip7.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "ambience/singledrip8.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "entity/bossdeath.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "entity/bosslaugh.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "entity/bossliving.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "entity/slime_death.ogg");
// ClientProxyCore.newMusic.add(this.func_110654_c(event.manager.soundPoolMusic, Constants.TEXTURE_PREFIX + "music/mars_JC.ogg"));
// ClientProxyCore.newMusic.add(this.func_110654_c(event.manager.soundPoolMusic, Constants.TEXTURE_PREFIX + "music/mimas_JC.ogg"));
// ClientProxyCore.newMusic.add(this.func_110654_c(event.manager.soundPoolMusic, Constants.TEXTURE_PREFIX + "music/orbit_JC.ogg"));
// ClientProxyCore.newMusic.add(this.func_110654_c(event.manager.soundPoolMusic, Constants.TEXTURE_PREFIX + "music/scary_ambience.ogg"));
// ClientProxyCore.newMusic.add(this.func_110654_c(event.manager.soundPoolMusic, Constants.TEXTURE_PREFIX + "music/spacerace_JC.ogg"));
// event.manager.addSound(Constants.TEXTURE_PREFIX + "player/closeairlock.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "player/openairlock.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "player/parachute.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "player/unlockchest.ogg");
// event.manager.addSound(Constants.TEXTURE_PREFIX + "shuttle/shuttle.ogg");
// }
// 
// @SideOnly(Side.CLIENT)
// private SoundPoolEntry func_110654_c(SoundPool pool, String par1Str)
// {
// try
// {
// ResourceLocation resourcelocation = new ResourceLocation(par1Str);
// String s1 = String.format("%s:%s:%s/%s", new Object[] { "mcsounddomain", resourcelocation.getResourceDomain(), "sound", resourcelocation.getResourcePath() });
// SoundPoolProtocolHandler soundpoolprotocolhandler = new SoundPoolProtocolHandler(pool);
// return new SoundPoolEntry(par1Str, new URL((URL) null, s1, soundpoolprotocolhandler));
// }
// catch (MalformedURLException e)
// {
// e.printStackTrace();
// }
// 
// return null;
// } TODO Fix sounds
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onLeaveBedButtonClicked(SleepCancelledEvent event) {
    EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
    BlockPos c = player.playerLocation;
    if (c != null) {
        EventWakePlayer event0 = new EventWakePlayer(player, c, true, true, false, true);
        MinecraftForge.EVENT_BUS.post(event0);
        player.wakeUpPlayer(true, true, false);
        if (player.worldObj.isRemote && GalacticraftCore.isPlanetsLoaded) {
            GalacticraftCore.packetPipeline.sendToServer(new PacketSimpleMars(PacketSimpleMars.EnumSimplePacketMars.S_WAKE_PLAYER, GCCoreUtil.getDimensionID(player.worldObj), new Object[] {}));
        }
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) PacketSimpleMars(micdoodle8.mods.galacticraft.planets.mars.network.PacketSimpleMars) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

EventWakePlayer (micdoodle8.mods.galacticraft.core.event.EventWakePlayer)3 BlockPos (net.minecraft.util.BlockPos)2 EntityCargoRocket (micdoodle8.mods.galacticraft.planets.mars.entities.EntityCargoRocket)1 EntitySlimeling (micdoodle8.mods.galacticraft.planets.mars.entities.EntitySlimeling)1 PacketSimpleMars (micdoodle8.mods.galacticraft.planets.mars.network.PacketSimpleMars)1 TileEntityLaunchController (micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController)1 Entity (net.minecraft.entity.Entity)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 TileEntity (net.minecraft.tileentity.TileEntity)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1