ForgePatch/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch

556 lines
27 KiB
Diff
Raw Normal View History

--- a/net/minecraft/entity/player/EntityPlayer.java
+++ b/net/minecraft/entity/player/EntityPlayer.java
@@ -98,6 +98,10 @@
import net.minecraftforge.api.distmarker.OnlyIn;
public abstract class EntityPlayer extends EntityLivingBase {
+ public static final String PERSISTED_NBT_TAG = "PlayerPersisted";
+ protected java.util.HashMap<ResourceLocation, BlockPos> spawnPosMap = new java.util.HashMap<>();
+ protected java.util.HashMap<ResourceLocation, Boolean> spawnForcedMap = new java.util.HashMap<>();
+ public static final net.minecraft.entity.ai.attributes.IAttribute REACH_DISTANCE = new net.minecraft.entity.ai.attributes.RangedAttribute(null, "generic.reachDistance", 5.0D, 0.0D, 1024.0D).func_111112_a(true);
private static final DataParameter<Float> field_184829_a = EntityDataManager.func_187226_a(EntityPlayer.class, DataSerializers.field_187193_c);
private static final DataParameter<Integer> field_184830_b = EntityDataManager.func_187226_a(EntityPlayer.class, DataSerializers.field_187192_b);
protected static final DataParameter<Byte> field_184827_bp = EntityDataManager.func_187226_a(EntityPlayer.class, DataSerializers.field_187191_a);
@@ -144,6 +148,10 @@
private final CooldownTracker field_184832_bU = this.func_184815_l();
@Nullable
public EntityFishHook field_71104_cf;
+ private float eyeHeight = this.getDefaultEyeHeight();
+ private net.minecraft.world.dimension.DimensionType spawnDimension = net.minecraft.world.dimension.DimensionType.OVERWORLD;
+ private final java.util.Collection<ITextComponent> prefixes = new java.util.LinkedList<ITextComponent>();
+ private final java.util.Collection<ITextComponent> suffixes = new java.util.LinkedList<ITextComponent>();
public EntityPlayer(World p_i45324_1_, GameProfile p_i45324_2_) {
super(EntityType.field_200729_aH, p_i45324_1_);
@@ -162,6 +170,7 @@
this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a((double)0.1F);
this.func_110140_aT().func_111150_b(SharedMonsterAttributes.field_188790_f);
this.func_110140_aT().func_111150_b(SharedMonsterAttributes.field_188792_h);
+ this.func_110140_aT().func_111150_b(REACH_DISTANCE);
}
protected void func_70088_a() {
@@ -175,6 +184,7 @@
}
public void func_70071_h_() {
+ net.minecraftforge.fml.hooks.BasicEventHooks.onPlayerPreTick(this);
this.field_70145_X = this.func_175149_v();
if (this.func_175149_v()) {
this.field_70122_E = false;
@@ -193,7 +203,7 @@
if (!this.field_70170_p.field_72995_K) {
if (!this.func_175143_p()) {
this.func_70999_a(true, true, false);
- } else if (this.field_70170_p.func_72935_r()) {
+ } else if (!net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck(this, this.field_71081_bT)) {
this.func_70999_a(false, true, true);
}
}
@@ -253,6 +263,7 @@
this.func_203041_m();
this.field_184832_bU.func_185144_a();
this.func_184808_cD();
+ net.minecraftforge.fml.hooks.BasicEventHooks.onPlayerPostTick(this);
}
protected boolean func_204229_de() {
@@ -434,10 +445,10 @@
2018-12-05 09:16:33 +00:00
this.field_71107_bF = this.field_71109_bG;
this.field_71109_bG = 0.0F;
this.func_71015_k(this.field_70165_t - d0, this.field_70163_u - d1, this.field_70161_v - d2);
- if (this.func_184187_bx() instanceof EntityPig) {
+ if (this.func_184187_bx() instanceof EntityLivingBase && ((EntityLivingBase)this.func_184187_bx()).shouldRiderFaceForward(this)) {
this.field_70125_A = f1;
this.field_70177_z = f;
- this.field_70761_aq = ((EntityPig)this.func_184187_bx()).field_70761_aq;
+ this.field_70761_aq = ((EntityLivingBase)this.func_184187_bx()).field_70761_aq;
}
}
@@ -556,10 +567,12 @@
}
public void func_70645_a(DamageSource p_70645_1_) {
+ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_70645_1_)) return;
super.func_70645_a(p_70645_1_);
this.func_70105_a(0.2F, 0.2F);
this.func_70107_b(this.field_70165_t, this.field_70163_u, this.field_70161_v);
this.field_70181_x = (double)0.1F;
+ captureDrops(new java.util.ArrayList<>());
if ("Notch".equals(this.func_200200_C_().getString())) {
this.func_146097_a(new ItemStack(Items.field_151034_e), true, false);
}
@@ -569,6 +582,8 @@
this.field_71071_by.func_70436_m();
}
+ if (!field_70170_p.field_72995_K) net.minecraftforge.event.ForgeEventFactory.onPlayerDrops(this, p_70645_1_, captureDrops(null), field_70718_bc > 0);
+
if (p_70645_1_ != null) {
this.field_70159_w = (double)(-MathHelper.func_76134_b((this.field_70739_aP + this.field_70177_z) * ((float)Math.PI / 180F)) * 0.1F);
this.field_70179_y = (double)(-MathHelper.func_76126_a((this.field_70739_aP + this.field_70177_z) * ((float)Math.PI / 180F)) * 0.1F);
@@ -608,12 +623,14 @@
@Nullable
public EntityItem func_71040_bB(boolean p_71040_1_) {
- return this.func_146097_a(this.field_71071_by.func_70298_a(this.field_71071_by.field_70461_c, p_71040_1_ && !this.field_71071_by.func_70448_g().func_190926_b() ? this.field_71071_by.func_70448_g().func_190916_E() : 1), false, true);
+ ItemStack stack = field_71071_by.func_70448_g();
+ if (stack.func_190926_b() || !stack.onDroppedByPlayer(this)) return null;
+ return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, this.field_71071_by.func_70298_a(this.field_71071_by.field_70461_c, p_71040_1_ && !this.field_71071_by.func_70448_g().func_190926_b() ? this.field_71071_by.func_70448_g().func_190916_E() : 1), true);
}
@Nullable
public EntityItem func_71019_a(ItemStack p_71019_1_, boolean p_71019_2_) {
- return this.func_146097_a(p_71019_1_, false, p_71019_2_);
+ return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, p_71019_1_, false);
}
@Nullable
@@ -660,11 +677,18 @@
}
public ItemStack func_184816_a(EntityItem p_184816_1_) {
+ if (captureDrops() != null) captureDrops().add(p_184816_1_);
+ else
this.field_70170_p.func_72838_d(p_184816_1_);
return p_184816_1_.func_92059_d();
}
+ @Deprecated //Use location sensitive version below
public float func_184813_a(IBlockState p_184813_1_) {
+ return getDigSpeed(p_184813_1_, null);
+ }
+
+ public float getDigSpeed(IBlockState p_184813_1_, @Nullable BlockPos pos) {
float f = this.field_71071_by.func_184438_a(p_184813_1_);
if (f > 1.0F) {
int i = EnchantmentHelper.func_185293_e(this);
@@ -706,11 +730,12 @@
f /= 5.0F;
}
+ f = net.minecraftforge.event.ForgeEventFactory.getBreakSpeed(this, p_184813_1_, f, pos);
return f;
}
public boolean func_184823_b(IBlockState p_184823_1_) {
- return p_184823_1_.func_185904_a().func_76229_l() || this.field_71071_by.func_184432_b(p_184823_1_);
+ return net.minecraftforge.event.ForgeEventFactory.doPlayerHarvestCheck(this, p_184823_1_, p_184823_1_.func_185904_a().func_76229_l() || this.field_71071_by.func_184432_b(p_184823_1_));
}
public void func_70037_a(NBTTagCompound p_70037_1_) {
@@ -740,6 +765,14 @@
this.field_82248_d = p_70037_1_.func_74767_n("SpawnForced");
}
+ p_70037_1_.func_150295_c("Spawns", 10).forEach(e -> {
+ NBTTagCompound data = (NBTTagCompound)e;
+ ResourceLocation dim = new ResourceLocation(data.func_74779_i("Dim"));
+ this.spawnPosMap.put(dim, new BlockPos(data.func_74762_e("SpawnX"), data.func_74762_e("SpawnY"), data.func_74762_e("SpawnZ")));
+ this.spawnForcedMap.put(dim, data.func_74767_n("DpawnForced"));
+ });
+ this.spawnDimension = net.minecraft.world.dimension.DimensionType.func_186069_a(p_70037_1_.func_150297_b("SpawnDimension", 99) ? p_70037_1_.func_74762_e("SpawnDimension") : 0);
+
this.field_71100_bB.func_75112_a(p_70037_1_);
this.field_71075_bZ.func_75095_b(p_70037_1_);
if (p_70037_1_.func_150297_b("EnderItems", 9)) {
@@ -786,9 +819,26 @@
p_70014_1_.func_74782_a("ShoulderEntityRight", this.func_192025_dl());
}
+ NBTTagList spawnlist = new NBTTagList();
+ spawnPosMap.forEach((dim, pos) -> {
+ if (pos != null) {
+ NBTTagCompound data = new NBTTagCompound();
+ data.func_74778_a("Dim", dim.toString());
+ data.func_74768_a("SpawnX", pos.func_177958_n());
+ data.func_74768_a("SpawnY", pos.func_177956_o());
+ data.func_74768_a("SpawnZ", pos.func_177952_p());
+ data.func_74757_a("SpawnForced", spawnForcedMap.getOrDefault(dim, false));
+ spawnlist.add(data);
+ }
+ });
+ p_70014_1_.func_74782_a("Spawns", spawnlist);
+ if (spawnDimension != net.minecraft.world.dimension.DimensionType.OVERWORLD) {
+ p_70014_1_.func_74768_a("SpawnDimension", spawnDimension.func_186068_a());
+ }
}
public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) {
+ if (!net.minecraftforge.common.ForgeHooks.onPlayerAttack(this, p_70097_1_, p_70097_2_)) return false;
if (this.func_180431_b(p_70097_1_)) {
return false;
} else if (this.field_71075_bZ.field_75102_a && !p_70097_1_.func_76357_e()) {
@@ -824,7 +874,7 @@
2018-12-05 09:16:33 +00:00
protected void func_190629_c(EntityLivingBase p_190629_1_) {
super.func_190629_c(p_190629_1_);
- if (p_190629_1_.func_184614_ca().func_77973_b() instanceof ItemAxe) {
+ if (p_190629_1_.func_184614_ca().canDisableShield(this.field_184627_bm, this, p_190629_1_)) {
this.func_190777_m(true);
}
@@ -845,11 +895,13 @@
2018-12-05 09:16:33 +00:00
}
protected void func_184590_k(float p_184590_1_) {
- if (p_184590_1_ >= 3.0F && this.field_184627_bm.func_77973_b() == Items.field_185159_cQ) {
+ if (p_184590_1_ >= 3.0F && this.field_184627_bm.isShield(this)) {
+ ItemStack copy = this.field_184627_bm.func_77946_l();
2018-12-05 09:16:33 +00:00
int i = 1 + MathHelper.func_76141_d(p_184590_1_);
this.field_184627_bm.func_77972_a(i, this);
if (this.field_184627_bm.func_190926_b()) {
EnumHand enumhand = this.func_184600_cs();
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, copy, enumhand);
if (enumhand == EnumHand.MAIN_HAND) {
this.func_184201_a(EntityEquipmentSlot.MAINHAND, ItemStack.field_190927_a);
} else {
@@ -877,11 +929,14 @@
protected void func_70665_d(DamageSource p_70665_1_, float p_70665_2_) {
if (!this.func_180431_b(p_70665_1_)) {
+ p_70665_2_ = net.minecraftforge.common.ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_);
+ if (p_70665_2_ <= 0) return;
p_70665_2_ = this.func_70655_b(p_70665_1_, p_70665_2_);
p_70665_2_ = this.func_70672_c(p_70665_1_, p_70665_2_);
float f = p_70665_2_;
p_70665_2_ = Math.max(p_70665_2_ - this.func_110139_bj(), 0.0F);
this.func_110149_m(this.func_110139_bj() - (f - p_70665_2_));
+ p_70665_2_ = net.minecraftforge.common.ForgeHooks.onLivingDamage(this, p_70665_1_, p_70665_2_);
float f1 = f - p_70665_2_;
if (f1 > 0.0F && f1 < 3.4028235E37F) {
this.func_195067_a(StatList.field_212738_J, Math.round(f1 * 10.0F));
@@ -935,6 +990,8 @@
return EnumActionResult.PASS;
} else {
+ EnumActionResult cancelResult = net.minecraftforge.common.ForgeHooks.onInteractEntity(this, p_190775_1_, p_190775_2_);
+ if (cancelResult != null) return cancelResult;
ItemStack itemstack = this.func_184586_b(p_190775_2_);
ItemStack itemstack1 = itemstack.func_190926_b() ? ItemStack.field_190927_a : itemstack.func_77946_l();
if (p_190775_1_.func_184230_a(this, p_190775_2_)) {
@@ -942,6 +999,10 @@
itemstack.func_190920_e(itemstack1.func_190916_E());
}
+ if (!this.field_71075_bZ.field_75098_d && itemstack.func_190926_b()) {
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, p_190775_2_);
+ }
+
return EnumActionResult.SUCCESS;
} else {
if (!itemstack.func_190926_b() && p_190775_1_ instanceof EntityLivingBase) {
@@ -951,6 +1012,7 @@
if (itemstack.func_111282_a(this, (EntityLivingBase)p_190775_1_, p_190775_2_)) {
if (itemstack.func_190926_b() && !this.field_71075_bZ.field_75098_d) {
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, p_190775_2_);
this.func_184611_a(p_190775_2_, ItemStack.field_190927_a);
}
@@ -973,6 +1035,7 @@
}
public void func_71059_n(Entity p_71059_1_) {
+ if (!net.minecraftforge.common.ForgeHooks.onPlayerAttackTarget(this, p_71059_1_)) return;
if (p_71059_1_.func_70075_an()) {
if (!p_71059_1_.func_85031_j(this)) {
float f = (float)this.func_110148_a(SharedMonsterAttributes.field_111264_e).func_111126_e();
@@ -1000,8 +1063,11 @@
boolean flag2 = flag && this.field_70143_R > 0.0F && !this.field_70122_E && !this.func_70617_f_() && !this.func_70090_H() && !this.func_70644_a(MobEffects.field_76440_q) && !this.func_184218_aH() && p_71059_1_ instanceof EntityLivingBase;
flag2 = flag2 && !this.func_70051_ag();
+
+ net.minecraftforge.event.entity.player.CriticalHitEvent hitResult = net.minecraftforge.common.ForgeHooks.getCriticalHit(this, p_71059_1_, flag2, flag2 ? 1.5F : 1.0F);
+ flag2 = hitResult != null;
if (flag2) {
- f *= 1.5F;
+ f *= hitResult.getDamageModifier();
}
f = f + f1;
@@ -1097,8 +1163,10 @@
}
if (!itemstack1.func_190926_b() && entity instanceof EntityLivingBase) {
+ ItemStack copy = itemstack1.func_77946_l();
itemstack1.func_77961_a((EntityLivingBase)entity, this);
if (itemstack1.func_190926_b()) {
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, copy, EnumHand.MAIN_HAND);
this.func_184611_a(EnumHand.MAIN_HAND, ItemStack.field_190927_a);
}
}
@@ -1140,7 +1208,7 @@
}
if (this.field_70146_Z.nextFloat() < f) {
- this.func_184811_cZ().func_185145_a(Items.field_185159_cQ, 100);
+ this.func_184811_cZ().func_185145_a(this.func_184607_cu().func_77973_b(), 100);
this.func_184602_cy();
this.field_70170_p.func_72960_a(this, (byte)30);
}
@@ -1188,7 +1256,11 @@
}
public EntityPlayer.SleepResult func_180469_a(BlockPos p_180469_1_) {
- EnumFacing enumfacing = this.field_70170_p.func_180495_p(p_180469_1_).func_177229_b(BlockHorizontal.field_185512_D);
+ EntityPlayer.SleepResult ret = net.minecraftforge.event.ForgeEventFactory.onPlayerSleepInBed(this, p_180469_1_);
+ if (ret != null) return ret;
+ final IBlockState state = this.field_70170_p.func_175667_e(p_180469_1_) ? this.field_70170_p.func_180495_p(p_180469_1_) : null;
+ final boolean isBed = state != null && state.isBed(this.field_70170_p, p_180469_1_, this);
+ final EnumFacing enumfacing = isBed && state.func_177230_c() instanceof BlockHorizontal ? (EnumFacing)state.func_177229_b(BlockHorizontal.field_185512_D) : null;
if (!this.field_70170_p.field_72995_K) {
if (this.func_70608_bn() || !this.func_70089_S()) {
return EntityPlayer.SleepResult.OTHER_PROBLEM;
@@ -1198,7 +1270,7 @@
return EntityPlayer.SleepResult.NOT_POSSIBLE_HERE;
}
- if (this.field_70170_p.func_72935_r()) {
+ if (!net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck(this, p_180469_1_)) {
return EntityPlayer.SleepResult.NOT_POSSIBLE_NOW;
}
@@ -1223,7 +1295,7 @@
this.func_192030_dh();
this.func_175145_a(StatList.field_199092_j.func_199076_b(StatList.field_203284_n));
this.func_70105_a(0.2F, 0.2F);
- if (this.field_70170_p.func_175667_e(p_180469_1_)) {
+ if (enumfacing != null) {
float f1 = 0.5F + (float)enumfacing.func_82601_c() * 0.4F;
float f = 0.5F + (float)enumfacing.func_82599_e() * 0.4F;
this.func_175139_a(enumfacing);
@@ -1248,6 +1320,8 @@
private boolean func_190774_a(BlockPos p_190774_1_, EnumFacing p_190774_2_) {
if (Math.abs(this.field_70165_t - (double)p_190774_1_.func_177958_n()) <= 3.0D && Math.abs(this.field_70163_u - (double)p_190774_1_.func_177956_o()) <= 2.0D && Math.abs(this.field_70161_v - (double)p_190774_1_.func_177952_p()) <= 3.0D) {
return true;
+ } else if (p_190774_2_ == null) {
+ return false;
} else {
BlockPos blockpos = p_190774_1_.func_177972_a(p_190774_2_.func_176734_d());
return Math.abs(this.field_70165_t - (double)blockpos.func_177958_n()) <= 3.0D && Math.abs(this.field_70163_u - (double)blockpos.func_177956_o()) <= 2.0D && Math.abs(this.field_70161_v - (double)blockpos.func_177952_p()) <= 3.0D;
@@ -1260,16 +1334,19 @@
}
public void func_70999_a(boolean p_70999_1_, boolean p_70999_2_, boolean p_70999_3_) {
+ net.minecraftforge.event.ForgeEventFactory.onPlayerWakeup(this, p_70999_1_, p_70999_2_, p_70999_3_);
this.func_70105_a(0.6F, 1.8F);
- IBlockState iblockstate = this.field_70170_p.func_180495_p(this.field_71081_bT);
- if (this.field_71081_bT != null && iblockstate.func_177230_c() instanceof BlockBed) {
- this.field_70170_p.func_180501_a(this.field_71081_bT, iblockstate.func_206870_a(BlockBed.field_176471_b, Boolean.valueOf(false)), 4);
- BlockPos blockpos = BlockBed.func_176468_a(this.field_70170_p, this.field_71081_bT, 0);
+ IBlockState iblockstate = field_71081_bT == null ? null : this.field_70170_p.func_180495_p(this.field_71081_bT);
+ if (this.field_71081_bT != null && iblockstate.isBed(field_70170_p, field_71081_bT, this)) {
+ iblockstate.setBedOccupied(field_70170_p, field_71081_bT, this, false);
+ BlockPos blockpos = iblockstate.getBedSpawnPosition(field_70170_p, field_71081_bT, this);
if (blockpos == null) {
blockpos = this.field_71081_bT.func_177984_a();
}
this.func_70107_b((double)((float)blockpos.func_177958_n() + 0.5F), (double)((float)blockpos.func_177956_o() + 0.1F), (double)((float)blockpos.func_177952_p() + 0.5F));
+ } else {
+ p_70999_3_ = false;
}
this.field_71083_bS = false;
@@ -1285,29 +1362,30 @@
}
private boolean func_175143_p() {
- return this.field_70170_p.func_180495_p(this.field_71081_bT).func_177230_c() instanceof BlockBed;
+ return net.minecraftforge.event.ForgeEventFactory.fireSleepingLocationCheck(this, this.field_71081_bT);
}
@Nullable
public static BlockPos func_180467_a(IBlockReader p_180467_0_, BlockPos p_180467_1_, boolean p_180467_2_) {
- Block block = p_180467_0_.func_180495_p(p_180467_1_).func_177230_c();
- if (!(block instanceof BlockBed)) {
+ IBlockState state = p_180467_0_.func_180495_p(p_180467_1_);
+ if (!state.isBed(p_180467_0_, p_180467_1_, null)) {
if (!p_180467_2_) {
return null;
} else {
- boolean flag = block.func_181623_g();
+ boolean flag = state.func_177230_c().func_181623_g();
boolean flag1 = p_180467_0_.func_180495_p(p_180467_1_.func_177984_a()).func_177230_c().func_181623_g();
return flag && flag1 ? p_180467_1_ : null;
}
} else {
- return BlockBed.func_176468_a(p_180467_0_, p_180467_1_, 0);
+ return state.getBedSpawnPosition(p_180467_0_, p_180467_1_, null);
}
}
@OnlyIn(Dist.CLIENT)
public float func_71051_bG() {
if (this.field_71081_bT != null) {
- EnumFacing enumfacing = this.field_70170_p.func_180495_p(this.field_71081_bT).func_177229_b(BlockHorizontal.field_185512_D);
+ IBlockState state = this.field_70170_p.func_180495_p(this.field_71081_bT);
+ EnumFacing enumfacing = !state.isBed(field_70170_p, field_71081_bT, this) ? EnumFacing.UP : state.getBedDirection(field_70170_p, field_71081_bT);
switch(enumfacing) {
case SOUTH:
return 90.0F;
@@ -1339,23 +1417,67 @@
public void func_146105_b(ITextComponent p_146105_1_, boolean p_146105_2_) {
}
+ @Deprecated //Forge: Use Dimension sensitive version
public BlockPos func_180470_cg() {
- return this.field_71077_c;
+ return getBedLocation(this.field_71093_bK);
}
+ /**
+ * A dimension aware version of getBedLocation.
+ * @param dimension The dimension to get the bed spawn for
+ * @return The player specific spawn location for the dimension. May be null.
+ */
+ public BlockPos getBedLocation(net.minecraft.world.dimension.DimensionType dim) {
+ return dim == net.minecraft.world.dimension.DimensionType.OVERWORLD ? field_71081_bT : spawnPosMap.get(dim);
+ }
+
+ @Deprecated //Forge: Use Dimension sensitive version
public boolean func_82245_bX() {
- return this.field_82248_d;
+ return isSpawnForced(this.field_71093_bK);
}
+ /**
+ * A dimension aware version of isSpawnForced.
+ * Noramally isSpawnForced is used to determine if the respawn system should check for a bed or not.
+ * This just extends that to be dimension aware.
+ * @param dimension The dimension to get whether to check for a bed before spawning for
+ * @return The player specific spawn location for the dimension. May be null.
+ */
+ public boolean isSpawnForced(net.minecraft.world.dimension.DimensionType dim) {
+ return dim == net.minecraft.world.dimension.DimensionType.OVERWORLD ? field_82248_d : spawnForcedMap.getOrDefault(dim, false);
+ }
+
+ @Deprecated //Forge: Use Dimension sensitive version
public void func_180473_a(BlockPos p_180473_1_, boolean p_180473_2_) {
- if (p_180473_1_ != null) {
- this.field_71077_c = p_180473_1_;
- this.field_82248_d = p_180473_2_;
- } else {
- this.field_71077_c = null;
- this.field_82248_d = false;
- }
+ setSpawnPoint(p_180473_1_, p_180473_2_, this.field_71093_bK);
+ }
+ /**
+ * A dimension aware version of setSpawnChunk.
+ * This functions identically, but allows you to specify which dimension to affect, rather than affecting the player's current dimension.
+ * @param pos The spawn point to set as the player-specific spawn point for the dimension
+ * @param forced Whether or not the respawn code should check for a bed at this location (true means it won't check for a bed)
+ * @param dimension Which dimension to apply the player-specific respawn point to
+ */
+ public void setSpawnPoint(BlockPos pos, boolean forced, net.minecraft.world.dimension.DimensionType dim) {
+ if(net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnSet(this, pos, forced)) return;
+ if (dim != net.minecraft.world.dimension.DimensionType.OVERWORLD) {
+ if (pos == null) {
+ spawnPosMap.remove(dim.getRegistryName());
+ spawnForcedMap.remove(dim.getRegistryName());
+ } else {
+ spawnPosMap.put(dim.getRegistryName(), pos);
+ spawnForcedMap.put(dim.getRegistryName(), forced);
+ }
+ return;
+ }
+ if (pos != null) {
+ this.field_71077_c = pos;
+ this.field_82248_d = forced;
+ } else {
+ this.field_71077_c = null;
+ this.field_82248_d = false;
+ }
}
public void func_195066_a(ResourceLocation p_195066_1_) {
@@ -1525,6 +1647,8 @@
}
super.func_180430_e(p_180430_1_, p_180430_2_);
+ } else {
+ net.minecraftforge.event.ForgeEventFactory.onPlayerFall(this, p_180430_1_, p_180430_2_);
}
}
@@ -1786,7 +1910,10 @@
}
public ITextComponent func_145748_c_() {
- ITextComponent itextcomponent = ScorePlayerTeam.func_200541_a(this.func_96124_cp(), this.func_200200_C_());
+ ITextComponent itextcomponent = new TextComponentString("");
+ prefixes.forEach(e -> itextcomponent.func_150257_a(e));
+ itextcomponent.func_150257_a(ScorePlayerTeam.func_200541_a(this.func_96124_cp(), this.func_200200_C_()));
+ suffixes.forEach(e -> itextcomponent.func_150257_a(e));
return this.func_208016_c(itextcomponent);
}
@@ -1806,7 +1933,7 @@
}
public float func_70047_e() {
- float f = 1.62F;
+ float f = eyeHeight;
if (this.func_70608_bn()) {
f = 0.2F;
} else if (!this.func_203007_ba() && !this.func_184613_cA() && this.field_70131_O != 0.6F) {
@@ -1973,6 +2100,54 @@
return this.field_71075_bZ.field_75098_d && this.func_184840_I() >= 2;
}
+ /**
+ * Returns the default eye height of the player
+ * @return player default eye height
+ */
+ public float getDefaultEyeHeight() {
+ return 1.62F;
+ }
+
+ public net.minecraft.world.dimension.DimensionType getSpawnDimension() {
+ return this.spawnDimension;
+ }
+
+ public void setSpawnDimenion(net.minecraft.world.dimension.DimensionType dim) {
+ this.spawnDimension = dim;
+ }
+
+ public Collection<ITextComponent> getPrefixes() {
+ return this.prefixes;
+ }
+
+ public Collection<ITextComponent> getSuffixes() {
+ return this.suffixes;
+ }
+
+ private final net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler>
+ playerMainHandler = net.minecraftforge.common.util.LazyOptional.of(
+ () -> new net.minecraftforge.items.wrapper.PlayerMainInvWrapper(field_71071_by));
+
+ private final net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler>
+ playerEquipmentHandler = net.minecraftforge.common.util.LazyOptional.of(
+ () -> new net.minecraftforge.items.wrapper.CombinedInvWrapper(
+ new net.minecraftforge.items.wrapper.PlayerArmorInvWrapper(field_71071_by),
+ new net.minecraftforge.items.wrapper.PlayerOffhandInvWrapper(field_71071_by)));
+
+ private final net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler>
+ playerJoinedHandler = net.minecraftforge.common.util.LazyOptional.of(
+ () -> new net.minecraftforge.items.wrapper.PlayerInvWrapper(field_71071_by));
+
+ @Override
+ public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable EnumFacing facing) {
+ if (this.func_70089_S() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
+ if (facing == null) return playerJoinedHandler.cast();
+ else if (facing.func_176740_k().func_200128_b()) return playerMainHandler.cast();
+ else if (facing.func_176740_k().func_176722_c()) return playerEquipmentHandler.cast();
+ }
+ return super.getCapability(capability, facing);
+ }
+
public static enum EnumChatVisibility {
FULL(0, "options.chat.visibility.full"),
SYSTEM(1, "options.chat.visibility.system"),