-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3953 from iTwins/fix/geo_miner_voiding_resources
- Loading branch information
Showing
5 changed files
with
59 additions
and
14 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
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
...java/io/github/thebusybiscuit/slimefun4/implementation/operations/GEOMiningOperation.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 io.github.thebusybiscuit.slimefun4.implementation.operations; | ||
|
||
import java.util.OptionalInt; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import io.github.bakedlibs.dough.blocks.BlockPosition; | ||
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; | ||
import io.github.thebusybiscuit.slimefun4.api.geo.ResourceManager; | ||
import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation; | ||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; | ||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner; | ||
|
||
/** | ||
* This {@link MachineOperation} represents a {@link GEOMiner} | ||
* mining a {@link GEOResource}. | ||
* | ||
* @author iTwins | ||
* | ||
* @see GEOMiner | ||
*/ | ||
public class GEOMiningOperation extends MiningOperation { | ||
|
||
private final GEOResource resource; | ||
|
||
public GEOMiningOperation(@Nonnull GEOResource resource, int totalTicks) { | ||
super(resource.getItem().clone(), totalTicks); | ||
this.resource = resource; | ||
} | ||
|
||
/** | ||
* This returns the {@link GEOResource} back to the chunk | ||
* when the {@link GEOMiningOperation} gets cancelled | ||
*/ | ||
@Override | ||
public void onCancel(@Nonnull BlockPosition position) { | ||
ResourceManager resourceManager = Slimefun.getGPSNetwork().getResourceManager(); | ||
OptionalInt supplies = resourceManager.getSupplies(resource, position.getWorld(), position.getChunkX(), position.getChunkZ()); | ||
supplies.ifPresent(s -> resourceManager.setSupplies(resource, position.getWorld(), position.getChunkX(), position.getChunkZ(), s + 1)); | ||
} | ||
|
||
} |
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