ForgePatch/patches/minecraft/net/minecraft/tileentity/AbstractFurnaceTileEntity.j...

127 lines
5.9 KiB
Diff

--- a/net/minecraft/tileentity/AbstractFurnaceTileEntity.java
+++ b/net/minecraft/tileentity/AbstractFurnaceTileEntity.java
@@ -91,6 +91,7 @@
this.field_214014_c = p_i49964_2_;
}
+ @Deprecated //Forge - get burn times by calling ForgeHooks#getBurnTime(ItemStack)
public static Map<Item, Integer> func_214001_f() {
Map<Item, Integer> map = Maps.newLinkedHashMap();
func_213996_a(map, Items.field_151129_at, 20000);
@@ -184,13 +185,13 @@
return this.field_214018_j > 0;
}
- public void func_230337_a_(BlockState p_230337_1_, CompoundNBT p_230337_2_) {
+ public void func_230337_a_(BlockState p_230337_1_, CompoundNBT p_230337_2_) { //TODO: MARK
super.func_230337_a_(p_230337_1_, p_230337_2_);
this.field_214012_a = NonNullList.func_191197_a(this.func_70302_i_(), ItemStack.field_190927_a);
ItemStackHelper.func_191283_b(p_230337_2_, this.field_214012_a);
- this.field_214018_j = p_230337_2_.func_74765_d("BurnTime");
- this.field_214020_l = p_230337_2_.func_74765_d("CookTime");
- this.field_214021_m = p_230337_2_.func_74765_d("CookTimeTotal");
+ this.field_214018_j = p_230337_2_.func_74762_e("BurnTime");
+ this.field_214020_l = p_230337_2_.func_74762_e("CookTime");
+ this.field_214021_m = p_230337_2_.func_74762_e("CookTimeTotal");
this.field_214019_k = this.func_213997_a(this.field_214012_a.get(1));
CompoundNBT compoundnbt = p_230337_2_.func_74775_l("RecipesUsed");
@@ -202,9 +203,9 @@
public CompoundNBT func_189515_b(CompoundNBT p_189515_1_) {
super.func_189515_b(p_189515_1_);
- p_189515_1_.func_74777_a("BurnTime", (short)this.field_214018_j);
- p_189515_1_.func_74777_a("CookTime", (short)this.field_214020_l);
- p_189515_1_.func_74777_a("CookTimeTotal", (short)this.field_214021_m);
+ p_189515_1_.func_74768_a("BurnTime", this.field_214018_j);
+ p_189515_1_.func_74768_a("CookTime", this.field_214020_l);
+ p_189515_1_.func_74768_a("CookTimeTotal", this.field_214021_m);
ItemStackHelper.func_191282_a(p_189515_1_, this.field_214012_a);
CompoundNBT compoundnbt = new CompoundNBT();
this.field_214022_n.forEach((p_235643_1_, p_235643_2_) -> {
@@ -230,12 +231,14 @@
this.field_214019_k = this.field_214018_j;
if (this.func_214006_r()) {
flag1 = true;
+ if (itemstack.hasContainerItem())
+ this.field_214012_a.set(1, itemstack.getContainerItem());
+ else
if (!itemstack.func_190926_b()) {
Item item = itemstack.func_77973_b();
itemstack.func_190918_g(1);
if (itemstack.func_190926_b()) {
- Item item1 = item.func_77668_q();
- this.field_214012_a.set(1, item1 == null ? ItemStack.field_190927_a : new ItemStack(item1));
+ this.field_214012_a.set(1, itemstack.getContainerItem());
}
}
}
@@ -279,10 +282,10 @@
return true;
} else if (!itemstack1.func_77969_a(itemstack)) {
return false;
- } else if (itemstack1.func_190916_E() < this.func_70297_j_() && itemstack1.func_190916_E() < itemstack1.func_77976_d()) {
+ } else if (itemstack1.func_190916_E() + itemstack.func_190916_E() <= this.func_70297_j_() && itemstack1.func_190916_E() + itemstack.func_190916_E() <= itemstack1.func_77976_d()) { // Forge fix: make furnace respect stack sizes in furnace recipes
return true;
} else {
- return itemstack1.func_190916_E() < itemstack.func_77976_d();
+ return itemstack1.func_190916_E() + itemstack.func_190916_E() <= itemstack.func_77976_d(); // Forge fix: make furnace respect stack sizes in furnace recipes
}
}
} else {
@@ -298,7 +301,7 @@
if (itemstack2.func_190926_b()) {
this.field_214012_a.set(2, itemstack1.func_77946_l());
} else if (itemstack2.func_77973_b() == itemstack1.func_77973_b()) {
- itemstack2.func_190917_f(1);
+ itemstack2.func_190917_f(itemstack1.func_190916_E());
}
if (!this.field_145850_b.field_72995_K) {
@@ -318,7 +321,7 @@
return 0;
} else {
Item item = p_213997_1_.func_77973_b();
- return func_214001_f().getOrDefault(item, 0);
+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_213997_1_);
}
}
@@ -327,7 +330,7 @@
}
public static boolean func_213991_b(ItemStack p_213991_0_) {
- return func_214001_f().containsKey(p_213991_0_.func_77973_b());
+ return net.minecraftforge.common.ForgeHooks.getBurnTime(p_213991_0_) > 0;
}
public int[] func_180463_a(Direction p_180463_1_) {
@@ -474,4 +477,27 @@
}
}
+
+ net.minecraftforge.common.util.LazyOptional<? extends net.minecraftforge.items.IItemHandler>[] handlers =
+ net.minecraftforge.items.wrapper.SidedInvWrapper.create(this, Direction.UP, Direction.DOWN, Direction.NORTH);
+
+ @Override
+ public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable Direction facing) {
+ if (!this.field_145846_f && facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
+ if (facing == Direction.UP)
+ return handlers[0].cast();
+ else if (facing == Direction.DOWN)
+ return handlers[1].cast();
+ else
+ return handlers[2].cast();
+ }
+ return super.getCapability(capability, facing);
+ }
+
+ @Override
+ protected void invalidateCaps() {
+ super.invalidateCaps();
+ for (int x = 0; x < handlers.length; x++)
+ handlers[x].invalidate();
+ }
}