-
Notifications
You must be signed in to change notification settings - Fork 79
Furnace optimize #586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
gardenevery
wants to merge
14
commits into
CleanroomMC:main
Choose a base branch
from
gardenevery:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Furnace optimize #586
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4be9bfc
furnace optimize
gardenevery d15fc3a
Revert breaking API change
gardenevery 8558d2b
check subtype
gardenevery 8bf1865
ItemKey optimize
gardenevery 5a4c52e
fix
gardenevery 1f7d9df
move to cleanroom package
gardenevery a3e98ed
Merge branch 'CleanroomMC:main' into main
gardenevery b18f69b
Revert "move to cleanroom package"
gardenevery bd853f1
Revert "fix"
gardenevery 5a38db4
Revert "ItemKey optimize"
gardenevery 454bbf5
Revert "check subtype"
gardenevery 2dee790
Revert "Revert breaking API change"
gardenevery 88fc2de
Revert "furnace optimize"
gardenevery 9b5ca76
remove
gardenevery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
patches/minecraft/net/minecraft/block/BlockFurnace.java.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| + 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)); | ||
| + } | ||
| + } | ||
| } | ||
| } | ||
|
|
||
14 changes: 13 additions & 1 deletion
14
patches/minecraft/net/minecraft/inventory/SlotFurnaceOutput.java.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 55 additions & 11 deletions
66
patches/minecraft/net/minecraft/item/crafting/FurnaceRecipes.java.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.