Skip to content
25 changes: 25 additions & 0 deletions patches/minecraft/net/minecraft/block/BlockFurnace.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--- before/net/minecraft/block/BlockFurnace.java
+++ after/net/minecraft/block/BlockFurnace.java
@@ -246,6 +246,22 @@
{
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityFurnace)tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
+ if (!worldIn.isRemote)
+ {
+ float exp = ((com.cleanroommc.common.crafting.IFurnace) tileentity).extractExp();
Comment thread
gardenevery marked this conversation as resolved.
Outdated
+ int i = net.minecraft.util.math.MathHelper.floor(exp);
+ float decimal = exp - i;
+
+ if (decimal > 0.0F && worldIn.rand.nextFloat() < decimal)
+ {
+ i++;
+ }
+
+ if (i > 0)
+ {
+ worldIn.spawnEntity(new net.minecraft.entity.item.EntityXPOrb(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, i));
+ }
+ }
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
--- before/net/minecraft/inventory/SlotFurnaceOutput.java
+++ after/net/minecraft/inventory/SlotFurnaceOutput.java
@@ -94,5 +94,6 @@
@@ -57,7 +57,10 @@
if (!this.player.world.isRemote)
{
int i = this.removeCount;
- float f = FurnaceRecipes.instance().getSmeltingExperience(stack);
+ float f = 0.0F;
+ if (this.inventory instanceof com.cleanroommc.common.crafting.IFurnace) {
+ f = ((com.cleanroommc.common.crafting.IFurnace) this.inventory).extractExp();
+ }

if (f == 0.0F)
{
@@ -94,5 +97,6 @@
}

this.removeCount = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,64 @@
--- before/net/minecraft/item/crafting/FurnaceRecipes.java
+++ after/net/minecraft/item/crafting/FurnaceRecipes.java
@@ -121,6 +121,7 @@
@@ -111,31 +111,22 @@

public void addSmeltingRecipeForBlock(Block input, ItemStack stack, float experience)
{
- this.addSmelting(Item.getItemFromBlock(input), stack, experience);
+ com.cleanroommc.common.crafting.FurnaceRecipeManager.instance().registerRecipe(input, stack, experience);
}

public void addSmelting(Item input, ItemStack stack, float experience)
{
- this.addSmeltingRecipe(new ItemStack(input, 1, 32767), stack, experience);
+ com.cleanroommc.common.crafting.FurnaceRecipeManager.instance().registerRecipe(input, stack, experience);
}

public void addSmeltingRecipe(ItemStack input, ItemStack stack, float experience)
{
+ if (getSmeltingResult(input) != ItemStack.EMPTY) { net.minecraftforge.fml.common.FMLLog.log.info("Ignored smelting recipe with conflicting input: {} = {}", input, stack); return; }
this.smeltingList.put(input, stack);
this.experienceList.put(stack, experience);
- this.smeltingList.put(input, stack);
- this.experienceList.put(stack, experience);
+ com.cleanroommc.common.crafting.FurnaceRecipeManager.instance().registerRecipe(input, stack, experience);
}

public ItemStack getSmeltingResult(ItemStack stack)
{
- for (Entry<ItemStack, ItemStack> entry : this.smeltingList.entrySet())
- {
- if (this.compareItemStacks(stack, entry.getKey()))
- {
- return entry.getValue();
- }
- }
-
- return ItemStack.EMPTY;
+ return com.cleanroommc.common.crafting.FurnaceRecipeManager.instance().getOutput(stack);
}
@@ -151,6 +152,9 @@

private boolean compareItemStacks(ItemStack stack1, ItemStack stack2)
@@ -146,19 +137,15 @@

public Map<ItemStack, ItemStack> getSmeltingList()
{
- return this.smeltingList;
+ return com.cleanroommc.common.crafting.FurnaceRecipeManager.instance().getInputToOutputMap();
}

+ /**
+ * @deprecated Use {@link com.cleanroommc.common.crafting.FurnaceRecipeManager#getExperience(ItemStack)}
+ */
+ @Deprecated
public float getSmeltingExperience(ItemStack stack)
{
+ float ret = stack.getItem().getSmeltingExperience(stack);
+ if (ret != -1) return ret;
+
for (Entry<ItemStack, Float> entry : this.experienceList.entrySet())
{
if (this.compareItemStacks(stack, entry.getKey()))
- for (Entry<ItemStack, Float> entry : this.experienceList.entrySet())
- {
- if (this.compareItemStacks(stack, entry.getKey()))
- {
- return entry.getValue();
- }
- }
-
- return 0.0F;
+ return com.cleanroommc.common.crafting.FurnaceRecipeManager.instance().getExperienceFromOutput(stack);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
--- before/net/minecraft/tileentity/TileEntityFurnace.java
+++ after/net/minecraft/tileentity/TileEntityFurnace.java
@@ -130,9 +130,9 @@
@@ -32,7 +32,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

-public class TileEntityFurnace extends TileEntityLockable implements ITickable, ISidedInventory
+public class TileEntityFurnace extends TileEntityLockable implements ITickable, ISidedInventory, com.cleanroommc.common.crafting.IFurnace
{
private static final int[] SLOTS_TOP = new int[] {0};
private static final int[] SLOTS_BOTTOM = new int[] {2, 1};
@@ -43,6 +43,7 @@
private int cookTime;
private int totalCookTime;
private String furnaceCustomName;
+ private float storageExp;

@Override
public int getSizeInventory()
@@ -130,11 +131,11 @@
super.readFromNBT(compound);
this.furnaceItemStacks = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY);
ItemStackHelper.loadAllItems(compound, this.furnaceItemStacks);
Expand All @@ -11,22 +28,28 @@
+ this.cookTime = compound.getInteger("CookTime");
+ this.totalCookTime = compound.getInteger("CookTimeTotal");
this.currentItemBurnTime = getItemBurnTime(this.furnaceItemStacks.get(1));

-
+ this.storageExp = compound.getFloat("StorageExp");
if (compound.hasKey("CustomName", 8))
@@ -145,9 +145,9 @@
{
this.furnaceCustomName = compound.getString("CustomName");
@@ -145,11 +146,11 @@
public NBTTagCompound writeToNBT(NBTTagCompound compound)
{
super.writeToNBT(compound);
- compound.setShort("BurnTime", (short)this.furnaceBurnTime);
- compound.setShort("CookTime", (short)this.cookTime);
- compound.setShort("CookTimeTotal", (short)this.totalCookTime);
+ compound.setInteger("BurnTime", (short)this.furnaceBurnTime);
+ compound.setInteger("CookTime", (short)this.cookTime);
+ compound.setInteger("CookTimeTotal", (short)this.totalCookTime);
+ compound.setInteger("BurnTime", this.furnaceBurnTime);
+ compound.setInteger("CookTime", this.cookTime);
+ compound.setInteger("CookTimeTotal", this.totalCookTime);
ItemStackHelper.saveAllItems(compound, this.furnaceItemStacks);

-
+ compound.setFloat("StorageExp", this.storageExp);
if (this.hasCustomName())
@@ -208,8 +208,8 @@
{
compound.setString("CustomName", this.furnaceCustomName);
@@ -208,8 +209,8 @@

if (itemstack.isEmpty())
{
Expand All @@ -37,7 +60,31 @@
}
}
}
@@ -281,11 +281,13 @@
@@ -250,9 +251,22 @@
}
}

+ public void addExp(float experience)
+ {
+ this.storageExp += experience;
+ }
+
+ @Override
+ public float extractExp()
+ {
+ float exp = this.storageExp;
+ this.storageExp = 0;
+ return exp;
+ }
+
public int getCookTime(ItemStack stack)
{
- return 200;
+ return com.cleanroommc.common.crafting.FurnaceRecipeManager.instance().getCookTime(stack);
}

private boolean canSmelt()
@@ -281,11 +295,13 @@
{
return false;
}
Expand All @@ -54,7 +101,7 @@
}
}
}
@@ -305,7 +307,7 @@
@@ -305,7 +321,7 @@
}
else if (itemstack2.getItem() == itemstack1.getItem())
{
Expand All @@ -63,7 +110,16 @@
}

if (itemstack.getItem() == Item.getItemFromBlock(Blocks.SPONGE)
@@ -328,6 +330,8 @@
@@ -315,7 +331,7 @@
{
this.furnaceItemStacks.set(1, new ItemStack(Items.WATER_BUCKET));
}
-
+ this.addExp(com.cleanroommc.common.crafting.FurnaceRecipeManager.instance().getExperience(itemstack));
itemstack.shrink(1);
}
}
@@ -328,6 +344,8 @@
}
else
{
Expand All @@ -72,7 +128,7 @@
Item item = stack.getItem();

if (item == Item.getItemFromBlock(Blocks.WOODEN_SLAB))
@@ -549,5 +553,24 @@
@@ -549,5 +567,24 @@
public void clear()
{
this.furnaceItemStacks.clear();
Expand Down
Loading