Search in sources :

Example 1 with TeleporterSpaceNether

use of stevekung.mods.moreplanets.utils.TeleporterSpaceNether in project MorePlanets by SteveKunG.

the class PacketSimpleMP method handleServerSide.

@Override
public void handleServerSide(EntityPlayer player) {
    EntityPlayerMP playerMP = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
    GCPlayerStats stats = GCPlayerStats.get(playerMP);
    World world = player.world;
    TileEntity tile;
    String type;
    switch(this.type) {
        case S_BLACK_HOLE_STORAGE_OPTION:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            type = (String) this.data.get(1);
            if (tile instanceof TileEntityBlackHoleStorage) {
                TileEntityBlackHoleStorage storage = (TileEntityBlackHoleStorage) tile;
                switch(type) {
                    case "disable":
                        storage.disableBlackHole = !storage.disableBlackHole;
                        break;
                    case "collect_mode":
                        storage.modeInt++;
                        storage.modeInt %= 3;
                        switch(storage.modeInt) {
                            case 0:
                                storage.collectMode = "item";
                                break;
                            case 1:
                                storage.collectMode = "xp";
                                break;
                            case 2:
                                storage.collectMode = "item_and_xp";
                                break;
                        }
                        break;
                    case "use_hopper":
                        storage.useHopper = !storage.useHopper;
                        break;
                }
            }
            break;
        case S_SHIELD_VISIBLE:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                shield.setBubbleVisible((boolean) this.data.get(1));
            }
            break;
        case S_ENABLE_SHIELD:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                shield.enableShield = !shield.enableShield;
            }
            break;
        case S_ENABLE_SHIELD_DAMAGE:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                shield.enableDamage = !shield.enableDamage;
            }
            break;
        case S_SHIELD_GENERATOR_OPTION:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            int value = (int) this.data.get(1);
            type = (String) this.data.get(2);
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                switch(type) {
                    case "damage":
                        shield.shieldDamage = value;
                        break;
                    case "size":
                        shield.maxShieldSize = value;
                        break;
                }
            }
            break;
        case S_SWITCH_SHIELD_GENERATOR_GUI:
            tile = player.world.getTileEntity((BlockPos) this.data.get(0));
            boolean isConfig = (boolean) this.data.get(1);
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                PacketSimpleMP.openShieldGeneratorConfig(playerMP, shield, isConfig);
            }
            break;
        case S_FAILED_UNLOCK_CHEST:
            if (stats.getChatCooldown() == 0) {
                player.sendMessage(new TextComponentString(LangUtils.translate("gui.valid_key.message", this.data.get(0))));
                stats.setChatCooldown(100);
            }
            break;
        case S_START_SURVIVAL_PLANET:
            if (WorldTickEventHandler.survivalPlanetData != null && !WorldTickEventHandler.survivalPlanetData.hasSurvivalPlanetData) {
                int sourceDimId = (int) this.data.get(0);
                String celestialName = (String) this.data.get(1);
                LoggerMP.info("Start survival planet at: {}, Dimension: {}", celestialName, WorldUtil.getProviderForNameServer(celestialName).getDimension());
                WorldTickEventHandler.survivalPlanetData.hasSurvivalPlanetData = true;
                WorldTickEventHandler.survivalPlanetData.survivalPlanetName = celestialName;
                WorldTickEventHandler.survivalPlanetData.setDirty(true);
                TeleportUtils.teleportPlayerToPlanet(playerMP, playerMP.getServer(), sourceDimId, WorldUtil.getProviderForNameServer(celestialName).getDimension());
            }
            break;
        case S_UPDATE_NIBIRU_WEATHER:
            int i = (300 + world.rand.nextInt(600)) * 20;
            boolean thunder = (boolean) this.data.get(0);
            WorldInfo worldinfo = playerMP.server.worlds[0].getWorldInfo();
            worldinfo.setCleanWeatherTime(0);
            worldinfo.setRainTime(i);
            worldinfo.setThunderTime(i);
            worldinfo.setRaining(true);
            worldinfo.setThundering(thunder);
            break;
        case S_SAVE_DISABLE_MESSAGE:
            if (WorldTickEventHandler.survivalPlanetData != null && !WorldTickEventHandler.survivalPlanetData.disableMessage) {
                WorldTickEventHandler.survivalPlanetData.disableMessage = true;
                WorldTickEventHandler.survivalPlanetData.setDirty(true);
            }
            break;
        case S_TRANSFER_PLAYER:
            int dimID = (int) this.data.get(0);
            playerMP.server.getPlayerList().transferPlayerToDimension(playerMP, dimID, new TeleporterSpaceNether(playerMP.server.getWorld(dimID), player.getPosition(), player.world.provider));
            GalacticraftCore.packetPipeline.sendTo(new PacketSimpleMP(EnumSimplePacketMP.C_RELOAD_RENDERER, player.dimension), playerMP);
            break;
        default:
            break;
    }
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) TextComponentString(net.minecraft.util.text.TextComponentString) World(net.minecraft.world.World) TeleporterSpaceNether(stevekung.mods.moreplanets.utils.TeleporterSpaceNether) TileEntityBlackHoleStorage(stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage) TextComponentString(net.minecraft.util.text.TextComponentString) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityShieldGenerator(stevekung.mods.moreplanets.tileentity.TileEntityShieldGenerator) WorldInfo(net.minecraft.world.storage.WorldInfo) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 TextComponentString (net.minecraft.util.text.TextComponentString)1 World (net.minecraft.world.World)1 WorldInfo (net.minecraft.world.storage.WorldInfo)1 TileEntityBlackHoleStorage (stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage)1 TileEntityShieldGenerator (stevekung.mods.moreplanets.tileentity.TileEntityShieldGenerator)1 TeleporterSpaceNether (stevekung.mods.moreplanets.utils.TeleporterSpaceNether)1