use of net.minecraft.entity.player.EntityPlayerMP in project MorePlanets by SteveKunG.
the class PacketSimpleMP method handleServerSide.
@Override
public void handleServerSide(EntityPlayer player) {
EntityPlayerMP playerMP = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
World world = player.world;
TileEntity tile;
BlockPos pos;
String type;
switch(this.type) {
case S_FIRE_EXTINGUISH:
pos = (BlockPos) this.data.get(0);
world.playSound(null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
world.setBlockToAir(pos);
break;
case S_RESPAWN_PLAYER_NETHER:
if (world instanceof WorldServer) {
WorldServer worldOld = (WorldServer) world;
WorldServer worldNew = WorldDimensionHelper.getStartWorld(worldOld);
BlockPos spawnPos = worldNew.getTopSolidOrLiquidBlock(worldNew.getSpawnPoint());
TeleportUtil.setWarpDimension(playerMP, worldNew, spawnPos.getX(), spawnPos.getY(), spawnPos.getZ(), WorldUtil.getProviderForNameServer(WorldTickEventHandler.startedDimensionData.planetToBack).getDimension(), true);
player.respawnPlayer();
player.closeScreen();
}
break;
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;
default:
break;
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project MorePlanets by SteveKunG.
the class PacketSimpleMP method sendToAllAround.
public static void sendToAllAround(PacketSimpleMP packet, World world, int dimID, BlockPos pos, double radius) {
double x = pos.getX() + 0.5D;
double y = pos.getY() + 0.5D;
double z = pos.getZ() + 0.5D;
double r2 = radius * radius;
for (EntityPlayer player : world.playerEntities) {
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
if (playerMP.dimension == dimID) {
double dx = x - playerMP.posX;
double dy = y - playerMP.posY;
double dz = z - playerMP.posZ;
if (dx * dx + dy * dy + dz * dz < r2) {
GalacticraftCore.packetPipeline.sendTo(packet, playerMP);
}
}
}
}
}
use of net.minecraft.entity.player.EntityPlayerMP 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));
}
}
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project MorePlanets by SteveKunG.
the class TileEntityVeinPortal method update.
@Override
public void update() {
super.update();
if (this.age < 5L) {
this.age++;
}
if (!this.world.isRemote) {
if (this.age < 5L) {
ArrayList<TileEntity> attachedList = new ArrayList<>();
for (int x = this.getPos().getX() - 1; x < this.getPos().getX() + 2; x++) {
for (int z = this.getPos().getZ() - 1; z < this.getPos().getZ() + 2; z++) {
TileEntity tile = this.world.getTileEntity(new BlockPos(x, this.getPos().getY(), z));
if (tile instanceof TileEntityVeinPortal) {
attachedList.add(tile);
}
}
}
if (attachedList.size() == 9) {
this.world.setBlockState(this.getPos(), NibiruBlocks.VEIN_PORTAL.getDefaultState(), 3);
TileEntityVeinPortal portal = this;
this.isMiddle = true;
this.world.setTileEntity(this.getPos(), portal);
for (int x = -1; x < 2; x++) {
for (int z = -1; z < 2; z++) {
BlockPos vecToAdd = new BlockPos(this.getPos().getX() + x, this.getPos().getY(), this.getPos().getZ() + z);
if (!vecToAdd.equals(this.getPos())) {
this.world.setBlockState(vecToAdd, NibiruBlocks.VEIN_PORTAL.getDefaultState(), 3);
this.delayToTeleport = 120;
}
}
}
}
if (this.isMiddle) {
if (!this.spawnedBoss) {
EntityVeinFloater vein = new EntityVeinFloater(this.world);
vein.setLocationAndAngles(this.getPos().getX() + 0.5D, this.getPos().getY() + 64, this.getPos().getZ() + 0.5D, 0.0F, 0.0F);
this.world.spawnEntity(vein);
this.spawnedBoss = true;
}
for (int yRender = this.pos.getY(); yRender < 99; yRender++) {
this.world.setBlockToAir(new BlockPos(this.pos.getX(), yRender + 1, this.pos.getZ()));
this.world.notifyBlockUpdate(this.pos, this.world.getBlockState(this.pos), NibiruBlocks.VEIN_PORTAL.getDefaultState(), 3);
}
}
}
}
if (this.isMiddle) {
EntityPlayer player = this.world.getClosestPlayer(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 64, false);
List<EntityVeinFloater> vein = this.world.getEntitiesWithinAABB(EntityVeinFloater.class, new AxisAlignedBB(this.getPos().getX() - 256, this.getPos().getY() - 256, this.getPos().getZ() - 256, this.getPos().getX() + 256, this.getPos().getY() + 256, this.getPos().getZ() + 256));
if (this.delayToTeleport > 0) {
this.delayToTeleport--;
}
if (this.delayToTeleport == 1) {
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
playerMP.dismountRidingEntity();
playerMP.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 120, 10));
playerMP.connection.setPlayerLocation(playerMP.posX, playerMP.posY + 64, playerMP.posZ, playerMP.rotationYaw, playerMP.rotationPitch);
}
}
if (this.renderTicks % 50 == 0 && vein.isEmpty()) {
this.isMiddle = false;
}
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project MorePlanets by SteveKunG.
the class ItemCreativeSpaceKit method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if (player instanceof EntityPlayerMP) {
GCPlayerStats stats = GCPlayerStats.get(player);
// Oxygen Mask
stats.getExtendedInventory().setInventorySlotContents(0, new ItemStack(GCItems.oxMask));
// Oxygen Gear
stats.getExtendedInventory().setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear));
// Creative Oxygen Tank
stats.getExtendedInventory().setInventorySlotContents(2, new ItemStack(GCItems.oxygenCanisterInfinite));
// Creative Oxygen Tank
stats.getExtendedInventory().setInventorySlotContents(3, new ItemStack(GCItems.oxygenCanisterInfinite));
// Parachute
stats.getExtendedInventory().setInventorySlotContents(4, new ItemStack(GCItems.parachute));
// Frequency Module
stats.getExtendedInventory().setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
// Thermal Armor Tier 2
stats.getExtendedInventory().setInventorySlotContents(6, new ItemStack(VenusItems.thermalPaddingTier2, 1, 0));
// Thermal Armor Tier 2
stats.getExtendedInventory().setInventorySlotContents(7, new ItemStack(VenusItems.thermalPaddingTier2, 1, 1));
// Thermal Armor Tier 2
stats.getExtendedInventory().setInventorySlotContents(8, new ItemStack(VenusItems.thermalPaddingTier2, 1, 2));
// Thermal Armor Tier 2
stats.getExtendedInventory().setInventorySlotContents(9, new ItemStack(VenusItems.thermalPaddingTier2, 1, 3));
// Shield Controller
stats.getExtendedInventory().setInventorySlotContents(10, new ItemStack(VenusItems.basicItem, 1, 0));
}
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
}
Aggregations