Skip to content

Commit

Permalink
First pass at exposing data fixers to modders.
Browse files Browse the repository at this point in the history
Each mod gets its own version number, mods SHOULD NOT rely on other
mod's fixers, just care about yourself.
Walkers can use IDataFixerData to retrieve their version.
  • Loading branch information
LexManos committed Nov 29, 2016
1 parent c17b407 commit 8d20258
Show file tree
Hide file tree
Showing 13 changed files with 390 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@
this.field_71100_bB.func_75112_a(p_70037_1_);
this.field_71075_bZ.func_75095_b(p_70037_1_);

@@ -921,6 +965,23 @@
@@ -903,6 +947,7 @@
{
super.func_70014_b(p_70014_1_);
p_70014_1_.func_74768_a("DataVersion", 819);
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().getDataFixer().writeVersionData(p_70014_1_);
p_70014_1_.func_74782_a("Inventory", this.field_71071_by.func_70442_a(new NBTTagList()));
p_70014_1_.func_74768_a("SelectedItemSlot", this.field_71071_by.field_70461_c);
p_70014_1_.func_74757_a("Sleeping", this.field_71083_bS);
@@ -921,6 +966,23 @@
p_70014_1_.func_74757_a("SpawnForced", this.field_82248_d);
}

Expand All @@ -176,23 +184,23 @@
this.field_71100_bB.func_75117_b(p_70014_1_);
this.field_71075_bZ.func_75091_a(p_70014_1_);
p_70014_1_.func_74782_a("EnderItems", this.field_71078_a.func_70487_g());
@@ -928,6 +989,7 @@
@@ -928,6 +990,7 @@

public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_)
{
+ if (!net.minecraftforge.common.ForgeHooks.onLivingAttack(this, p_70097_1_, p_70097_2_)) return false;
if (this.func_180431_b(p_70097_1_))
{
return false;
@@ -1006,6 +1068,7 @@
@@ -1006,6 +1069,7 @@
if (this.field_184627_bm.func_190926_b())
{
EnumHand enumhand = this.func_184600_cs();
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, this.field_184627_bm, enumhand);

if (enumhand == EnumHand.MAIN_HAND)
{
@@ -1041,7 +1104,10 @@
@@ -1041,7 +1105,10 @@
{
if (!this.func_180431_b(p_70665_1_))
{
Expand All @@ -204,15 +212,15 @@
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);
@@ -1111,6 +1177,7 @@
@@ -1111,6 +1178,7 @@
}
else
{
+ if (net.minecraftforge.common.ForgeHooks.onInteractEntity(this, p_190775_1_, p_190775_2_)) return EnumActionResult.PASS;
ItemStack itemstack = this.func_184586_b(p_190775_2_);
ItemStack itemstack1 = itemstack.func_190926_b() ? ItemStack.field_190927_a : itemstack.func_77946_l();

@@ -1120,7 +1187,10 @@
@@ -1120,7 +1188,10 @@
{
itemstack.func_190920_e(itemstack1.func_190916_E());
}
Expand All @@ -224,23 +232,23 @@
return EnumActionResult.SUCCESS;
}
else
@@ -1136,6 +1206,7 @@
@@ -1136,6 +1207,7 @@
{
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);
}

@@ -1161,6 +1232,7 @@
@@ -1161,6 +1233,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))
@@ -1331,11 +1403,13 @@
@@ -1331,11 +1404,13 @@

if (!itemstack1.func_190926_b() && entity instanceof EntityLivingBase)
{
Expand All @@ -254,7 +262,7 @@
}
}

@@ -1441,6 +1515,8 @@
@@ -1441,6 +1516,8 @@

public EntityPlayer.SleepResult func_180469_a(BlockPos p_180469_1_)
{
Expand All @@ -263,7 +271,7 @@
EnumFacing enumfacing = (EnumFacing)this.field_70170_p.func_180495_p(p_180469_1_).func_177229_b(BlockHorizontal.field_185512_D);

if (!this.field_70170_p.field_72995_K)
@@ -1482,8 +1558,9 @@
@@ -1482,8 +1559,9 @@

this.func_70105_a(0.2F, 0.2F);

Expand All @@ -275,7 +283,7 @@
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);
@@ -1530,13 +1607,14 @@
@@ -1530,13 +1608,14 @@

public void func_70999_a(boolean p_70999_1_, boolean p_70999_2_, boolean p_70999_3_)
{
Expand All @@ -293,7 +301,7 @@

if (blockpos == null)
{
@@ -1545,6 +1623,10 @@
@@ -1545,6 +1624,10 @@

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));
}
Expand All @@ -304,7 +312,7 @@

this.field_71083_bS = false;

@@ -1563,15 +1645,16 @@
@@ -1563,15 +1646,16 @@

private boolean func_175143_p()
{
Expand All @@ -324,7 +332,7 @@
{
if (!p_180467_2_)
{
@@ -1586,16 +1669,17 @@
@@ -1586,16 +1670,17 @@
}
else
{
Expand All @@ -345,7 +353,7 @@

switch (enumfacing)
{
@@ -1635,16 +1719,24 @@
@@ -1635,16 +1720,24 @@

public BlockPos func_180470_cg()
{
Expand All @@ -372,7 +380,7 @@
if (p_180473_1_ != null)
{
this.field_71077_c = p_180473_1_;
@@ -1839,6 +1931,10 @@
@@ -1839,6 +1932,10 @@

super.func_180430_e(p_180430_1_, p_180430_2_);
}
Expand All @@ -383,7 +391,7 @@
}

protected void func_71061_d_()
@@ -2039,6 +2135,18 @@
@@ -2039,6 +2136,18 @@
this.field_175152_f = p_71049_1_.field_175152_f;
this.field_71078_a = p_71049_1_.field_71078_a;
this.func_184212_Q().func_187227_b(field_184827_bp, p_71049_1_.func_184212_Q().func_187225_a(field_184827_bp));
Expand All @@ -402,7 +410,7 @@
}

protected boolean func_70041_e_()
@@ -2137,7 +2245,10 @@
@@ -2137,7 +2246,10 @@

public ITextComponent func_145748_c_()
{
Expand All @@ -414,7 +422,7 @@
itextcomponent.func_150256_b().func_150241_a(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.func_70005_c_() + " "));
itextcomponent.func_150256_b().func_150209_a(this.func_174823_aP());
itextcomponent.func_150256_b().func_179989_a(this.func_70005_c_());
@@ -2146,7 +2257,7 @@
@@ -2146,7 +2258,7 @@

public float func_70047_e()
{
Expand All @@ -423,7 +431,7 @@

if (this.func_70608_bn())
{
@@ -2362,6 +2473,162 @@
@@ -2362,6 +2474,162 @@
return this.field_71075_bZ.field_75098_d && this.func_70003_b(2, "");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- ../src-base/minecraft/net/minecraft/util/datafix/DataFixesManager.java
+++ ../src-work/minecraft/net/minecraft/util/datafix/DataFixesManager.java
@@ -158,6 +158,7 @@
public static DataFixer func_188279_a()
{
DataFixer datafixer = new DataFixer(819);
+ datafixer = new net.minecraftforge.common.util.CompoundDataFixer(datafixer);
WorldInfo.func_189967_a(datafixer);
EntityPlayer.func_189806_a(datafixer);
AnvilChunkLoader.func_189889_a(datafixer);
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@
}
}
}
@@ -122,6 +181,7 @@
@@ -121,7 +180,9 @@
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound.func_74782_a("Level", nbttagcompound1);
nbttagcompound.func_74768_a("DataVersion", 819);
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().getDataFixer().writeVersionData(nbttagcompound);
this.func_75820_a(p_75816_2_, p_75816_1_, nbttagcompound1);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Save(p_75816_2_, nbttagcompound));
this.func_75824_a(p_75816_2_.func_76632_l(), nbttagcompound);
}
catch (Exception exception)
@@ -307,8 +367,17 @@
@@ -307,8 +368,17 @@

if (entity.func_70039_c(nbttagcompound2))
{
Expand All @@ -123,7 +125,7 @@
}
}
}
@@ -318,8 +387,17 @@
@@ -318,8 +388,17 @@

for (TileEntity tileentity : p_75820_1_.func_177434_r().values())
{
Expand All @@ -141,7 +143,7 @@
}

p_75820_3_.func_74782_a("TileEntities", nbttaglist2);
@@ -388,6 +466,12 @@
@@ -388,6 +467,12 @@
chunk.func_76616_a(p_75823_2_.func_74770_j("Biomes"));
}

Expand All @@ -154,7 +156,7 @@
NBTTagList nbttaglist1 = p_75823_2_.func_150295_c("Entities", 10);

for (int j1 = 0; j1 < nbttaglist1.func_74745_c(); ++j1)
@@ -431,8 +515,6 @@
@@ -431,8 +516,6 @@
p_75823_1_.func_180497_b(new BlockPos(nbttagcompound3.func_74762_e("x"), nbttagcompound3.func_74762_e("y"), nbttagcompound3.func_74762_e("z")), block, nbttagcompound3.func_74762_e("t"), nbttagcompound3.func_74762_e("p"));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- ../src-base/minecraft/net/minecraft/world/gen/structure/template/Template.java
+++ ../src-work/minecraft/net/minecraft/world/gen/structure/template/Template.java
@@ -520,6 +520,7 @@
p_189552_1_.func_74782_a("size", this.func_186267_a(new int[] {this.field_186272_c.func_177958_n(), this.field_186272_c.func_177956_o(), this.field_186272_c.func_177952_p()}));
p_189552_1_.func_74778_a("author", this.field_186273_d);
p_189552_1_.func_74768_a("DataVersion", 819);
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().getDataFixer().writeVersionData(p_189552_1_);
return p_189552_1_;
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@

protected WorldInfo()
{
@@ -807,6 +808,26 @@
@@ -335,6 +336,7 @@
nbttagcompound.func_74757_a("Snapshot", false);
p_76064_1_.func_74782_a("Version", nbttagcompound);
p_76064_1_.func_74768_a("DataVersion", 819);
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().getDataFixer().writeVersionData(p_76064_1_);
p_76064_1_.func_74772_a("RandomSeed", this.field_76100_a);
p_76064_1_.func_74778_a("generatorName", this.field_76098_b.func_77127_a());
p_76064_1_.func_74768_a("generatorVersion", this.field_76098_b.func_77131_c());
@@ -807,6 +809,26 @@
});
}

Expand Down
Loading

0 comments on commit 8d20258

Please sign in to comment.