use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class GuiNewSpaceRace method initGui.
@Override
public void initGui() {
float sliderR = 0;
float sliderG = 0;
float sliderB = 0;
if (this.sliderColorR != null && this.sliderColorG != null && this.sliderColorB != null) {
sliderR = this.sliderColorR.getSliderPos() / (float) this.sliderColorR.getButtonHeight();
sliderG = this.sliderColorG.getSliderPos() / (float) this.sliderColorG.getButtonHeight();
sliderB = this.sliderColorB.getSliderPos() / (float) this.sliderColorB.getButtonHeight();
}
super.initGui();
this.buttonList.clear();
if (this.initialized) {
this.buttonFlag_width = 81;
this.buttonFlag_height = 58;
this.buttonFlag_xPosition = this.width / 2 - this.buttonFlag_width / 2;
this.buttonFlag_yPosition = this.height / 2 - this.height / 3 + 10;
this.buttonTeamColor_width = 45;
this.buttonTeamColor_height = 45;
this.buttonTeamColor_xPosition = this.buttonFlag_xPosition + this.buttonFlag_width + 10;
this.buttonTeamColor_yPosition = this.buttonFlag_yPosition + this.buttonFlag_height / 2 - this.buttonTeamColor_height / 2;
this.buttonList.add(new GuiElementGradientButton(0, this.width / 2 - this.width / 3 + 15, this.height / 2 - this.height / 4 - 15, 50, 15, this.currentState == EnumSpaceRaceGui.MAIN ? GCCoreUtil.translate("gui.space_race.create.close.name") : GCCoreUtil.translate("gui.space_race.create.back.name")));
switch(this.currentState) {
case MAIN:
this.textBoxRename = new GuiElementTextBox(1, this, this.width / 2 - 75, this.buttonFlag_yPosition + this.buttonFlag_height + 10, 150, 16, GCCoreUtil.translate("gui.space_race.create.rename.name"), false, 25, true);
this.buttonList.add(this.textBoxRename);
if (this.canEdit) {
this.buttonList.add(new GuiElementGradientButton(2, this.width / 2 - 120, this.textBoxRename.yPosition + this.height / 10, 100, this.height / 10, GCCoreUtil.translate("gui.space_race.create.add_players.name")));
this.buttonList.add(new GuiElementGradientButton(3, this.width / 2 - 120, this.textBoxRename.yPosition + this.height / 10 + this.height / 10 + this.height / 50, 100, this.height / 10, GCCoreUtil.translate("gui.space_race.create.rem_players.name")));
}
GuiElementGradientButton localStats = new GuiElementGradientButton(4, this.width / 2 + (this.canEdit ? 20 : -50), this.textBoxRename.yPosition + this.height / 10, 100, this.height / 10, GCCoreUtil.translate("gui.space_race.create.server_stats.name"));
GuiElementGradientButton serverStats = new GuiElementGradientButton(5, this.width / 2 + (this.canEdit ? 20 : -50), this.textBoxRename.yPosition + this.height / 10 + this.height / 10 + this.height / 50, 100, this.height / 10, GCCoreUtil.translate("gui.space_race.create.global_stats.name"));
localStats.enabled = false;
serverStats.enabled = false;
this.buttonList.add(localStats);
this.buttonList.add(serverStats);
break;
case ADD_PLAYER:
this.buttonList.add(new GuiElementGradientButton(2, this.width / 2 - this.width / 3 + 7, this.height / 2 + this.height / 4 - 15, 64, 15, GCCoreUtil.translate("gui.space_race.create.send_invite.name")));
int xPos0 = ((GuiElementGradientButton) this.buttonList.get(0)).xPosition + ((GuiElementGradientButton) this.buttonList.get(0)).getButtonWidth() + 10;
int xPos1 = this.width / 2 + this.width / 3 - 10;
int yPos0 = this.height / 2 - this.height / 3 + 10;
int yPos1 = this.height / 2 + this.height / 3 - 10;
this.gradientListAddPlayers = new GuiElementGradientList(xPos0, yPos0, xPos1 - xPos0, yPos1 - yPos0);
break;
case REMOVE_PLAYER:
this.buttonList.add(new GuiElementGradientButton(2, this.width / 2 - this.width / 3 + 7, this.height / 2 + this.height / 4 - 15, 64, 15, GCCoreUtil.translate("gui.space_race.create.remove.name")));
int xPos0b = ((GuiElementGradientButton) this.buttonList.get(0)).xPosition + ((GuiElementGradientButton) this.buttonList.get(0)).getButtonWidth() + 10;
int xPos1b = this.width / 2 + this.width / 3 - 10;
int yPos0b = this.height / 2 - this.height / 3 + 10;
int yPos1b = this.height / 2 + this.height / 3 - 10;
this.gradientListRemovePlayers = new GuiElementGradientList(xPos0b, yPos0b, xPos1b - xPos0b, yPos1b - yPos0b);
break;
case DESIGN_FLAG:
int guiBottom = this.height / 2 + this.height / 4;
int guiTop = this.height / 2 - this.height / 4;
int guiRight = this.width / 2 + this.width / 3;
int guiLeft;
this.flagDesignerScale = new Vector2(this.width / 130.0F, this.height / 70.0F);
this.flagDesignerMinX = this.width / 2 - this.spaceRaceData.getFlagData().getWidth() * (float) this.flagDesignerScale.x / 2;
this.flagDesignerMinY = this.height / 2 - this.spaceRaceData.getFlagData().getHeight() * (float) this.flagDesignerScale.y / 2;
this.flagDesignerWidth = this.spaceRaceData.getFlagData().getWidth() * (float) this.flagDesignerScale.x;
this.flagDesignerHeight = this.spaceRaceData.getFlagData().getHeight() * (float) this.flagDesignerScale.y;
int flagDesignerRight = (int) (this.flagDesignerMinX + this.flagDesignerWidth);
int availWidth = (int) ((guiRight - 10 - (this.flagDesignerMinX + this.flagDesignerWidth + 10)) / 3);
float x1 = flagDesignerRight + 10;
float x2 = guiRight - 10;
float y1 = guiBottom - 10 - (x2 - x1);
int height = (int) (y1 - 10 - (guiTop + 10));
this.sliderColorR = new GuiElementSlider(1, flagDesignerRight + 10, guiTop + 10, availWidth, height, true, new Vector3(0, 0, 0), new Vector3(1, 0, 0));
this.sliderColorG = new GuiElementSlider(2, flagDesignerRight + 11 + availWidth, guiTop + 10, availWidth, height, true, new Vector3(0, 0, 0), new Vector3(0, 1, 0));
this.sliderColorB = new GuiElementSlider(3, flagDesignerRight + 12 + availWidth * 2, guiTop + 10, availWidth, height, true, new Vector3(0, 0, 0), new Vector3(0, 0, 1));
this.sliderColorR.setSliderPos(sliderR);
this.sliderColorG.setSliderPos(sliderG);
this.sliderColorB.setSliderPos(sliderB);
this.buttonList.add(this.sliderColorR);
this.buttonList.add(this.sliderColorG);
this.buttonList.add(this.sliderColorB);
this.checkboxPaintbrush = new GuiElementCheckbox(5, this, (int) (this.flagDesignerMinX - 15), this.height / 2 - this.height / 4 + 10, 13, 13, 26, 26, 133, 0, "", 4210752, false);
this.checkboxEraser = new GuiElementCheckbox(6, this, (int) (this.flagDesignerMinX - 15), this.height / 2 - this.height / 4 + 25, 13, 13, 26, 26, 133, 52, "", 4210752, false);
this.checkboxSelector = new GuiElementCheckbox(7, this, (int) (this.flagDesignerMinX - 15), this.height / 2 - this.height / 4 + 40, 13, 13, 26, 26, 133, 78, "", 4210752, false);
this.checkboxColorSelector = new GuiElementCheckbox(8, this, (int) (this.flagDesignerMinX - 15), this.height / 2 - this.height / 4 + 55, 13, 13, 26, 26, 133, 104, "", 4210752, false);
this.checkboxShowGrid = new GuiElementCheckbox(9, this, (int) (this.flagDesignerMinX - 15), this.height / 2 - this.height / 4 + 90, 13, 13, 26, 26, 133, 26, "", 4210752, false);
this.sliderBrushSize = new GuiElementSlider(10, this.checkboxPaintbrush.xPosition - 40, this.checkboxPaintbrush.yPosition, 35, 13, false, new Vector3(0.34, 0.34, 0.34), new Vector3(0.34, 0.34, 0.34), GCCoreUtil.translate("gui.space_race.create.brush_size.name"));
this.sliderEraserSize = new GuiElementSlider(11, this.checkboxEraser.xPosition - 40, this.checkboxEraser.yPosition, 35, 13, false, new Vector3(0.34, 0.34, 0.34), new Vector3(0.34, 0.34, 0.34), GCCoreUtil.translate("gui.space_race.create.eraser_size.name"));
this.sliderEraserSize.visible = false;
this.buttonList.add(this.checkboxPaintbrush);
this.buttonList.add(this.checkboxShowGrid);
this.buttonList.add(this.checkboxEraser);
this.buttonList.add(this.checkboxSelector);
this.buttonList.add(this.checkboxColorSelector);
this.buttonList.add(this.sliderBrushSize);
this.buttonList.add(this.sliderEraserSize);
break;
case CHANGE_TEAM_COLOR:
guiBottom = this.height / 2 + this.height / 4;
guiTop = this.height / 2 - this.height / 4;
guiLeft = this.width / 6;
guiRight = this.width / 2 + this.width / 3;
flagDesignerRight = guiLeft;
availWidth = (guiRight - guiLeft - 100) / 3;
x1 = flagDesignerRight + 10;
x2 = guiLeft - 10;
y1 = guiBottom - 10 - (x2 - x1);
height = (int) (y1 - 10 - (guiTop + 30));
this.sliderColorR = new GuiElementSlider(1, flagDesignerRight + 25, guiTop + 30, availWidth, height, true, new Vector3(0, 0, 0), new Vector3(1, 0, 0));
this.sliderColorG = new GuiElementSlider(2, flagDesignerRight + availWidth + 50, guiTop + 30, availWidth, height, true, new Vector3(0, 0, 0), new Vector3(0, 1, 0));
this.sliderColorB = new GuiElementSlider(3, flagDesignerRight + availWidth * 2 + 75, guiTop + 30, availWidth, height, true, new Vector3(0, 0, 0), new Vector3(0, 0, 1));
this.sliderColorR.setSliderPos(this.spaceRaceData.getTeamColor().floatX());
this.sliderColorG.setSliderPos(this.spaceRaceData.getTeamColor().floatY());
this.sliderColorB.setSliderPos(this.spaceRaceData.getTeamColor().floatZ());
this.buttonList.add(this.sliderColorR);
this.buttonList.add(this.sliderColorG);
this.buttonList.add(this.sliderColorB);
break;
default:
break;
}
}
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class EntityAdvancedMotion method onUpdate.
@Override
public void onUpdate() {
this.ticks++;
super.onUpdate();
if (this.canSetPositionClient() && this.worldObj.isRemote && (this.riddenByEntity == null || !(this.riddenByEntity instanceof EntityPlayer) || !FMLClientHandler.instance().getClient().thePlayer.equals(this.riddenByEntity))) {
double x;
double y;
double var12;
double z;
if (this.posRotIncrements > 0) {
x = this.posX + (this.advancedPositionX - this.posX) / this.posRotIncrements;
y = this.posY + (this.advancedPositionY - this.posY) / this.posRotIncrements;
z = this.posZ + (this.advancedPositionZ - this.posZ) / this.posRotIncrements;
var12 = MathHelper.wrapAngleTo180_double(this.advancedYaw - this.rotationYaw);
this.rotationYaw = (float) (this.rotationYaw + var12 / this.posRotIncrements);
this.rotationPitch = (float) (this.rotationPitch + (this.advancedPitch - this.rotationPitch) / this.posRotIncrements);
--this.posRotIncrements;
this.setPosition(x, y, z);
this.setRotation(this.rotationYaw, this.rotationPitch);
} else {
// x = this.posX + this.motionX;
// y = this.posY + this.motionY;
// z = this.posZ + this.motionZ;
// this.setPosition(x, y, z);
}
}
if (this.timeSinceHit > 0) {
this.timeSinceHit--;
}
if (this.currentDamage > 0) {
this.currentDamage--;
}
if (this.shouldSpawnParticles() && this.worldObj.isRemote) {
this.spawnParticles(this.getParticleMap());
}
if (this.onGround) {
this.tickOnGround();
} else {
this.tickInAir();
}
if (this.worldObj.isRemote) {
Vector3 mot = this.getMotionVec();
this.motionX = mot.x;
this.motionY = mot.y;
this.motionZ = mot.z;
}
// Necessary on both server and client to achieve a correct this.onGround setting
this.moveEntity(this.motionX, this.motionY, this.motionZ);
if (this.onGround && !this.lastOnGround) {
this.onGroundHit();
}
if (shouldSendAdvancedMotionPacket()) {
if (this.worldObj.isRemote) {
GalacticraftCore.packetPipeline.sendToServer(new PacketEntityUpdate(this));
}
if (!this.worldObj.isRemote && this.ticks % 5 == 0) {
GalacticraftCore.packetPipeline.sendToAllAround(new PacketEntityUpdate(this), new TargetPoint(GCCoreUtil.getDimensionID(this.worldObj), this.posX, this.posY, this.posZ, 50.0D));
}
}
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.lastOnGround = this.onGround;
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class PlayerClient method updateFeet.
private void updateFeet(EntityPlayerSP player, double motionX, double motionZ) {
GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
double motionSqrd = motionX * motionX + motionZ * motionZ;
// If the player is on the moon, not airbourne and not riding anything
if (motionSqrd > 0.001 && player.worldObj != null && player.worldObj.provider instanceof WorldProviderMoon && player.ridingEntity == null && !player.capabilities.isFlying) {
int iPosX = MathHelper.floor_double(player.posX);
int iPosY = MathHelper.floor_double(player.posY - 0.05);
int iPosZ = MathHelper.floor_double(player.posZ);
BlockPos pos1 = new BlockPos(iPosX, iPosY, iPosZ);
IBlockState state = player.worldObj.getBlockState(pos1);
// If the block below is the moon block
if (state.getBlock() == GCBlocks.blockMoon) {
// And is the correct metadata (moon turf)
if (state.getValue(BlockBasicMoon.BASIC_TYPE_MOON) == BlockBasicMoon.EnumBlockBasicMoon.MOON_TURF) {
// If it has been long enough since the last step
if (stats.getDistanceSinceLastStep() > 0.35) {
Vector3 pos = new Vector3(player);
// Set the footprint position to the block below and add random number to stop z-fighting
pos.y = MathHelper.floor_double(player.posY) + player.getRNG().nextFloat() / 100.0F;
// Adjust footprint to left or right depending on step count
switch(stats.getLastStep()) {
case 0:
pos.translate(new Vector3(Math.sin(Math.toRadians(-player.rotationYaw + 90)) * 0.25, 0, Math.cos(Math.toRadians(-player.rotationYaw + 90)) * 0.25));
break;
case 1:
pos.translate(new Vector3(Math.sin(Math.toRadians(-player.rotationYaw - 90)) * 0.25, 0, Math.cos(Math.toRadians(-player.rotationYaw - 90)) * 0.25));
break;
}
pos = WorldUtil.getFootprintPosition(player.worldObj, player.rotationYaw - 180, pos, new BlockVec3(player));
long chunkKey = ChunkCoordIntPair.chunkXZ2Int(pos.intX() >> 4, pos.intZ() >> 4);
FootprintRenderer.addFootprint(chunkKey, GCCoreUtil.getDimensionID(player.worldObj), pos, player.rotationYaw, player.getName());
// Increment and cap step counter at 1
stats.setLastStep((stats.getLastStep() + 1) % 2);
stats.setDistanceSinceLastStep(0);
} else {
stats.setDistanceSinceLastStep(stats.getDistanceSinceLastStep() + motionSqrd);
}
}
}
}
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class WorldUtil method teleportEntity.
private static Entity teleportEntity(World worldNew, Entity entity, int dimID, ITeleportType type, boolean transferInv, EntityAutoRocket ridingRocket) {
Entity otherRiddenEntity = null;
if (entity.ridingEntity != null) {
if (entity.ridingEntity instanceof EntitySpaceshipBase) {
entity.mountEntity(entity.ridingEntity);
} else if (entity.ridingEntity instanceof EntityCelestialFake) {
entity.ridingEntity.setDead();
entity.mountEntity(null);
} else {
otherRiddenEntity = entity.ridingEntity;
entity.mountEntity(null);
}
}
boolean dimChange = entity.worldObj != worldNew;
// Make sure the entity is added to the correct chunk in the OLD world so that it will be properly removed later if it needs to be unloaded from that world
entity.worldObj.updateEntityWithOptionalForce(entity, false);
EntityPlayerMP player = null;
Vector3 spawnPos = null;
int oldDimID = GCCoreUtil.getDimensionID(entity.worldObj);
if (ridingRocket != null) {
ArrayList<TileEntityTelemetry> tList = ridingRocket.getTelemetry();
NBTTagCompound nbt = new NBTTagCompound();
ridingRocket.isDead = false;
ridingRocket.riddenByEntity = null;
ridingRocket.writeToNBTOptional(nbt);
((WorldServer) ridingRocket.worldObj).getEntityTracker().untrackEntity(ridingRocket);
removeEntityFromWorld(ridingRocket.worldObj, ridingRocket, true);
ridingRocket = (EntityAutoRocket) EntityList.createEntityFromNBT(nbt, worldNew);
if (ridingRocket != null) {
ridingRocket.setWaitForPlayer(true);
if (ridingRocket instanceof IWorldTransferCallback) {
((IWorldTransferCallback) ridingRocket).onWorldTransferred(worldNew);
}
}
}
if (dimChange) {
if (entity instanceof EntityPlayerMP) {
player = (EntityPlayerMP) entity;
World worldOld = player.worldObj;
GCPlayerStats stats = GCPlayerStats.get(player);
stats.setUsingPlanetSelectionGui(false);
player.dimension = dimID;
if (ConfigManagerCore.enableDebug) {
GCLog.info("DEBUG: Sending respawn packet to player for dim " + dimID);
}
player.playerNetServerHandler.sendPacket(new S07PacketRespawn(dimID, player.worldObj.getDifficulty(), player.worldObj.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType()));
if (worldNew.provider instanceof WorldProviderSpaceStation) {
if (WorldUtil.registeredSpaceStations.containsKey(dimID)) // TODO This has never been effective before due to the earlier bug - what does it actually do?
{
NBTTagCompound var2 = new NBTTagCompound();
SpaceStationWorldData.getStationData(worldNew, dimID, player).writeToNBT(var2);
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_SPACESTATION_DATA, GCCoreUtil.getDimensionID(player.worldObj), new Object[] { dimID, var2 }), player);
}
}
removeEntityFromWorld(worldOld, player, true);
if (ridingRocket != null) {
spawnPos = new Vector3(ridingRocket);
} else {
spawnPos = type.getPlayerSpawnLocation((WorldServer) worldNew, player);
}
forceMoveEntityToPos(entity, (WorldServer) worldNew, spawnPos, true);
GCLog.info("Server attempting to transfer player " + PlayerUtil.getName(player) + " to dimension " + GCCoreUtil.getDimensionID(worldNew));
if (worldNew.provider instanceof WorldProviderSpaceStation) {
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_RESET_THIRD_PERSON, GCCoreUtil.getDimensionID(worldNew), new Object[] {}), player);
}
player.capabilities.isFlying = false;
player.mcServer.getConfigurationManager().preparePlayer(player, (WorldServer) worldOld);
player.theItemInWorldManager.setWorld((WorldServer) worldNew);
player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer) worldNew);
player.mcServer.getConfigurationManager().syncPlayerInventory(player);
for (Object o : player.getActivePotionEffects()) {
PotionEffect var10 = (PotionEffect) o;
player.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(player.getEntityId(), var10));
}
player.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
} else // Non-player entity transfer i.e. it's an EntityCargoRocket or an empty rocket
{
ArrayList<TileEntityTelemetry> tList = null;
if (entity instanceof EntitySpaceshipBase) {
tList = ((EntitySpaceshipBase) entity).getTelemetry();
}
WorldUtil.removeEntityFromWorld(entity.worldObj, entity, true);
NBTTagCompound nbt = new NBTTagCompound();
entity.isDead = false;
entity.writeToNBTOptional(nbt);
entity = EntityList.createEntityFromNBT(nbt, worldNew);
if (entity == null) {
return null;
}
if (entity instanceof IWorldTransferCallback) {
((IWorldTransferCallback) entity).onWorldTransferred(worldNew);
}
forceMoveEntityToPos(entity, (WorldServer) worldNew, new Vector3(entity), true);
if (tList != null && tList.size() > 0) {
for (TileEntityTelemetry t : tList) {
t.addTrackedEntity(entity);
}
}
}
} else {
// Same dimension player transfer
if (entity instanceof EntityPlayerMP) {
player = (EntityPlayerMP) entity;
player.closeScreen();
GCPlayerStats stats = GCPlayerStats.get(player);
stats.setUsingPlanetSelectionGui(false);
if (ridingRocket != null) {
spawnPos = new Vector3(ridingRocket);
} else {
spawnPos = type.getPlayerSpawnLocation((WorldServer) entity.worldObj, (EntityPlayerMP) entity);
}
forceMoveEntityToPos(entity, (WorldServer) worldNew, spawnPos, false);
GCLog.info("Server attempting to transfer player " + PlayerUtil.getName(player) + " within same dimension " + GCCoreUtil.getDimensionID(worldNew));
if (worldNew.provider instanceof WorldProviderSpaceStation) {
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_RESET_THIRD_PERSON, GCCoreUtil.getDimensionID(worldNew), new Object[] {}), player);
}
player.capabilities.isFlying = false;
}
// Cargo rocket does not needs its location setting here, it will do that itself
}
// Update PlayerStatsGC
if (player != null) {
GCPlayerStats stats = GCPlayerStats.get(player);
if (ridingRocket == null && type.useParachute() && stats.getExtendedInventory().getStackInSlot(4) != null && stats.getExtendedInventory().getStackInSlot(4).getItem() instanceof ItemParaChute) {
GCPlayerHandler.setUsingParachute(player, stats, true);
} else {
GCPlayerHandler.setUsingParachute(player, stats, false);
}
if (stats.getRocketStacks() != null && stats.getRocketStacks().length > 0) {
for (int stack = 0; stack < stats.getRocketStacks().length; stack++) {
if (transferInv) {
if (stats.getRocketStacks()[stack] == null) {
if (stack == stats.getRocketStacks().length - 1) {
if (stats.getRocketItem() != null) {
stats.getRocketStacks()[stack] = new ItemStack(stats.getRocketItem(), 1, stats.getRocketType());
}
} else if (stack == stats.getRocketStacks().length - 2) {
stats.getRocketStacks()[stack] = stats.getLaunchpadStack();
stats.setLaunchpadStack(null);
}
}
} else {
stats.getRocketStacks()[stack] = null;
}
}
}
if (transferInv && stats.getChestSpawnCooldown() == 0) {
stats.setChestSpawnVector(type.getParaChestSpawnLocation((WorldServer) entity.worldObj, player, new Random()));
stats.setChestSpawnCooldown(200);
}
}
if (ridingRocket != null) {
ridingRocket.forceSpawn = true;
worldNew.spawnEntityInWorld(ridingRocket);
ridingRocket.setWorld(worldNew);
worldNew.updateEntityWithOptionalForce(ridingRocket, true);
entity.mountEntity(ridingRocket);
GCLog.debug("Entering rocket at : " + entity.posX + "," + entity.posZ + " rocket at: " + ridingRocket.posX + "," + ridingRocket.posZ);
} else if (otherRiddenEntity != null) {
if (dimChange) {
World worldOld = otherRiddenEntity.worldObj;
NBTTagCompound nbt = new NBTTagCompound();
otherRiddenEntity.writeToNBTOptional(nbt);
removeEntityFromWorld(worldOld, otherRiddenEntity, true);
otherRiddenEntity = EntityList.createEntityFromNBT(nbt, worldNew);
worldNew.spawnEntityInWorld(otherRiddenEntity);
otherRiddenEntity.setWorld(worldNew);
}
otherRiddenEntity.setPositionAndRotation(entity.posX, entity.posY - 10, entity.posZ, otherRiddenEntity.rotationYaw, otherRiddenEntity.rotationPitch);
worldNew.updateEntityWithOptionalForce(otherRiddenEntity, true);
}
if (entity instanceof EntityPlayerMP) {
if (dimChange)
FMLCommonHandler.instance().firePlayerChangedDimensionEvent((EntityPlayerMP) entity, oldDimID, dimID);
// Spawn in a lander if appropriate
type.onSpaceDimensionChanged(worldNew, (EntityPlayerMP) entity, ridingRocket != null);
}
return entity;
}
use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.
the class AsteroidsModuleClient method spawnParticle.
@Override
public void spawnParticle(String particleID, Vector3 position, Vector3 motion, Object... extraData) {
Minecraft mc = FMLClientHandler.instance().getClient();
if (mc != null && mc.getRenderViewEntity() != null && mc.effectRenderer != null) {
double dX = mc.getRenderViewEntity().posX - position.x;
double dY = mc.getRenderViewEntity().posY - position.y;
double dZ = mc.getRenderViewEntity().posZ - position.z;
EntityFX particle = null;
double viewDistance = 64.0D;
if (dX * dX + dY * dY + dZ * dZ < viewDistance * viewDistance) {
if (particleID.equals("portalBlue")) {
particle = new EntityFXTeleport(mc.theWorld, position, motion, (TileEntityShortRangeTelepad) extraData[0], (Boolean) extraData[1]);
} else if (particleID.equals("cryoFreeze")) {
particle = new EntityCryoFX(mc.theWorld, position, motion);
}
}
if (particle != null) {
particle.prevPosX = particle.posX;
particle.prevPosY = particle.posY;
particle.prevPosZ = particle.posZ;
mc.effectRenderer.addEffect(particle);
}
}
}
Aggregations