This repository has been archived by the owner on Apr 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/main/java/org/dimdev/rift/listener/ToolEfficiencyProvider.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,10 @@ | ||
package org.dimdev.rift.listener; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.item.ItemTool; | ||
|
||
import java.util.Set; | ||
|
||
public interface ToolEfficiencyProvider { | ||
void addEffectiveBlocks(ItemTool tool, Set<Block> target); | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/org/dimdev/rift/mixin/hook/MixinItemTool.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,32 @@ | ||
package org.dimdev.rift.mixin.hook; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.item.IItemTier; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemTool; | ||
import org.dimdev.rift.listener.ToolEfficiencyProvider; | ||
import org.dimdev.riftloader.RiftLoader; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Mutable; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@Mixin(ItemTool.class) | ||
public class MixinItemTool { | ||
@Shadow @Mutable @Final private Set<Block> effectiveBlocks; | ||
|
||
@Inject(method = "<init>", at = @At("RETURN")) | ||
private void onInit(float attackDamage, float attackSpeed, IItemTier tier, Set<Block> effectiveBlocks, Item.Builder builder, CallbackInfo ci) { | ||
this.effectiveBlocks = new HashSet<>(effectiveBlocks); | ||
|
||
for (ToolEfficiencyProvider toolEfficiencyProvider : RiftLoader.instance.getListeners(ToolEfficiencyProvider.class)) { | ||
toolEfficiencyProvider.addEffectiveBlocks((ItemTool) (Object) this, this.effectiveBlocks); | ||
} | ||
} | ||
} |
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