base mod created
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
package net.minecraft.client.entity;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.io.File;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import net.minecraft.client.renderer.ImageBufferDownload;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class AbstractClientPlayer extends EntityPlayer
|
||||
{
|
||||
private NetworkPlayerInfo playerInfo;
|
||||
public float rotateElytraX;
|
||||
public float rotateElytraY;
|
||||
public float rotateElytraZ;
|
||||
|
||||
public AbstractClientPlayer(World worldIn, GameProfile playerProfile)
|
||||
{
|
||||
super(worldIn, playerProfile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the player is in spectator mode.
|
||||
*/
|
||||
public boolean isSpectator()
|
||||
{
|
||||
NetworkPlayerInfo networkplayerinfo = Minecraft.getMinecraft().getConnection().getPlayerInfo(this.getGameProfile().getId());
|
||||
return networkplayerinfo != null && networkplayerinfo.getGameType() == GameType.SPECTATOR;
|
||||
}
|
||||
|
||||
public boolean isCreative()
|
||||
{
|
||||
NetworkPlayerInfo networkplayerinfo = Minecraft.getMinecraft().getConnection().getPlayerInfo(this.getGameProfile().getId());
|
||||
return networkplayerinfo != null && networkplayerinfo.getGameType() == GameType.CREATIVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this instance of AbstractClientPlayer has any associated player data.
|
||||
*/
|
||||
public boolean hasPlayerInfo()
|
||||
{
|
||||
return this.getPlayerInfo() != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected NetworkPlayerInfo getPlayerInfo()
|
||||
{
|
||||
if (this.playerInfo == null)
|
||||
{
|
||||
this.playerInfo = Minecraft.getMinecraft().getConnection().getPlayerInfo(this.getUniqueID());
|
||||
}
|
||||
|
||||
return this.playerInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the player has an associated skin.
|
||||
*/
|
||||
public boolean hasSkin()
|
||||
{
|
||||
NetworkPlayerInfo networkplayerinfo = this.getPlayerInfo();
|
||||
return networkplayerinfo != null && networkplayerinfo.hasLocationSkin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the player instance has an associated skin.
|
||||
*/
|
||||
public ResourceLocation getLocationSkin()
|
||||
{
|
||||
NetworkPlayerInfo networkplayerinfo = this.getPlayerInfo();
|
||||
return networkplayerinfo == null ? DefaultPlayerSkin.getDefaultSkin(this.getUniqueID()) : networkplayerinfo.getLocationSkin();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ResourceLocation getLocationCape()
|
||||
{
|
||||
NetworkPlayerInfo networkplayerinfo = this.getPlayerInfo();
|
||||
return networkplayerinfo == null ? null : networkplayerinfo.getLocationCape();
|
||||
}
|
||||
|
||||
public boolean isPlayerInfoSet()
|
||||
{
|
||||
return this.getPlayerInfo() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the special Elytra texture for the player.
|
||||
*/
|
||||
@Nullable
|
||||
public ResourceLocation getLocationElytra()
|
||||
{
|
||||
NetworkPlayerInfo networkplayerinfo = this.getPlayerInfo();
|
||||
return networkplayerinfo == null ? null : networkplayerinfo.getLocationElytra();
|
||||
}
|
||||
|
||||
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username)
|
||||
{
|
||||
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
||||
ITextureObject itextureobject = texturemanager.getTexture(resourceLocationIn);
|
||||
|
||||
if (itextureobject == null)
|
||||
{
|
||||
itextureobject = new ThreadDownloadImageData((File)null, String.format("http://skins.minecraft.net/MinecraftSkins/%s.png", StringUtils.stripControlCodes(username)), DefaultPlayerSkin.getDefaultSkin(getOfflineUUID(username)), new ImageBufferDownload());
|
||||
texturemanager.loadTexture(resourceLocationIn, itextureobject);
|
||||
}
|
||||
|
||||
return (ThreadDownloadImageData)itextureobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the username has an associated skin.
|
||||
*/
|
||||
public static ResourceLocation getLocationSkin(String username)
|
||||
{
|
||||
return new ResourceLocation("skins/" + StringUtils.stripControlCodes(username));
|
||||
}
|
||||
|
||||
public String getSkinType()
|
||||
{
|
||||
NetworkPlayerInfo networkplayerinfo = this.getPlayerInfo();
|
||||
return networkplayerinfo == null ? DefaultPlayerSkin.getSkinType(this.getUniqueID()) : networkplayerinfo.getSkinType();
|
||||
}
|
||||
|
||||
public float getFovModifier()
|
||||
{
|
||||
float f = 1.0F;
|
||||
|
||||
if (this.capabilities.isFlying)
|
||||
{
|
||||
f *= 1.1F;
|
||||
}
|
||||
|
||||
IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
|
||||
f = (float)((double)f * ((iattributeinstance.getAttributeValue() / (double)this.capabilities.getWalkSpeed() + 1.0D) / 2.0D));
|
||||
|
||||
if (this.capabilities.getWalkSpeed() == 0.0F || Float.isNaN(f) || Float.isInfinite(f))
|
||||
{
|
||||
f = 1.0F;
|
||||
}
|
||||
|
||||
if (this.isHandActive() && this.getActiveItemStack().getItem() == Items.BOW)
|
||||
{
|
||||
int i = this.getItemInUseMaxCount();
|
||||
float f1 = (float)i / 20.0F;
|
||||
|
||||
if (f1 > 1.0F)
|
||||
{
|
||||
f1 = 1.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
f1 = f1 * f1;
|
||||
}
|
||||
|
||||
f *= 1.0F - f1 * 0.15F;
|
||||
}
|
||||
|
||||
return net.minecraftforge.client.ForgeHooksClient.getOffsetFOV(this, f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package net.minecraft.client.entity;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class EntityOtherPlayerMP extends AbstractClientPlayer
|
||||
{
|
||||
private int otherPlayerMPPosRotationIncrements;
|
||||
private double otherPlayerMPX;
|
||||
private double otherPlayerMPY;
|
||||
private double otherPlayerMPZ;
|
||||
private double otherPlayerMPYaw;
|
||||
private double otherPlayerMPPitch;
|
||||
|
||||
public EntityOtherPlayerMP(World worldIn, GameProfile gameProfileIn)
|
||||
{
|
||||
super(worldIn, gameProfileIn);
|
||||
this.stepHeight = 1.0F;
|
||||
this.noClip = true;
|
||||
this.renderOffsetY = 0.25F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entity is in range to render.
|
||||
*/
|
||||
public boolean isInRangeToRenderDist(double distance)
|
||||
{
|
||||
double d0 = this.getEntityBoundingBox().getAverageEdgeLength() * 10.0D;
|
||||
|
||||
if (Double.isNaN(d0))
|
||||
{
|
||||
d0 = 1.0D;
|
||||
}
|
||||
|
||||
d0 = d0 * 64.0D * getRenderDistanceWeight();
|
||||
return distance < d0 * d0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the entity is attacked.
|
||||
*/
|
||||
public boolean attackEntityFrom(DamageSource source, float amount)
|
||||
{
|
||||
net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, source, amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the position and rotation values directly without any clamping.
|
||||
*/
|
||||
public void setPositionAndRotationDirect(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean teleport)
|
||||
{
|
||||
this.otherPlayerMPX = x;
|
||||
this.otherPlayerMPY = y;
|
||||
this.otherPlayerMPZ = z;
|
||||
this.otherPlayerMPYaw = (double)yaw;
|
||||
this.otherPlayerMPPitch = (double)pitch;
|
||||
this.otherPlayerMPPosRotationIncrements = posRotationIncrements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
public void onUpdate()
|
||||
{
|
||||
this.renderOffsetY = 0.0F;
|
||||
super.onUpdate();
|
||||
this.prevLimbSwingAmount = this.limbSwingAmount;
|
||||
double d0 = this.posX - this.prevPosX;
|
||||
double d1 = this.posZ - this.prevPosZ;
|
||||
float f = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;
|
||||
|
||||
if (f > 1.0F)
|
||||
{
|
||||
f = 1.0F;
|
||||
}
|
||||
|
||||
this.limbSwingAmount += (f - this.limbSwingAmount) * 0.4F;
|
||||
this.limbSwing += this.limbSwingAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
|
||||
* use this to react to sunlight and start to burn.
|
||||
*/
|
||||
public void onLivingUpdate()
|
||||
{
|
||||
if (this.otherPlayerMPPosRotationIncrements > 0)
|
||||
{
|
||||
double d0 = this.posX + (this.otherPlayerMPX - this.posX) / (double)this.otherPlayerMPPosRotationIncrements;
|
||||
double d1 = this.posY + (this.otherPlayerMPY - this.posY) / (double)this.otherPlayerMPPosRotationIncrements;
|
||||
double d2 = this.posZ + (this.otherPlayerMPZ - this.posZ) / (double)this.otherPlayerMPPosRotationIncrements;
|
||||
double d3;
|
||||
|
||||
for (d3 = this.otherPlayerMPYaw - (double)this.rotationYaw; d3 < -180.0D; d3 += 360.0D)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
while (d3 >= 180.0D)
|
||||
{
|
||||
d3 -= 360.0D;
|
||||
}
|
||||
|
||||
this.rotationYaw = (float)((double)this.rotationYaw + d3 / (double)this.otherPlayerMPPosRotationIncrements);
|
||||
this.rotationPitch = (float)((double)this.rotationPitch + (this.otherPlayerMPPitch - (double)this.rotationPitch) / (double)this.otherPlayerMPPosRotationIncrements);
|
||||
--this.otherPlayerMPPosRotationIncrements;
|
||||
this.setPosition(d0, d1, d2);
|
||||
this.setRotation(this.rotationYaw, this.rotationPitch);
|
||||
}
|
||||
|
||||
this.prevCameraYaw = this.cameraYaw;
|
||||
this.updateArmSwingProgress();
|
||||
float f1 = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
float f = (float)Math.atan(-this.motionY * 0.20000000298023224D) * 15.0F;
|
||||
|
||||
if (f1 > 0.1F)
|
||||
{
|
||||
f1 = 0.1F;
|
||||
}
|
||||
|
||||
if (!this.onGround || this.getHealth() <= 0.0F)
|
||||
{
|
||||
f1 = 0.0F;
|
||||
}
|
||||
|
||||
if (this.onGround || this.getHealth() <= 0.0F)
|
||||
{
|
||||
f = 0.0F;
|
||||
}
|
||||
|
||||
this.cameraYaw += (f1 - this.cameraYaw) * 0.4F;
|
||||
this.cameraPitch += (f - this.cameraPitch) * 0.8F;
|
||||
this.world.profiler.startSection("push");
|
||||
this.collideWithNearbyEntities();
|
||||
this.world.profiler.endSection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a chat message to the CommandSender
|
||||
*/
|
||||
public void sendMessage(ITextComponent component)
|
||||
{
|
||||
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(component);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the CommandSender is allowed to execute the command, {@code false} if not
|
||||
*/
|
||||
public boolean canUseCommand(int permLevel, String commandName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position in the world. <b>{@code null} is not allowed!</b> If you are not an entity in the world, return
|
||||
* the coordinates 0, 0, 0
|
||||
*/
|
||||
public BlockPos getPosition()
|
||||
{
|
||||
return new BlockPos(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
// Auto generated package-info by MCP
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraft.client.entity;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
Reference in New Issue
Block a user