use of net.minecraft.client.entity.EntityPlayerSP in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EntityDraggable method tickAddedVelocity.
//TODO: Finishme
public void tickAddedVelocity() {
if (worldBelowFeet != null && !ValkyrienWarfareMod.physicsManager.isEntityFixed(draggableAsEntity)) {
CoordTransformObject coordTransform = worldBelowFeet.wrapping.coordTransform;
float rotYaw = draggableAsEntity.rotationYaw;
float rotPitch = draggableAsEntity.rotationPitch;
float prevYaw = draggableAsEntity.prevRotationYaw;
float prevPitch = draggableAsEntity.prevRotationPitch;
Vector oldPos = new Vector(draggableAsEntity);
RotationMatrices.applyTransform(coordTransform.prevwToLTransform, coordTransform.prevWToLRotation, draggableAsEntity);
RotationMatrices.applyTransform(coordTransform.lToWTransform, coordTransform.lToWRotation, draggableAsEntity);
Vector newPos = new Vector(draggableAsEntity);
//Move the entity back to its old position, the added velocity will be used afterwards
draggableAsEntity.setPosition(oldPos.X, oldPos.Y, oldPos.Z);
Vector addedVel = oldPos.getSubtraction(newPos);
velocityAddedToPlayer = addedVel;
draggableAsEntity.rotationYaw = rotYaw;
draggableAsEntity.rotationPitch = rotPitch;
draggableAsEntity.prevRotationYaw = prevYaw;
draggableAsEntity.prevRotationPitch = prevPitch;
Vector oldLookingPos = new Vector(draggableAsEntity.getLook(1.0F));
RotationMatrices.applyTransform(coordTransform.prevWToLRotation, oldLookingPos);
RotationMatrices.applyTransform(coordTransform.lToWRotation, oldLookingPos);
double newPitch = Math.asin(oldLookingPos.Y) * -180D / Math.PI;
double f4 = -Math.cos(-newPitch * 0.017453292D);
double radianYaw = Math.atan2((oldLookingPos.X / f4), (oldLookingPos.Z / f4));
radianYaw += Math.PI;
radianYaw *= -180D / Math.PI;
if (!(Double.isNaN(radianYaw) || Math.abs(newPitch) > 85)) {
double wrappedYaw = MathHelper.wrapDegrees(radianYaw);
double wrappedRotYaw = MathHelper.wrapDegrees(draggableAsEntity.rotationYaw);
double yawDif = wrappedYaw - wrappedRotYaw;
if (Math.abs(yawDif) > 180D) {
if (yawDif < 0) {
yawDif += 360D;
} else {
yawDif -= 360D;
}
}
yawDif %= 360D;
final double threshold = .1D;
if (Math.abs(yawDif) < threshold) {
yawDif = 0D;
}
yawDifVelocity = yawDif;
}
}
boolean onGroundOrig = draggableAsEntity.onGround;
if (!ValkyrienWarfareMod.physicsManager.isEntityFixed(draggableAsEntity)) {
float originalWalked = draggableAsEntity.distanceWalkedModified;
float originalWalkedOnStep = draggableAsEntity.distanceWalkedOnStepModified;
boolean originallySneaking = draggableAsEntity.isSneaking();
draggableAsEntity.setSneaking(false);
if (draggableAsEntity.worldObj.isRemote && draggableAsEntity instanceof EntityPlayerSP) {
EntityPlayerSP playerSP = (EntityPlayerSP) draggableAsEntity;
MovementInput moveInput = playerSP.movementInput;
originallySneaking = moveInput.sneak;
moveInput.sneak = false;
}
draggableAsEntity.moveEntity(velocityAddedToPlayer.X, velocityAddedToPlayer.Y, velocityAddedToPlayer.Z);
if (!(draggableAsEntity instanceof EntityPlayer)) {
if (draggableAsEntity instanceof EntityArrow) {
draggableAsEntity.prevRotationYaw = draggableAsEntity.rotationYaw;
draggableAsEntity.rotationYaw -= yawDifVelocity;
} else {
draggableAsEntity.prevRotationYaw = draggableAsEntity.rotationYaw;
draggableAsEntity.rotationYaw += yawDifVelocity;
}
} else {
if (draggableAsEntity.worldObj.isRemote) {
draggableAsEntity.prevRotationYaw = draggableAsEntity.rotationYaw;
draggableAsEntity.rotationYaw += yawDifVelocity;
}
}
//Do not add this movement as if the entity were walking it
draggableAsEntity.distanceWalkedModified = originalWalked;
draggableAsEntity.distanceWalkedOnStepModified = originalWalkedOnStep;
draggableAsEntity.setSneaking(originallySneaking);
if (draggableAsEntity.worldObj.isRemote && draggableAsEntity instanceof EntityPlayerSP) {
EntityPlayerSP playerSP = (EntityPlayerSP) draggableAsEntity;
MovementInput moveInput = playerSP.movementInput;
moveInput.sneak = originallySneaking;
}
}
if (onGroundOrig) {
draggableAsEntity.onGround = onGroundOrig;
}
velocityAddedToPlayer.multiply(.99D);
yawDifVelocity *= .95D;
}
use of net.minecraft.client.entity.EntityPlayerSP in project RFToolsDimensions by McJty.
the class SkyRenderer method renderSky.
/**
* Renders the sky with the partial tick time. Args: partialTickTime
*/
@SideOnly(Side.CLIENT)
private static void renderSky(float partialTickTime, GenericWorldProvider provider) {
initialize();
EntityPlayerSP player = Minecraft.getMinecraft().player;
WorldClient world = Minecraft.getMinecraft().world;
TextureManager renderEngine = Minecraft.getMinecraft().getTextureManager();
GlStateManager.disableTexture2D();
Vec3d vec3 = world.getSkyColor(player, partialTickTime);
float skyRed = (float) vec3.x;
float skyGreen = (float) vec3.y;
float skyBlue = (float) vec3.z;
boolean anaglyph = Minecraft.getMinecraft().gameSettings.anaglyph;
if (anaglyph) {
float f4 = (skyRed * 30.0F + skyGreen * 59.0F + skyBlue * 11.0F) / 100.0F;
float f5 = (skyRed * 30.0F + skyGreen * 70.0F) / 100.0F;
float f6 = (skyRed * 30.0F + skyBlue * 70.0F) / 100.0F;
skyRed = f4;
skyGreen = f5;
skyBlue = f6;
}
GlStateManager.color(skyRed, skyGreen, skyBlue);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder renderer = tessellator.getBuffer();
GlStateManager.depthMask(false);
GlStateManager.enableFog();
GlStateManager.color(skyRed, skyGreen, skyBlue);
// @todo support VBO?
// if (OpenGlHelper.useVbo()) {
// skyVBO.bindBuffer();
// GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
// GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
// this.skyVBO.drawArrays(7);
// this.skyVBO.unbindBuffer();
// GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
//
// } else {
GlStateManager.callList(glSkyList);
// }
GlStateManager.disableFog();
GlStateManager.disableAlpha();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
RenderHelper.disableStandardItemLighting();
float[] sunsetColors = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTickTime), partialTickTime);
if (sunsetColors != null) {
GlStateManager.disableTexture2D();
GlStateManager.shadeModel(7425);
GlStateManager.pushMatrix();
GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(MathHelper.sin(world.getCelestialAngleRadians(partialTickTime)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
float f6 = sunsetColors[0];
float f7 = sunsetColors[1];
float f8 = sunsetColors[2];
if (anaglyph) {
float f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
float f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F;
float f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F;
f6 = f9;
f7 = f10;
f8 = f11;
}
renderer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
renderer.pos(0.0D, 100.0D, 0.0D).color(f6, f7, f8, sunsetColors[3]).endVertex();
for (int j = 0; j <= 16; ++j) {
float f11 = j * (float) Math.PI * 2.0F / 16.0f;
float f12 = MathHelper.sin(f11);
float f13 = MathHelper.cos(f11);
renderer.pos((f12 * 120.0F), (f13 * 120.0F), (-f13 * 40.0F * sunsetColors[3])).color(sunsetColors[0], sunsetColors[1], sunsetColors[2], 0.0F).endVertex();
}
tessellator.draw();
GlStateManager.popMatrix();
GlStateManager.shadeModel(GL11.GL_FLAT);
}
renderCelestialBodies(partialTickTime, provider.getDimensionInformation(), world, renderEngine, tessellator);
GlStateManager.color(0.0F, 0.0F, 0.0F);
double d0 = player.getPosition().getY() - world.getHorizon();
if (d0 < 0.0D) {
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, 12.0F, 0.0F);
// @todo
// if (this.vboEnabled)
// {
// this.sky2VBO.bindBuffer();
// GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
// GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
// this.sky2VBO.drawArrays(7);
// this.sky2VBO.unbindBuffer();
// GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
// }
// else
// {
GlStateManager.callList(glSkyList2);
// GlStateManager.callList(this.glSkyList2);
// }
GlStateManager.popMatrix();
float f8 = 1.0F;
float f9 = -((float) (d0 + 65.0D));
float f10 = -f8;
renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
renderer.pos((-f8), f9, f8).color(0, 0, 0, 255).endVertex();
renderer.pos(f8, f9, f8).color(0, 0, 0, 255).endVertex();
renderer.pos(f8, f10, f8).color(0, 0, 0, 255).endVertex();
renderer.pos((-f8), f10, f8).color(0, 0, 0, 255).endVertex();
renderer.pos((-f8), f10, (-f8)).color(0, 0, 0, 255).endVertex();
renderer.pos(f8, f10, (-f8)).color(0, 0, 0, 255).endVertex();
renderer.pos(f8, f9, (-f8)).color(0, 0, 0, 255).endVertex();
renderer.pos((-f8), f9, (-f8)).color(0, 0, 0, 255).endVertex();
renderer.pos(f8, f10, (-f8)).color(0, 0, 0, 255).endVertex();
renderer.pos(f8, f10, f8).color(0, 0, 0, 255).endVertex();
renderer.pos(f8, f9, f8).color(0, 0, 0, 255).endVertex();
renderer.pos(f8, f9, (-f8)).color(0, 0, 0, 255).endVertex();
renderer.pos((-f8), f9, (-f8)).color(0, 0, 0, 255).endVertex();
renderer.pos((-f8), f9, f8).color(0, 0, 0, 255).endVertex();
renderer.pos((-f8), f10, f8).color(0, 0, 0, 255).endVertex();
renderer.pos((-f8), f10, (-f8)).color(0, 0, 0, 255).endVertex();
renderer.pos((-f8), f10, (-f8)).color(0, 0, 0, 255).endVertex();
renderer.pos((-f8), f10, f8).color(0, 0, 0, 255).endVertex();
renderer.pos(f8, f10, f8).color(0, 0, 0, 255).endVertex();
renderer.pos(f8, f10, (-f8)).color(0, 0, 0, 255).endVertex();
tessellator.draw();
}
if (world.provider.isSkyColored()) {
GlStateManager.color(skyRed * 0.2F + 0.04F, skyGreen * 0.2F + 0.04F, skyBlue * 0.6F + 0.1F);
} else {
GlStateManager.color(skyRed, skyGreen, skyBlue);
}
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, -((float) (d0 - 16.0D)), 0.0F);
GlStateManager.callList(glSkyList2);
GlStateManager.popMatrix();
GlStateManager.enableTexture2D();
GlStateManager.depthMask(true);
}
use of net.minecraft.client.entity.EntityPlayerSP in project RFToolsDimensions by McJty.
the class GuiDimletWorkbench method initGui.
@Override
public void initGui() {
super.initGui();
searchBar = new TextField(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(120, 7, 128, 16)).addTextEvent((widget, string) -> {
itemList.setSelected(-1);
listDirty = true;
});
itemList = new WidgetList(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(120, 25, 118, 133)).setLeftMargin(0).setRowheight(-1).addSelectionEvent(new SelectionEvent() {
@Override
public void select(Widget widget, int i) {
}
@Override
public void doubleClick(Widget widget, int i) {
EntityPlayerSP player = Minecraft.getMinecraft().player;
if (player.isCreative() && (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))) {
cheatDimlet();
} else {
suggestParts();
}
}
});
slider = new Slider(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(239, 25, 9, 133)).setDesiredWidth(11).setVertical().setScrollable(itemList);
int maxEnergyStored = tileEntity.getMaxEnergyStored();
energyBar = new EnergyBar(mc, this).setVertical().setMaxValue(maxEnergyStored).setLayoutHint(new PositionalLayout.PositionalHint(88, 9, 30, 10)).setShowText(false).setHorizontal();
energyBar.setValue(GenericEnergyStorageTileEntity.getCurrentRF());
extractButton = new ToggleButton(mc, this).setText("Extract").setLayoutHint(new PositionalLayout.PositionalHint(30, 7, 56, 14)).setCheckMarker(true).addButtonEvent(parent -> setExtractMode()).setTooltips("If on dimlets will be reconstructed into parts");
extractButton.setPressed(tileEntity.isExtractMode());
Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout()).addChild(extractButton).addChild(energyBar).addChild(itemList).addChild(slider).addChild(searchBar);
toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
listDirty = true;
window = new Window(this, toplevel);
}
use of net.minecraft.client.entity.EntityPlayerSP in project malmo by Microsoft.
the class ObservationFromSubgoalPositionListImplementation method writeObservationsToJSON.
@Override
public void writeObservationsToJSON(JsonObject json, MissionInit missionInit) {
int nTargets = this.positions.getPoint().size();
boolean foundNextPoint = false;
double targetx = 0;
double targetz = 0;
EntityPlayerSP player = Minecraft.getMinecraft().player;
if (player == null)
// Nothing we can do.
return;
double sourcex = player.posX;
double sourcez = player.posZ;
while (this.subgoalIndex < nTargets && !foundNextPoint) {
targetx = this.positions.getPoint().get(this.subgoalIndex).getX().doubleValue();
targetz = this.positions.getPoint().get(this.subgoalIndex).getZ().doubleValue();
double tol = this.positions.getPoint().get(this.subgoalIndex).getTolerance().doubleValue();
if (Math.abs(targetx - sourcex) + Math.abs(targetz - sourcez) < tol)
this.subgoalIndex++;
else
foundNextPoint = true;
}
if (!foundNextPoint)
// Finished.
return;
// Calculate which way we need to turn in order to point towards the target:
double dx = (targetx - sourcex);
double dz = (targetz - sourcez);
double targetYaw = (Math.atan2(dz, dx) * 180.0 / Math.PI) - 90;
double sourceYaw = player.rotationYaw;
// Find shortest angular distance between the two yaws, preserving sign:
double difference = targetYaw - sourceYaw;
while (difference < -180) difference += 360;
while (difference > 180) difference -= 360;
// Normalise:
difference /= 180.0;
json.addProperty("yawDelta", difference);
PointWithToleranceAndDescription point = this.positions.getPoint().get(this.subgoalIndex);
JsonObject pointElement = new JsonObject();
pointElement.addProperty("XPos", point.getX().doubleValue());
pointElement.addProperty("YPos", point.getY().doubleValue());
pointElement.addProperty("ZPos", point.getZ().doubleValue());
pointElement.addProperty("description", point.getDescription());
json.add("nextSubgoal", pointElement);
}
use of net.minecraft.client.entity.EntityPlayerSP in project malmo by Microsoft.
the class RewardForCatchingMobImplementation method getCaughtEntities.
static List<Entity> getCaughtEntities() {
EntityPlayerSP player = Minecraft.getMinecraft().player;
World world = player.world;
// Get all the currently loaded entities:
List<?> entities = Minecraft.getMinecraft().world.getLoadedEntityList();
// Now filter out all the player entities:
List<BlockPos> entityPositions = new ArrayList<BlockPos>();
for (Object obj : entities) {
if (obj instanceof EntityPlayer) {
EntityPlayer ep = (EntityPlayer) obj;
entityPositions.add(new BlockPos(ep.posX, ep.posY, ep.posZ));
}
}
// Now search for trapped entities
List<Entity> trappedEntities = new ArrayList<Entity>();
BlockPos playerPos = new BlockPos((int) player.posX, (int) player.posY, (int) player.posZ);
for (Object obj : entities) {
if (obj instanceof EntityPlayer)
// Don't score points for catching other players.
continue;
if (obj instanceof Entity) {
Entity e = (Entity) obj;
BlockPos entityPos = new BlockPos((int) e.posX, (int) e.posY, (int) e.posZ);
// For now, only consider entities on the same plane as us:
if (entityPos.getY() != playerPos.getY())
continue;
// Now see whether the mob can move anywhere:
boolean canEscape = false;
for (int x = -1; x <= 1 && !canEscape; x++) {
for (int z = -1; z <= 1 && !canEscape; z++) {
if (Math.abs(x) == Math.abs(z))
// Only consider the n/s/e/w blocks - ignore diagonals.
continue;
BlockPos square = new BlockPos(entityPos.getX() + x, entityPos.getY(), entityPos.getZ() + z);
if (world.isAirBlock(square) && !entityPositions.contains(square))
canEscape = true;
}
}
if (!canEscape) {
trappedEntities.add(e);
}
}
}
return trappedEntities;
}
Aggregations