Fix vanilla bug where player reputations villages were reset on read.

Deprecated Username based API in favor of UUID based API.
This commit is contained in:
LexManos 2017-03-31 02:33:39 -07:00
parent 006b8cc8bd
commit 72937c90be
4 changed files with 204 additions and 16 deletions

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntityIronGolem.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntityIronGolem.java
@@ -287,7 +287,7 @@
{
if (!this.func_70850_q() && this.field_70717_bb != null && this.field_70857_d != null)
{
- this.field_70857_d.func_82688_a(this.field_70717_bb.func_70005_c_(), -5);
+ this.field_70857_d.modifyPlayerReputation(this.field_70717_bb.func_110124_au(), -5);
}
super.func_70645_a(p_70645_1_);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,137 @@
--- ../src-base/minecraft/net/minecraft/village/Village.java
+++ ../src-work/minecraft/net/minecraft/village/Village.java
@@ -37,7 +37,7 @@
private int field_75581_g;
private int field_75588_h;
private int field_82694_i;
- private final Map<String, Integer> field_82693_j = Maps.<String, Integer>newHashMap();
+ private final Map<UUID, Integer> field_82693_j = Maps.<UUID, Integer>newHashMap();
private final List<Village.VillageAggressor> field_75589_i = Lists.<Village.VillageAggressor>newArrayList();
private int field_75587_j;
@@ -310,11 +310,11 @@
double d0 = Double.MAX_VALUE;
EntityPlayer entityplayer = null;
- for (String s : this.field_82693_j.keySet())
+ for (UUID s : this.field_82693_j.keySet())
{
- if (this.func_82687_d(s))
+ if (this.isPlayerReputationTooLow(s))
{
- EntityPlayer entityplayer1 = this.field_75586_a.func_72924_a(s);
+ EntityPlayer entityplayer1 = this.field_75586_a.func_152378_a(s);
if (entityplayer1 != null)
{
@@ -407,25 +407,51 @@
}
}
+ @Deprecated //Hasn't worked since 1.9, use UUID version below.
public int func_82684_a(String p_82684_1_)
{
+ return this.getPlayerReputation(findUUID(p_82684_1_));
+ }
+
+ public int getPlayerReputation(UUID p_82684_1_)
+ {
Integer integer = (Integer)this.field_82693_j.get(p_82684_1_);
return integer == null ? 0 : integer.intValue();
}
+ private UUID findUUID(String name)
+ {
+ if (this.field_75586_a == null || this.field_75586_a.func_73046_m() == null)
+ return EntityPlayer.func_175147_b(name);
+ GameProfile profile = this.field_75586_a.func_73046_m().func_152358_ax().func_152655_a(name);
+ return profile == null ? EntityPlayer.func_175147_b(name) : profile.getId();
+ }
+
+ @Deprecated //Hasn't worked since 1.9, use UUID version below.
public int func_82688_a(String p_82688_1_, int p_82688_2_)
{
- int i = this.func_82684_a(p_82688_1_);
+ return this.modifyPlayerReputation(findUUID(p_82688_1_), p_82688_2_);
+ }
+
+ public int modifyPlayerReputation(UUID p_82688_1_, int p_82688_2_)
+ {
+ int i = this.getPlayerReputation(p_82688_1_);
int j = MathHelper.func_76125_a(i + p_82688_2_, -30, 10);
this.field_82693_j.put(p_82688_1_, Integer.valueOf(j));
return j;
}
+ @Deprecated //Hasn't worked since 1.9, use UUID version below.
public boolean func_82687_d(String p_82687_1_)
{
- return this.func_82684_a(p_82687_1_) <= -15;
+ return this.isPlayerReputationTooLow(findUUID(p_82687_1_));
}
+ public boolean isPlayerReputationTooLow(UUID uuid)
+ {
+ return this.getPlayerReputation(uuid) <= -15;
+ }
+
public void func_82690_a(NBTTagCompound p_82690_1_)
{
this.field_75588_h = p_82690_1_.func_74762_e("PopSize");
@@ -451,19 +477,14 @@
{
NBTTagCompound nbttagcompound1 = nbttaglist1.func_150305_b(j);
- if (nbttagcompound1.func_74764_b("UUID") && this.field_75586_a != null && this.field_75586_a.func_73046_m() != null)
+ if (nbttagcompound1.func_74764_b("UUID"))
{
- PlayerProfileCache playerprofilecache = this.field_75586_a.func_73046_m().func_152358_ax();
- GameProfile gameprofile = playerprofilecache.func_152652_a(UUID.fromString(nbttagcompound1.func_74779_i("UUID")));
-
- if (gameprofile != null)
- {
- this.field_82693_j.put(gameprofile.getName(), Integer.valueOf(nbttagcompound1.func_74762_e("S")));
- }
+ this.field_82693_j.put(UUID.fromString(nbttagcompound1.func_74779_i("UUID")), Integer.valueOf(nbttagcompound1.func_74762_e("S")));
}
else
{
- this.field_82693_j.put(nbttagcompound1.func_74779_i("Name"), Integer.valueOf(nbttagcompound1.func_74762_e("S")));
+ //World is never set here, so this will always be offline UUIDs, sadly there is no way to convert this.
+ this.field_82693_j.put(findUUID(nbttagcompound1.func_74779_i("Name")), Integer.valueOf(nbttagcompound1.func_74762_e("S")));
}
}
}
@@ -499,18 +520,14 @@
p_82689_1_.func_74782_a("Doors", nbttaglist);
NBTTagList nbttaglist1 = new NBTTagList();
- for (String s : this.field_82693_j.keySet())
+ for (UUID s : this.field_82693_j.keySet())
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
- PlayerProfileCache playerprofilecache = this.field_75586_a.func_73046_m().func_152358_ax();
try
{
- GameProfile gameprofile = playerprofilecache.func_152655_a(s);
-
- if (gameprofile != null)
{
- nbttagcompound1.func_74778_a("UUID", gameprofile.getId().toString());
+ nbttagcompound1.func_74778_a("UUID", s.toString());
nbttagcompound1.func_74768_a("S", ((Integer)this.field_82693_j.get(s)).intValue());
nbttaglist1.func_74742_a(nbttagcompound1);
}
@@ -536,9 +553,9 @@
public void func_82683_b(int p_82683_1_)
{
- for (String s : this.field_82693_j.keySet())
+ for (UUID s : this.field_82693_j.keySet())
{
- this.func_82688_a(s, p_82683_1_);
+ this.modifyPlayerReputation(s, p_82683_1_);
}
}

View File

@ -56,4 +56,6 @@ net/minecraft/world/storage/loot/LootEntryItem.<init>(Lnet/minecraft/item/Item;I
net/minecraft/world/storage/loot/LootEntryTable.<init>(Lnet/minecraft/util/ResourceLocation;II[Lnet/minecraft/world/storage/loot/conditions/LootCondition;Ljava/lang/String;)V=|p_i46639_1_,p_i46639_2_,p_i46639_3_,p_i46639_4_,entryName
net/minecraft/world/storage/loot/LootEntryEmpty.<init>(II[Lnet/minecraft/world/storage/loot/conditions/LootCondition;Ljava/lang/String;)V=|p_i46645_1_,p_i46645_2_,p_i46645_3_,entryName
net/minecraft/world/chunk/BlockStateContainer.setBits(IZ)V=|p_186012_1_,forceBits
net/minecraft/world/chunk/BlockStateContainer.setBits(IZ)V=|p_186012_1_,forceBits
net/minecraft/village/Village.getPlayerReputation(Ljava/util/UUID;)I=|p_82684_1_
net/minecraft/village/Village.modifyPlayerReputation(Ljava/util/UUID;I)I=|p_82688_1_,p_82688_2_