ForgePatch/patches/minecraft/net/minecraft/inventory/container/EnchantmentContainer.java.patch
2019-06-07 16:50:47 -04:00

90 lines
4.8 KiB
Diff

--- a/net/minecraft/inventory/container/EnchantmentContainer.java
+++ b/net/minecraft/inventory/container/EnchantmentContainer.java
@@ -55,7 +55,7 @@
});
this.func_75146_a(new Slot(this.field_75168_e, 1, 35, 47) {
public boolean func_75214_a(ItemStack p_75214_1_) {
- return p_75214_1_.func_77973_b() == Items.field_196128_bn;
+ return net.minecraftforge.common.Tags.Items.GEMS_LAPIS.func_199685_a_(p_75214_1_.func_77973_b());
}
});
@@ -81,40 +81,28 @@
this.func_216958_a(IntReferenceHolder.func_221497_a(this.field_185002_i, 2));
}
+ private float getPower(net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos) {
+ return world.func_180495_p(pos).getEnchantPowerBonus(world, pos);
+ }
+
public void func_75130_a(IInventory p_75130_1_) {
if (p_75130_1_ == this.field_75168_e) {
ItemStack itemstack = p_75130_1_.func_70301_a(0);
if (!itemstack.func_190926_b() && itemstack.func_77956_u()) {
this.field_217006_g.func_221486_a((p_217002_2_, p_217002_3_) -> {
- int j = 0;
+ float power = 0;
for(int k = -1; k <= 1; ++k) {
for(int l = -1; l <= 1; ++l) {
if ((k != 0 || l != 0) && p_217002_2_.func_175623_d(p_217002_3_.func_177982_a(l, 0, k)) && p_217002_2_.func_175623_d(p_217002_3_.func_177982_a(l, 1, k))) {
- if (p_217002_2_.func_180495_p(p_217002_3_.func_177982_a(l * 2, 0, k * 2)).func_177230_c() == Blocks.field_150342_X) {
- ++j;
- }
+ power += getPower(p_217002_2_, p_217002_3_.func_177982_a(l * 2, 0, k * 2));
+ power += getPower(p_217002_2_, p_217002_3_.func_177982_a(l * 2, 1, k * 2));
- if (p_217002_2_.func_180495_p(p_217002_3_.func_177982_a(l * 2, 1, k * 2)).func_177230_c() == Blocks.field_150342_X) {
- ++j;
- }
-
if (l != 0 && k != 0) {
- if (p_217002_2_.func_180495_p(p_217002_3_.func_177982_a(l * 2, 0, k)).func_177230_c() == Blocks.field_150342_X) {
- ++j;
- }
-
- if (p_217002_2_.func_180495_p(p_217002_3_.func_177982_a(l * 2, 1, k)).func_177230_c() == Blocks.field_150342_X) {
- ++j;
- }
-
- if (p_217002_2_.func_180495_p(p_217002_3_.func_177982_a(l, 0, k * 2)).func_177230_c() == Blocks.field_150342_X) {
- ++j;
- }
-
- if (p_217002_2_.func_180495_p(p_217002_3_.func_177982_a(l, 1, k * 2)).func_177230_c() == Blocks.field_150342_X) {
- ++j;
- }
+ power += getPower(p_217002_2_, p_217002_3_.func_177982_a(l * 2, 0, k));
+ power += getPower(p_217002_2_, p_217002_3_.func_177982_a(l * 2, 1, k));
+ power += getPower(p_217002_2_, p_217002_3_.func_177982_a(l, 0, k * 2));
+ power += getPower(p_217002_2_, p_217002_3_.func_177982_a(l, 1, k * 2));
}
}
}
@@ -123,12 +111,13 @@
this.field_75169_l.setSeed((long)this.field_178149_f.func_221495_b());
for(int i1 = 0; i1 < 3; ++i1) {
- this.field_75167_g[i1] = EnchantmentHelper.func_77514_a(this.field_75169_l, i1, j, itemstack);
+ this.field_75167_g[i1] = EnchantmentHelper.func_77514_a(this.field_75169_l, i1, (int)power, itemstack);
this.field_185001_h[i1] = -1;
this.field_185002_i[i1] = -1;
if (this.field_75167_g[i1] < i1 + 1) {
this.field_75167_g[i1] = 0;
}
+ this.field_75167_g[i1] = net.minecraftforge.event.ForgeEventFactory.onEnchantmentLevelSet(p_217002_2_, p_217002_3_, i1, (int)power, itemstack, field_75167_g[i1]);
}
for(int j1 = 0; j1 < 3; ++j1) {
@@ -262,9 +251,8 @@
return ItemStack.field_190927_a;
}
- if (itemstack1.func_77942_o() && itemstack1.func_190916_E() == 1) {
- this.field_75151_b.get(0).func_75215_d(itemstack1.func_77946_l());
- itemstack1.func_190920_e(0);
+ if (itemstack1.func_77942_o()) { // Forge: Fix MC-17431
+ ((Slot)this.field_75151_b.get(0)).func_75215_d(itemstack1.func_77979_a(1));
} else if (!itemstack1.func_190926_b()) {
this.field_75151_b.get(0).func_75215_d(new ItemStack(itemstack1.func_77973_b()));
itemstack1.func_190918_g(1);