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

476 lines
24 KiB
Diff
Raw Normal View History

2019-05-23 23:02:15 +00:00
--- a/net/minecraft/entity/player/PlayerEntity.java
+++ b/net/minecraft/entity/player/PlayerEntity.java
2019-06-25 02:01:03 +00:00
@@ -108,6 +108,10 @@
import net.minecraftforge.api.distmarker.OnlyIn;
2019-05-23 23:02:15 +00:00
public abstract class PlayerEntity extends LivingEntity {
+ 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);
2019-05-23 23:02:15 +00:00
public static final EntitySize field_213835_bs = EntitySize.func_220314_b(0.6F, 1.8F);
private static final Map<Pose, EntitySize> field_213836_b = ImmutableMap.<Pose, EntitySize>builder().put(Pose.STANDING, field_213835_bs).put(Pose.SLEEPING, field_213377_as).put(Pose.FALL_FLYING, EntitySize.func_220314_b(0.6F, 0.6F)).put(Pose.SWIMMING, EntitySize.func_220314_b(0.6F, 0.6F)).put(Pose.SPIN_ATTACK, EntitySize.func_220314_b(0.6F, 0.6F)).put(Pose.SNEAKING, EntitySize.func_220314_b(0.6F, 1.5F)).put(Pose.DYING, EntitySize.func_220311_c(0.2F, 0.2F)).build();
private static final DataParameter<Float> field_184829_a = EntityDataManager.func_187226_a(PlayerEntity.class, DataSerializers.field_187193_c);
@@ -150,6 +154,9 @@
private final CooldownTracker field_184832_bU = this.func_184815_l();
@Nullable
2019-05-23 23:02:15 +00:00
public FishingBobberEntity field_71104_cf;
2019-06-25 02:01:03 +00:00
+ private net.minecraft.world.dimension.DimensionType spawnDimension = net.minecraft.world.dimension.DimensionType.field_223227_a_;
+ private final java.util.Collection<ITextComponent> prefixes = new java.util.LinkedList<ITextComponent>();
+ private final java.util.Collection<ITextComponent> suffixes = new java.util.LinkedList<ITextComponent>();
2019-05-23 23:02:15 +00:00
public PlayerEntity(World p_i45324_1_, GameProfile p_i45324_2_) {
super(EntityType.field_200729_aH, p_i45324_1_);
@@ -181,6 +188,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() {
@@ -194,6 +202,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;
@@ -209,7 +218,7 @@
2019-05-23 23:02:15 +00:00
this.field_71076_b = 100;
}
- if (!this.field_70170_p.field_72995_K && this.field_70170_p.func_72935_r()) {
+ if (!this.field_70170_p.field_72995_K && !net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck(this, func_213374_dv())) {
this.func_70999_a(false, true, true);
}
2019-05-23 23:02:15 +00:00
} else if (this.field_71076_b > 0) {
@@ -267,6 +276,7 @@
this.func_203041_m();
this.field_184832_bU.func_185144_a();
2019-05-23 23:02:15 +00:00
this.func_213832_dB();
+ net.minecraftforge.fml.hooks.BasicEventHooks.onPlayerPostTick(this);
}
protected boolean func_204229_de() {
@@ -441,10 +451,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);
2019-05-23 23:02:15 +00:00
- if (this.func_184187_bx() instanceof PigEntity) {
+ if (this.func_184187_bx() instanceof LivingEntity && ((LivingEntity)this.func_184187_bx()).shouldRiderFaceForward(this)) {
2018-12-05 09:16:33 +00:00
this.field_70125_A = f1;
this.field_70177_z = f;
2019-05-23 23:02:15 +00:00
- this.field_70761_aq = ((PigEntity)this.func_184187_bx()).field_70761_aq;
+ this.field_70761_aq = ((LivingEntity)this.func_184187_bx()).field_70761_aq;
}
}
@@ -557,6 +567,7 @@
}
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_70107_b(this.field_70165_t, this.field_70163_u, this.field_70161_v);
2019-05-23 23:02:15 +00:00
if (!this.func_175149_v()) {
@@ -611,12 +622,14 @@
@Nullable
2019-05-23 23:02:15 +00:00
public ItemEntity 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
2019-05-23 23:02:15 +00:00
public ItemEntity 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
@@ -650,7 +663,12 @@
2019-05-23 23:02:15 +00:00
}
}
+ @Deprecated //Use location sensitive version below
2019-05-23 23:02:15 +00:00
public float func_184813_a(BlockState p_184813_1_) {
+ return getDigSpeed(p_184813_1_, null);
+ }
+
2019-05-23 23:02:15 +00:00
+ public float getDigSpeed(BlockState 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);
@@ -692,11 +710,12 @@
f /= 5.0F;
}
+ f = net.minecraftforge.event.ForgeEventFactory.getBreakSpeed(this, p_184813_1_, f, pos);
return f;
}
2019-05-23 23:02:15 +00:00
public boolean func_184823_b(BlockState 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_));
}
2019-05-23 23:02:15 +00:00
public void func_70037_a(CompoundNBT p_70037_1_) {
@@ -720,6 +739,17 @@
this.field_82248_d = p_70037_1_.func_74767_n("SpawnForced");
}
+ p_70037_1_.func_150295_c("Spawns", 10).forEach(e -> {
2019-05-23 23:02:15 +00:00
+ CompoundNBT data = (CompoundNBT)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("SpawnForced"));
+ });
+ net.minecraft.world.dimension.DimensionType spawnDim = null;
+ if (p_70037_1_.func_150297_b("SpawnDimension", net.minecraftforge.common.util.Constants.NBT.TAG_STRING))
+ spawnDim = net.minecraft.world.dimension.DimensionType.func_193417_a(new ResourceLocation(p_70037_1_.func_74779_i("SpawnDimension")));
2019-06-25 02:01:03 +00:00
+ this.spawnDimension = spawnDim != null ? spawnDim : net.minecraft.world.dimension.DimensionType.field_223227_a_;
+
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)) {
@@ -765,9 +795,26 @@
2019-05-23 23:02:15 +00:00
p_213281_1_.func_218657_a("ShoulderEntityRight", this.func_192025_dl());
}
2019-05-23 23:02:15 +00:00
+ ListNBT spawnlist = new ListNBT();
+ spawnPosMap.forEach((dim, pos) -> {
+ if (pos != null) {
2019-05-23 23:02:15 +00:00
+ CompoundNBT data = new CompoundNBT();
+ 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);
+ }
+ });
2019-05-23 23:02:15 +00:00
+ p_213281_1_.func_218657_a("Spawns", spawnlist);
2019-06-25 02:01:03 +00:00
+ if (spawnDimension != net.minecraft.world.dimension.DimensionType.field_223227_a_) {
2019-05-23 23:02:15 +00:00
+ p_213281_1_.func_74778_a("SpawnDimension", spawnDimension.getRegistryName().toString());
+ }
}
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()) {
@@ -799,7 +846,7 @@
2018-12-05 09:16:33 +00:00
2019-05-23 23:02:15 +00:00
protected void func_190629_c(LivingEntity p_190629_1_) {
2018-12-05 09:16:33 +00:00
super.func_190629_c(p_190629_1_);
2019-05-23 23:02:15 +00:00
- if (p_190629_1_.func_184614_ca().func_77973_b() instanceof AxeItem) {
2018-12-05 09:16:33 +00:00
+ if (p_190629_1_.func_184614_ca().canDisableShield(this.field_184627_bm, this, p_190629_1_)) {
this.func_190777_m(true);
}
@@ -820,13 +867,15 @@
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_);
2019-05-23 23:02:15 +00:00
Hand hand = this.func_184600_cs();
this.field_184627_bm.func_222118_a(i, this, (p_213833_1_) -> {
p_213833_1_.func_213334_d(hand);
});
2018-12-05 09:16:33 +00:00
if (this.field_184627_bm.func_190926_b()) {
2019-05-23 23:02:15 +00:00
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, copy, hand);
if (hand == Hand.MAIN_HAND) {
this.func_184201_a(EquipmentSlotType.MAINHAND, ItemStack.field_190927_a);
} else {
@@ -842,11 +891,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) {
2019-05-23 23:02:15 +00:00
this.func_195067_a(Stats.field_212738_J, Math.round(f1 * 10.0F));
@@ -901,6 +953,8 @@
2019-05-23 23:02:15 +00:00
return ActionResultType.PASS;
} else {
2019-05-23 23:02:15 +00:00
+ ActionResultType 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_)) {
@@ -908,6 +962,9 @@
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_);
+ }
2019-05-23 23:02:15 +00:00
return ActionResultType.SUCCESS;
} else {
2019-05-23 23:02:15 +00:00
if (!itemstack.func_190926_b() && p_190775_1_ instanceof LivingEntity) {
@@ -917,6 +974,7 @@
2019-05-23 23:02:15 +00:00
if (itemstack.func_111282_a(this, (LivingEntity)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);
}
@@ -943,6 +1001,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();
@@ -970,8 +1029,10 @@
2019-05-23 23:02:15 +00:00
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(Effects.field_76440_q) && !this.func_184218_aH() && p_71059_1_ instanceof LivingEntity;
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;
@@ -1059,8 +1120,10 @@
}
2019-05-23 23:02:15 +00:00
if (!this.field_70170_p.field_72995_K && !itemstack1.func_190926_b() && entity instanceof LivingEntity) {
+ ItemStack copy = itemstack1.func_77946_l();
2019-05-23 23:02:15 +00:00
itemstack1.func_77961_a((LivingEntity)entity, this);
if (itemstack1.func_190926_b()) {
2019-05-23 23:02:15 +00:00
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, copy, Hand.MAIN_HAND);
this.func_184611_a(Hand.MAIN_HAND, ItemStack.field_190927_a);
}
}
@@ -1102,7 +1165,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);
}
@@ -1146,6 +1209,9 @@
}
2019-05-23 23:02:15 +00:00
public Either<PlayerEntity.SleepResult, Unit> func_213819_a(BlockPos p_213819_1_) {
+ Optional<BlockPos> optAt = Optional.of(p_213819_1_);
+ PlayerEntity.SleepResult ret = net.minecraftforge.event.ForgeEventFactory.onPlayerSleepInBed(this, optAt);
2019-05-23 23:02:15 +00:00
+ if (ret != null) return Either.left(ret);
Direction direction = this.field_70170_p.func_180495_p(p_213819_1_).func_177229_b(HorizontalBlock.field_185512_D);
if (!this.field_70170_p.field_72995_K) {
if (this.func_70608_bn() || !this.func_70089_S()) {
@@ -1156,7 +1222,7 @@
2019-05-23 23:02:15 +00:00
return Either.left(PlayerEntity.SleepResult.NOT_POSSIBLE_HERE);
}
- if (this.field_70170_p.func_72935_r()) {
+ if (!net.minecraftforge.event.ForgeEventFactory.fireSleepingTimeCheck(this, optAt)) {
2019-05-23 23:02:15 +00:00
return Either.left(PlayerEntity.SleepResult.NOT_POSSIBLE_NOW);
}
@@ -1197,6 +1263,8 @@
2019-05-23 23:02:15 +00:00
private boolean func_190774_a(BlockPos p_190774_1_, Direction 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;
@@ -1209,6 +1277,7 @@
}
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_);
2019-05-23 23:02:15 +00:00
Optional<BlockPos> optional = this.func_213374_dv();
super.func_213366_dy();
if (this.field_70170_p instanceof ServerWorld && p_70999_2_) {
@@ -1229,17 +1298,17 @@
}
2019-05-23 23:02:15 +00:00
public static Optional<Vec3d> func_213822_a(IWorldReader p_213822_0_, BlockPos p_213822_1_, boolean p_213822_2_) {
- Block block = p_213822_0_.func_180495_p(p_213822_1_).func_177230_c();
- if (!(block instanceof BedBlock)) {
+ BlockState blockState = p_213822_0_.func_180495_p(p_213822_1_);
+ if (!(blockState.isBed(p_213822_0_, p_213822_1_, null))) {
if (!p_213822_2_) {
return Optional.empty();
} else {
- boolean flag = block.func_181623_g();
2019-05-23 23:02:15 +00:00
+ boolean flag = blockState.func_177230_c().func_181623_g();
boolean flag1 = p_213822_0_.func_180495_p(p_213822_1_.func_177984_a()).func_177230_c().func_181623_g();
return flag && flag1 ? Optional.of(new Vec3d((double)p_213822_1_.func_177958_n() + 0.5D, (double)p_213822_1_.func_177956_o() + 0.1D, (double)p_213822_1_.func_177952_p() + 0.5D)) : Optional.empty();
}
} else {
2019-05-23 23:02:15 +00:00
- return BedBlock.func_220172_a(EntityType.field_200729_aH, p_213822_0_, p_213822_1_, 0);
+ return blockState.getBedSpawnPosition(EntityType.field_200729_aH, p_213822_0_, p_213822_1_, null);
}
}
@@ -1254,23 +1323,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 dim 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) {
2019-06-25 02:01:03 +00:00
+ return dim == net.minecraft.world.dimension.DimensionType.field_223227_a_ ? field_71077_c : spawnPosMap.get(dim.getRegistryName());
+ }
+
+ @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 dim 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) {
2019-06-25 02:01:03 +00:00
+ return dim == net.minecraft.world.dimension.DimensionType.field_223227_a_ ? field_82248_d : spawnForcedMap.getOrDefault(dim.getRegistryName(), 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 dim Which dimension to apply the player-specific respawn point to
+ */
+ public void setSpawnPoint(@Nullable BlockPos pos, boolean forced, net.minecraft.world.dimension.DimensionType dim) {
+ if(net.minecraftforge.event.ForgeEventFactory.onPlayerSpawnSet(this, pos, forced)) return;
2019-06-25 02:01:03 +00:00
+ if (dim != net.minecraft.world.dimension.DimensionType.field_223227_a_) {
+ 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_) {
@@ -1436,6 +1549,8 @@
}
super.func_180430_e(p_180430_1_, p_180430_2_);
+ } else {
+ net.minecraftforge.event.ForgeEventFactory.onPlayerFall(this, p_180430_1_, p_180430_2_);
}
}
@@ -1703,7 +1818,10 @@
}
public ITextComponent func_145748_c_() {
- ITextComponent itextcomponent = ScorePlayerTeam.func_200541_a(this.func_96124_cp(), this.func_200200_C_());
2019-05-23 23:02:15 +00:00
+ ITextComponent itextcomponent = new StringTextComponent("");
+ 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);
}
@@ -1939,4 +2057,44 @@
2019-05-23 23:02:15 +00:00
return this.field_221260_g;
}
}
2019-05-23 23:02:15 +00:00
+ // =========== FORGE START ==============//
+ 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;
+ }
2019-05-23 23:02:15 +00:00
+
+ 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));
2019-05-23 23:02:15 +00:00
+
+ 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)));
2019-05-23 23:02:15 +00:00
+
+ 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));
2019-05-23 23:02:15 +00:00
+
+ @Override
2019-05-23 23:02:15 +00:00
+ public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable Direction 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);
+ }
2019-05-23 23:02:15 +00:00
}