use of net.minecraft.entity.player.EntityPlayerMP in project VoodooCraft by Mod-DevCafeTeam.
the class CapabilityHandler method onClonePlayer.
@SuppressWarnings("all")
@SubscribeEvent
public static void onClonePlayer(net.minecraftforge.event.entity.player.PlayerEvent.Clone event) {
//Copy capability on player death to new player
if (event.isWasDeath() && (event.getEntityPlayer() instanceof EntityPlayerMP)) {
EntityPlayerMP player = (EntityPlayerMP) event.getEntityPlayer();
for (Capability<? extends ICapability> cap : VCCapabilities.getCapabilities()) {
ICapability oldicap = event.getOriginal().getCapability(cap, null);
ICapability icap = player.getCapability(cap, null);
if (oldicap == null || icap == null)
continue;
icap.deserializeNBT(oldicap.serializeNBT());
icap.dataChanged(player);
}
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project ConvenientAdditions by Necr0.
the class ExtendedExplosion method newExplosion.
public static Explosion newExplosion(ExtendedExplosion e) {
if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(e.getWorld(), e))
return e;
e.doExplosionA();
e.doExplosionB(false);
if (!e.isSmoking) {
e.clearAffectedBlockPositions();
}
for (EntityPlayer entityplayer : e.getWorld().playerEntities) {
if (entityplayer instanceof EntityPlayerMP && entityplayer.getDistanceSq(e.explosionX, e.explosionY, e.explosionZ) < 4096.0D) {
ModNetworking.INSTANCE.sendTo(new PacketExtendedExplosion(e.explosionX, e.explosionY, e.explosionZ, e.explosionSize, e.getAffectedBlockPositions(), (Vec3d) e.getPlayerKnockbackMap().get(entityplayer)), (EntityPlayerMP) entityplayer);
}
}
return e;
}
use of net.minecraft.entity.player.EntityPlayerMP in project ImmersiveEngineering by BluSunrize.
the class EntitySkylineHook method onUpdate.
@Override
public void onUpdate() {
EntityPlayer player = null;
// if(this.getControllingPassenger() instanceof EntityPlayer)
// player = ((EntityPlayer)this.getControllingPassenger());
List<Entity> list = this.getPassengers();
if (!list.isEmpty() && list.get(0) instanceof EntityPlayer)
player = (EntityPlayer) list.get(0);
if (this.ticksExisted == 1 && !worldObj.isRemote) {
IELogger.debug("init tick at " + System.currentTimeMillis());
if (player instanceof EntityPlayerMP)
ImmersiveEngineering.packetHandler.sendTo(new MessageSkyhookSync(this), (EntityPlayerMP) player);
}
super.onUpdate();
// return;
if (subPoints != null && targetPoint < subPoints.length - 1) {
double dist = subPoints[targetPoint].distanceTo(new Vec3d(posX, posY, posZ));
IELogger.debug("dist: " + dist);
if (dist <= 0) {
this.posX = subPoints[targetPoint].xCoord;
this.posY = subPoints[targetPoint].yCoord;
this.posZ = subPoints[targetPoint].zCoord;
targetPoint++;
if (player instanceof EntityPlayerMP)
ImmersiveEngineering.packetHandler.sendTo(new MessageSkyhookSync(this), (EntityPlayerMP) player);
IELogger.debug("next vertex: " + targetPoint);
return;
}
float speed = 2f;
if (player != null && player.getActiveItemStack() != null && player.getActiveItemStack().getItem() instanceof ItemSkyhook)
speed = ((ItemSkyhook) player.getActiveItemStack().getItem()).getSkylineSpeed(player.getActiveItemStack());
Vec3d moveVec = SkylineHelper.getSubMovementVector(new Vec3d(posX, posY, posZ), subPoints[targetPoint], speed);
//*speed;
motionX = moveVec.xCoord;
//*speed;
motionY = moveVec.yCoord;
//*speed;
motionZ = moveVec.zCoord;
}
if (target != null && targetPoint == subPoints.length - 1) {
TileEntity end = this.worldObj.getTileEntity(target);
IImmersiveConnectable iicEnd = ApiUtils.toIIC(end, worldObj);
if (iicEnd == null) {
this.setDead();
return;
}
Vec3d vEnd = new Vec3d(target.getX(), target.getY(), target.getZ());
vEnd = Utils.addVectors(vEnd, iicEnd.getConnectionOffset(connection));
double gDist = vEnd.distanceTo(new Vec3d(posX, posY, posZ));
IELogger.debug("distance to goal: " + gDist);
if (gDist <= .3) {
reachedTarget(end);
return;
} else if (gDist > 5) {
setDead();
return;
}
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float) (Math.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) + 90.0F;
for (this.rotationPitch = (float) (Math.atan2((double) f1, this.motionY) * 180.0D / Math.PI) - 90.0F; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) ;
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) this.prevRotationPitch += 360.0F;
while (this.rotationYaw - this.prevRotationYaw < -180.0F) this.prevRotationYaw -= 360.0F;
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) this.prevRotationYaw += 360.0F;
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
if (this.isInWater()) {
for (int j = 0; j < 4; ++j) {
float f3 = 0.25F;
this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double) f3, this.posY - this.motionY * (double) f3, this.posZ - this.motionZ * (double) f3, this.motionX, this.motionY, this.motionZ);
}
}
if (player != null) {
double dx = this.posX - this.prevPosX;
double dy = this.posY - this.prevPosY;
double dz = this.posZ - this.prevPosZ;
int distTrvl = Math.round(MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz) * 100.0F);
if (distTrvl > 0)
player.addStat(IEAchievements.statDistanceSkyhook, distTrvl);
if (!worldObj.isRemote && SkylineHelper.isInBlock(player, worldObj)) {
// setDead();
// player.setPosition(posX-3*dx, posY-3*dy+getMountedYOffset(),posZ-3*dz);
}
//TODO
// if(player instanceof EntityPlayerMP)
// if(((EntityPlayerMP)player).getStatFile().func_150870_b(IEAchievements.statDistanceSkyhook)>100000)
// player.triggerAchievement(IEAchievements.skyhookPro);
}
this.setPosition(this.posX, this.posY, this.posZ);
}
use of net.minecraft.entity.player.EntityPlayerMP in project RecurrentComplex by Ivorforce.
the class CommandPaste method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args, "mirror", "generate", "select");
EntityPlayerMP entityPlayerMP = getCommandSenderAsPlayer(sender);
RCEntityInfo entityInfo = RCCommands.getStructureEntityInfo(entityPlayerMP, null);
NBTTagCompound worldData = entityInfo.getWorldDataClipboard();
if (worldData == null)
throw ServerTranslations.commandException("commands.strucPaste.noClipboard");
WorldServer world = (WorldServer) sender.getEntityWorld();
BlockPos pos = parameters.pos("x", "y", "z", sender.getPosition(), false).require();
AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(AxisAlignedTransform2D.ORIGINAL);
String seed = parameters.get("seed").first().optional().orElse(null);
boolean generate = parameters.has("generate");
boolean select = parameters.has("select");
GenericStructure structure = GenericStructure.createDefaultStructure();
structure.worldDataCompound = worldData;
// TODO Generate with generation info?
OperationRegistry.queueOperation(new OperationGenerateStructure(structure, null, transform, pos, generate).withSeed(seed).prepare(world), sender);
if (select) {
StructureGenerator<?> generator = new StructureGenerator<>(structure).transform(transform).lowerCoord(pos);
// Can never not place so don't handle
//noinspection OptionalGetWithoutIsPresent
StructureBoundingBox boundingBox = generator.boundingBox().get();
SelectionOwner owner = RCCommands.getSelectionOwner(sender, null, false);
owner.setSelection(RCBlockAreas.from(boundingBox));
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project RecurrentComplex by Ivorforce.
the class CommandExportStructure method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
EntityPlayerMP player = getCommandSenderAsPlayer(commandSender);
String structureID = parameters.get().first().optional().orElse(null);
GenericStructure genericStructureInfo = getNewGenericStructure(commandSender, parameters.rc("from"));
SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
RCCommands.assertSize(commandSender, selectionOwner);
genericStructureInfo.worldDataCompound = IvWorldData.capture(commandSender.getEntityWorld(), selectionOwner.getSelection(), true).createTagCompound();
PacketEditStructureHandler.openEditStructure(genericStructureInfo, structureID, player);
}
Aggregations