mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
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:
1 parent
006b8cc8bd
commit
72937c90be
4 files changed
+204
-16
No files matched your search
@@ -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_);
|
||||
@@ -1,14 +1,24 @@
|
||||
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityVillager.java
|
||||
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityVillager.java
|
||||
@@ -111,6 +111,7 @@
|
||||
@@ -105,7 +105,7 @@
|
||||
private boolean field_70959_by;
|
||||
private boolean field_175565_bs;
|
||||
private int field_70956_bz;
|
||||
- private String field_82189_bL;
|
||||
+ private java.util.UUID field_82189_bL;
|
||||
private int field_175563_bv;
|
||||
private int field_175562_bw;
|
||||
private boolean field_82190_bM;
|
||||
private boolean field_175564_by;
|
||||
private final InventoryBasic field_175560_bz;
|
||||
+ @Deprecated //Use VillagerRegistry
|
||||
private static final EntityVillager.ITradeList[][][][] field_175561_bA = new EntityVillager.ITradeList[][][][] {{{{new EntityVillager.EmeraldForItems(Items.field_151015_O, new EntityVillager.PriceInfo(18, 22)), new EntityVillager.EmeraldForItems(Items.field_151174_bG, new EntityVillager.PriceInfo(15, 19)), new EntityVillager.EmeraldForItems(Items.field_151172_bF, new EntityVillager.PriceInfo(15, 19)), new EntityVillager.ListItemForEmeralds(Items.field_151025_P, new EntityVillager.PriceInfo(-4, -2))}, {new EntityVillager.EmeraldForItems(Item.func_150898_a(Blocks.field_150423_aK), new EntityVillager.PriceInfo(8, 13)), new EntityVillager.ListItemForEmeralds(Items.field_151158_bO, new EntityVillager.PriceInfo(-3, -2))}, {new EntityVillager.EmeraldForItems(Item.func_150898_a(Blocks.field_150440_ba), new EntityVillager.PriceInfo(7, 12)), new EntityVillager.ListItemForEmeralds(Items.field_151034_e, new EntityVillager.PriceInfo(-7, -5))}, {new EntityVillager.ListItemForEmeralds(Items.field_151106_aX, new EntityVillager.PriceInfo(-10, -6)), new EntityVillager.ListItemForEmeralds(Items.field_151105_aU, new EntityVillager.PriceInfo(1, 1))}}, {{new EntityVillager.EmeraldForItems(Items.field_151007_F, new EntityVillager.PriceInfo(15, 20)), new EntityVillager.EmeraldForItems(Items.field_151044_h, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ItemAndEmeraldToItem(Items.field_151115_aP, new EntityVillager.PriceInfo(6, 6), Items.field_179566_aV, new EntityVillager.PriceInfo(6, 6))}, {new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151112_aM, new EntityVillager.PriceInfo(7, 8))}}, {{new EntityVillager.EmeraldForItems(Item.func_150898_a(Blocks.field_150325_L), new EntityVillager.PriceInfo(16, 22)), new EntityVillager.ListItemForEmeralds(Items.field_151097_aZ, new EntityVillager.PriceInfo(3, 4))}, {new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L)), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 1), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 2), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 3), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 4), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 5), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 6), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 7), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 8), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 9), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 10), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 11), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 12), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 13), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 14), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 15), new EntityVillager.PriceInfo(1, 2))}}, {{new EntityVillager.EmeraldForItems(Items.field_151007_F, new EntityVillager.PriceInfo(15, 20)), new EntityVillager.ListItemForEmeralds(Items.field_151032_g, new EntityVillager.PriceInfo(-12, -8))}, {new EntityVillager.ListItemForEmeralds(Items.field_151031_f, new EntityVillager.PriceInfo(2, 3)), new EntityVillager.ItemAndEmeraldToItem(Item.func_150898_a(Blocks.field_150351_n), new EntityVillager.PriceInfo(10, 10), Items.field_151145_ak, new EntityVillager.PriceInfo(6, 10))}}}, {{{new EntityVillager.EmeraldForItems(Items.field_151121_aF, new EntityVillager.PriceInfo(24, 36)), new EntityVillager.ListEnchantedBookForEmeralds()}, {new EntityVillager.EmeraldForItems(Items.field_151122_aG, new EntityVillager.PriceInfo(8, 10)), new EntityVillager.ListItemForEmeralds(Items.field_151111_aL, new EntityVillager.PriceInfo(10, 12)), new EntityVillager.ListItemForEmeralds(Item.func_150898_a(Blocks.field_150342_X), ne
Line truncated
|
||||
@@ -230,7 +230,7 @@
|
||||
if (this.field_70954_d != null && this.field_82189_bL != null)
|
||||
{
|
||||
this.field_70170_p.func_72960_a(this, (byte)14);
|
||||
- this.field_70954_d.func_82688_a(this.field_82189_bL, 1);
|
||||
+ this.field_70954_d.modifyPlayerReputation(this.field_82189_bL, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public EntityVillager(World p_i1747_1_)
|
||||
@@ -323,6 +324,7 @@
|
||||
@@ -323,6 +323,7 @@
|
||||
{
|
||||
super.func_70014_b(p_70014_1_);
|
||||
p_70014_1_.func_74768_a("Profession", this.func_70946_n());
|
||||
@@ -16,7 +26,7 @@
|
||||
p_70014_1_.func_74768_a("Riches", this.field_70956_bz);
|
||||
p_70014_1_.func_74768_a("Career", this.field_175563_bv);
|
||||
p_70014_1_.func_74768_a("CareerLevel", this.field_175562_bw);
|
||||
@@ -352,6 +354,14 @@
|
||||
@@ -352,6 +353,14 @@
|
||||
{
|
||||
super.func_70037_a(p_70037_1_);
|
||||
this.func_70938_b(p_70037_1_.func_74762_e("Profession"));
|
||||
@@ -31,7 +41,7 @@
|
||||
this.field_70956_bz = p_70037_1_.func_74762_e("Riches");
|
||||
this.field_175563_bv = p_70037_1_.func_74762_e("Career");
|
||||
this.field_175562_bw = p_70037_1_.func_74762_e("CareerLevel");
|
||||
@@ -408,13 +418,43 @@
|
||||
@@ -408,13 +417,43 @@
|
||||
public void func_70938_b(int p_70938_1_)
|
||||
{
|
||||
this.field_70180_af.func_187227_b(field_184752_bw, Integer.valueOf(p_70938_1_));
|
||||
@@ -75,7 +85,34 @@
|
||||
public boolean func_70941_o()
|
||||
{
|
||||
return this.field_70952_f;
|
||||
@@ -607,15 +647,13 @@
|
||||
@@ -452,7 +491,7 @@
|
||||
i = -3;
|
||||
}
|
||||
|
||||
- this.field_70954_d.func_82688_a(p_70604_1_.func_70005_c_(), i);
|
||||
+ this.field_70954_d.modifyPlayerReputation(p_70604_1_.func_110124_au(), i);
|
||||
|
||||
if (this.func_70089_S())
|
||||
{
|
||||
@@ -472,7 +511,7 @@
|
||||
{
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
- this.field_70954_d.func_82688_a(entity.func_70005_c_(), -2);
|
||||
+ this.field_70954_d.modifyPlayerReputation(entity.func_110124_au(), -2);
|
||||
}
|
||||
else if (entity instanceof IMob)
|
||||
{
|
||||
@@ -564,7 +603,7 @@
|
||||
|
||||
if (this.field_70962_h != null)
|
||||
{
|
||||
- this.field_82189_bL = this.field_70962_h.func_70005_c_();
|
||||
+ this.field_82189_bL = this.field_70962_h.func_110124_au();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -607,15 +646,13 @@
|
||||
|
||||
private void func_175554_cu()
|
||||
{
|
||||
@@ -92,7 +129,7 @@
|
||||
this.field_175562_bw = 1;
|
||||
}
|
||||
|
||||
@@ -626,19 +664,13 @@
|
||||
@@ -626,19 +663,13 @@
|
||||
|
||||
int i = this.field_175563_bv - 1;
|
||||
int j = this.field_175562_bw - 1;
|
||||
@@ -116,7 +153,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -748,7 +780,7 @@
|
||||
@@ -748,7 +779,7 @@
|
||||
s1 = "nitwit";
|
||||
}
|
||||
|
||||
@@ -125,7 +162,7 @@
|
||||
{
|
||||
ITextComponent itextcomponent = new TextComponentTranslation("entity.Villager." + s1, new Object[0]);
|
||||
itextcomponent.func_150256_b().func_150209_a(this.func_174823_aP());
|
||||
@@ -761,10 +793,6 @@
|
||||
@@ -761,10 +792,6 @@
|
||||
|
||||
return itextcomponent;
|
||||
}
|
||||
@@ -136,7 +173,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,7 +846,7 @@
|
||||
@@ -818,7 +845,7 @@
|
||||
|
||||
if (p_190672_3_)
|
||||
{
|
||||
@@ -145,11 +182,12 @@
|
||||
}
|
||||
|
||||
this.func_175552_ct();
|
||||
@@ -1071,6 +1099,8 @@
|
||||
@@ -1071,6 +1098,9 @@
|
||||
p_190888_2_.add(new MerchantRecipe(itemstack, itemstack1));
|
||||
}
|
||||
}
|
||||
+ //MODDERS DO NOT USE OR EDIT THIS IN ANY WAY IT WILL HAVE NO EFFECT, THIS IS JUST IN HERE TO ALLOW FORGE TO ACCESS IT
|
||||
+ @Deprecated
|
||||
+ public static ITradeList[][][][] GET_TRADES_DONT_USE(){ return field_175561_bA; }
|
||||
|
||||
public static class ListItemForEmeralds implements EntityVillager.ITradeList
|
||||
|
||||
@@ -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_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_
|
||||
Reference in new issue
Block a user