This repository has been archived by the owner on Jul 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change turtle refuel into a class replacer
Obfuscation means that bytecode injection for MC sources is tricky
- Loading branch information
Showing
5 changed files
with
61 additions
and
143 deletions.
There are no files selected for viewing
This file contains 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,4 +1,4 @@ | ||
mc_version=1.7.10 | ||
forge_version=10.13.2.1291 | ||
cc_version=1.73 | ||
mod_version=0.1.4.1 | ||
mod_version=0.1.4.2 |
This file contains 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
This file contains 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
This file contains 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
42 changes: 42 additions & 0 deletions
42
src/main/java/squiddev/cctweaks/core/turtle/TurtleRefuelCommand_Rewrite.java
This file contains 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,42 @@ | ||
package squiddev.cctweaks.core.turtle; | ||
|
||
import dan200.computercraft.api.turtle.ITurtleAccess; | ||
import dan200.computercraft.api.turtle.ITurtleCommand; | ||
import dan200.computercraft.api.turtle.TurtleAnimation; | ||
import dan200.computercraft.api.turtle.TurtleCommandResult; | ||
import net.minecraft.item.ItemStack; | ||
import squiddev.cctweaks.core.registry.TurtleRefuelList; | ||
|
||
/** | ||
* Complete rewrite of {@link dan200.computercraft.shared.turtle.core.TurtleRefuelCommand} | ||
* Uses the turtle refuel registry instead {@link TurtleRefuelList}. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class TurtleRefuelCommand_Rewrite implements ITurtleCommand { | ||
private int m_limit = 0; | ||
|
||
public TurtleRefuelCommand_Rewrite(int limit) { | ||
m_limit = limit; | ||
} | ||
|
||
public TurtleCommandResult execute(ITurtleAccess turtle) { | ||
ItemStack stack = turtle.getInventory().getStackInSlot(turtle.getSelectedSlot()); | ||
if (stack == null) { | ||
return TurtleCommandResult.failure("No items to combust"); | ||
} | ||
|
||
for (ITurtleRefuelSource source : TurtleRefuelList.refuelList) { | ||
if (source.canRefuel(turtle, stack, m_limit)) { | ||
if (m_limit == 0) { | ||
return TurtleCommandResult.success(); | ||
} else { | ||
turtle.addFuel(source.refuel(turtle, stack, m_limit)); | ||
turtle.playAnimation(TurtleAnimation.Wait); | ||
return TurtleCommandResult.success(); | ||
} | ||
} | ||
} | ||
|
||
return TurtleCommandResult.failure("Cannot refuel from this"); | ||
} | ||
} |