Search in sources :

Example 6 with PacketSimpleMP

use of stevekung.mods.moreplanets.network.PacketSimpleMP in project MorePlanets by SteveKunG.

the class EntityEventHandler method onLivingDeath.

@SubscribeEvent
public void onLivingDeath(LivingDeathEvent event) {
    EntityLivingBase living = event.getEntityLiving();
    int id = GCCoreUtil.getDimensionID(living.world);
    PacketSimpleMP.sendToAllAround(new PacketSimpleMP(EnumSimplePacketMP.C_REMOVE_ENTITY_ID, id, String.valueOf(living.getEntityId())), living.world, id, living.getPosition(), 64);
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) PacketSimpleMP(stevekung.mods.moreplanets.network.PacketSimpleMP) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 7 with PacketSimpleMP

use of stevekung.mods.moreplanets.network.PacketSimpleMP in project MorePlanets by SteveKunG.

the class EntityEventHandler method onLivingUpdate.

@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {
    EntityLivingBase living = event.getEntityLiving();
    World world = living.world;
    if (living.isDead) {
        int id = GCCoreUtil.getDimensionID(living.world);
        PacketSimpleMP.sendToAllAround(new PacketSimpleMP(EnumSimplePacketMP.C_REMOVE_ENTITY_ID, id, String.valueOf(living.getEntityId())), living.world, id, living.getPosition(), 64);
    }
    if (living instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) living;
        if (ConfigManagerMP.enableStartedPlanet && !WorldTickEventHandler.startedDimensionData.startedDimension && !(ConfigManagerMP.startedPlanet.equals("planet.") || ConfigManagerMP.startedPlanet.equals("moon.") || ConfigManagerMP.startedPlanet.equals("satellite."))) {
            MPLog.debug("Start teleporting player to dimension {}", ConfigManagerMP.startedPlanet);
            TeleportUtil.startNewDimension(player);
            WorldTickEventHandler.startedDimensionData.startedDimension = true;
            WorldTickEventHandler.startedDimensionData.planetToBack = ConfigManagerMP.startedPlanet;
            WorldTickEventHandler.startedDimensionData.setDirty(true);
        }
        if (player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) || this.isInOxygen(world, player)) {
            player.removePotionEffect(MPPotions.INFECTED_SPORE);
        }
        if (player.isPotionActive(MPPotions.DARK_ENERGY_PROTECTION)) {
            player.removePotionEffect(MPPotions.DARK_ENERGY);
        }
        if (world.provider instanceof WorldProviderNibiru) {
            if (world.isRainingAt(player.getPosition()) && !this.isGodPlayer(player) && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && world.getBiome(player.getPosition()) != MPBiomes.GREEN_VEIN) {
                player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
            }
            if (player.ticksExisted % 128 == 0 && !this.isGodPlayer(player) && !this.isInOxygen(world, player) && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && world.getBiome(player.getPosition()) != MPBiomes.GREEN_VEIN) {
                player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
            }
        }
        if (world.provider instanceof IMeteorType) {
        // this.spawnMeteor(world, player, (IMeteorType)world.provider);
        }
    }
    if (world.provider instanceof WorldProviderNibiru) {
        if (!(living instanceof EntityPlayer) && !EntityEffectHelper.isGalacticraftMob(living) && !(living instanceof EntityJuicer)) {
            if (living.ticksExisted % 128 == 0 && world.getBiome(living.getPosition()) != MPBiomes.GREEN_VEIN) {
                living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
            }
            if (world.isRainingAt(living.getPosition()) && world.getBiome(living.getPosition()) != MPBiomes.GREEN_VEIN) {
                living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
            }
        }
    }
}
Also used : WorldProviderNibiru(stevekung.mods.moreplanets.module.planets.nibiru.dimension.WorldProviderNibiru) PotionEffect(net.minecraft.potion.PotionEffect) EntityJuicer(micdoodle8.mods.galacticraft.planets.venus.entities.EntityJuicer) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PacketSimpleMP(stevekung.mods.moreplanets.network.PacketSimpleMP) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) IMeteorType(stevekung.mods.moreplanets.world.IMeteorType) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 8 with PacketSimpleMP

use of stevekung.mods.moreplanets.network.PacketSimpleMP in project MorePlanets by SteveKunG.

the class GeneralEventHandler method onLeftClickBlock.

@SubscribeEvent
public void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event) {
    BlockPos firePos = event.getPos().offset(event.getFace());
    if (event.getWorld().getBlockState(firePos).getBlock() instanceof IFireBlock) {
        GalacticraftCore.packetPipeline.sendToServer(new PacketSimpleMP(EnumSimplePacketMP.S_FIRE_EXTINGUISH, GCCoreUtil.getDimensionID(event.getWorld()), firePos));
        event.setCanceled(true);
    }
}
Also used : IFireBlock(stevekung.mods.moreplanets.util.blocks.IFireBlock) BlockPos(net.minecraft.util.math.BlockPos) PacketSimpleMP(stevekung.mods.moreplanets.network.PacketSimpleMP) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 9 with PacketSimpleMP

use of stevekung.mods.moreplanets.network.PacketSimpleMP in project MorePlanets by SteveKunG.

the class GuiShieldGeneratorConfig method updateScreen.

@Override
public void updateScreen() {
    this.shieldDamageText.updateCursorCounter();
    this.shieldSizeText.updateCursorCounter();
    if (this.messageTicks > 0) {
        this.messageTicks--;
    }
    if (this.shieldDamageText.getText().isEmpty() || this.shieldSizeText.getText().isEmpty()) {
        this.buttonDone.enabled = false;
    } else {
        this.buttonDone.enabled = true;
    }
    if (this.tempDamage > this.tile.maxShieldDamage) {
        this.tempDamage = this.tile.maxShieldDamage;
        this.shieldDamageText.setText(String.valueOf(this.tempDamage));
        GalacticraftCore.packetPipeline.sendToServer(new PacketSimpleMP(EnumSimplePacketMP.S_SHIELD_GENERATOR_OPTION, GCCoreUtil.getDimensionID(this.tile.getWorld()), this.tile.getPos(), this.tempDamage, "damage"));
    }
    if (this.tempSize > this.tile.maxShieldSizeUpgrade) {
        this.tempSize = this.tile.maxShieldSizeUpgrade;
        this.shieldSizeText.setText(String.valueOf(this.tempSize));
        GalacticraftCore.packetPipeline.sendToServer(new PacketSimpleMP(EnumSimplePacketMP.S_SHIELD_GENERATOR_OPTION, GCCoreUtil.getDimensionID(this.tile.getWorld()), this.tile.getPos(), this.tempSize, "size"));
    }
}
Also used : PacketSimpleMP(stevekung.mods.moreplanets.network.PacketSimpleMP)

Example 10 with PacketSimpleMP

use of stevekung.mods.moreplanets.network.PacketSimpleMP in project MorePlanets by SteveKunG.

the class GuiShieldGeneratorConfig method initGui.

@Override
public void initGui() {
    super.initGui();
    Keyboard.enableRepeatEvents(true);
    int width = (this.width - this.xSize) / 2;
    int height = (this.height - this.ySize) / 2;
    this.tempDamage = this.tile.shieldDamage;
    this.tempSize = this.tile.maxShieldSize;
    List<String> batterySlotDesc = new ArrayList<>();
    batterySlotDesc.add(GCCoreUtil.translate("gui.battery_slot.desc.0"));
    batterySlotDesc.add(GCCoreUtil.translate("gui.battery_slot.desc.1"));
    this.infoRegions.add(new GuiElementInfoRegionMP(width + 151, height + 77, 18, 18, batterySlotDesc, this.width, this.height, this));
    this.infoRegions.add(new GuiElementInfoRegionMP(width + 151, height + 59, 18, 18, Arrays.asList(GCCoreUtil.translate("gui.shield_capacity_upgrade.desc.0"), GCCoreUtil.translate("gui.shield_capacity_upgrade.desc.1")), this.width, this.height, this));
    this.infoRegions.add(new GuiElementInfoRegionMP(width + 151, height + 41, 18, 18, Arrays.asList(GCCoreUtil.translate("gui.shield_size_upgrade.desc.0"), GCCoreUtil.translate("gui.shield_size_upgrade.desc.1")), this.width, this.height, this));
    this.infoRegions.add(new GuiElementInfoRegionMP(width + 151, height + 23, 18, 18, Arrays.asList(GCCoreUtil.translate("gui.shield_damage_upgrade.desc.0"), GCCoreUtil.translate("gui.shield_damage_upgrade.desc.1")), this.width, this.height, this));
    this.infoRegions.add(new GuiElementInfoRegionMP(width + 60, height + 70, 13, 13, Arrays.asList(GCCoreUtil.translate("gui.shield_visible.desc")), this.width, this.height, this));
    this.infoRegions.add(new GuiElementInfoRegionMP(width + 80, height + 70, 13, 13, Arrays.asList(GCCoreUtil.translate("gui.enable_shield.desc")), this.width, this.height, this));
    this.infoRegions.add(new GuiElementInfoRegionMP(width + 100, height + 70, 13, 13, Arrays.asList(GCCoreUtil.translate("gui.enable_shield_damage.desc")), this.width, this.height, this));
    this.checkboxRenderShield = new GuiElementCheckbox(100, this, width + 60, height + 70, "");
    this.checkboxEnableShield = new GuiElementCheckbox(101, this, width + 80, height + 70, "");
    this.checkboxEnableDamage = new GuiElementCheckbox(102, this, width + 100, height + 70, "");
    this.buttonList.add(this.checkboxRenderShield);
    this.buttonList.add(this.checkboxEnableShield);
    this.buttonList.add(this.checkboxEnableDamage);
    this.buttonList.add(this.buttonBack = new GuiButton(0, this.width / 2 - 76, this.height / 2 - 6, 72, 20, GCCoreUtil.translate("gui.button.back.name")));
    this.buttonList.add(this.buttonDone = new GuiButton(1, this.width / 2 + 4, this.height / 2 - 6, 72, 20, GCCoreUtil.translate("gui.done")));
    this.shieldDamageText = new GuiNumberField(1, this.fontRenderer, this.width / 2 - 3, this.height / 2 - 83, 30, 16);
    this.shieldDamageText.setMaxStringLength(2);
    this.shieldDamageText.setFocused(false);
    this.shieldDamageText.setCanLoseFocus(true);
    this.shieldDamageText.setEnableBackgroundDrawing(true);
    this.shieldDamageText.setTextColor(16777215);
    this.shieldDamageText.setText(String.valueOf(this.tile.shieldDamage));
    this.shieldSizeText = new GuiNumberField(2, this.fontRenderer, this.width / 2 - 3, this.height / 2 - 62, 30, 16);
    this.shieldSizeText.setMaxStringLength(2);
    this.shieldSizeText.setFocused(false);
    this.shieldSizeText.setCanLoseFocus(true);
    this.shieldSizeText.setEnableBackgroundDrawing(true);
    this.shieldSizeText.setTextColor(16777215);
    this.shieldSizeText.setText(String.valueOf(this.tile.maxShieldSize));
    if (this.tempDamage > this.tile.maxShieldDamage) {
        this.tempDamage = this.tile.maxShieldDamage;
        this.shieldDamageText.setText(String.valueOf(this.tempDamage));
        GalacticraftCore.packetPipeline.sendToServer(new PacketSimpleMP(EnumSimplePacketMP.S_SHIELD_GENERATOR_OPTION, GCCoreUtil.getDimensionID(this.tile.getWorld()), this.tile.getPos(), this.tempDamage, "damage"));
    }
    if (this.tempSize > this.tile.maxShieldSizeUpgrade) {
        this.tempSize = this.tile.maxShieldSizeUpgrade;
        this.shieldSizeText.setText(String.valueOf(this.tempSize));
        GalacticraftCore.packetPipeline.sendToServer(new PacketSimpleMP(EnumSimplePacketMP.S_SHIELD_GENERATOR_OPTION, GCCoreUtil.getDimensionID(this.tile.getWorld()), this.tile.getPos(), this.tempSize, "size"));
    }
}
Also used : GuiElementCheckbox(micdoodle8.mods.galacticraft.core.client.gui.element.GuiElementCheckbox) GuiElementInfoRegionMP(stevekung.mods.moreplanets.util.client.gui.GuiElementInfoRegionMP) GuiButton(net.minecraft.client.gui.GuiButton) GuiNumberField(stevekung.mods.moreplanets.util.client.gui.GuiNumberField) ArrayList(java.util.ArrayList) PacketSimpleMP(stevekung.mods.moreplanets.network.PacketSimpleMP)

Aggregations

PacketSimpleMP (stevekung.mods.moreplanets.network.PacketSimpleMP)15 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 TileEntity (net.minecraft.tileentity.TileEntity)2 ArrayList (java.util.ArrayList)1 GuiElementCheckbox (micdoodle8.mods.galacticraft.core.client.gui.element.GuiElementCheckbox)1 EntityJuicer (micdoodle8.mods.galacticraft.planets.venus.entities.EntityJuicer)1 GuiButton (net.minecraft.client.gui.GuiButton)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 PotionEffect (net.minecraft.potion.PotionEffect)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 WorldProviderNibiru (stevekung.mods.moreplanets.module.planets.nibiru.dimension.WorldProviderNibiru)1 TileEntityNuclearWasteGenerator (stevekung.mods.moreplanets.module.planets.nibiru.tileentity.TileEntityNuclearWasteGenerator)1 TileEntityDarkEnergyReceiver (stevekung.mods.moreplanets.tileentity.TileEntityDarkEnergyReceiver)1 TeleporterMP (stevekung.mods.moreplanets.util.TeleporterMP)1 IFireBlock (stevekung.mods.moreplanets.util.blocks.IFireBlock)1 GuiElementInfoRegionMP (stevekung.mods.moreplanets.util.client.gui.GuiElementInfoRegionMP)1 GuiNumberField (stevekung.mods.moreplanets.util.client.gui.GuiNumberField)1