forked from AppliedEnergistics/Applied-Energistics-2
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
a4f7b9c
commit edfee7e
Showing
6 changed files
with
77 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package refabricated.patches; | ||
|
||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.context.UseOnContext; | ||
|
||
public interface IItemExtended { | ||
|
||
default InteractionResult onItemUseFirst(ItemStack stack, UseOnContext context) { | ||
return InteractionResult.PASS; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/refabricated/patches/IItemStackExtended.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,38 @@ | ||
package refabricated.patches; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.component.DataComponents; | ||
import net.minecraft.stats.Stats; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.AdventureModePredicate; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.context.UseOnContext; | ||
import net.minecraft.world.level.block.state.pattern.BlockInWorld; | ||
|
||
public interface IItemStackExtended { | ||
|
||
private ItemStack self() { | ||
return (ItemStack) (Object) this; | ||
} | ||
|
||
default InteractionResult onItemUseFirst(UseOnContext context) { | ||
Player entityplayer = context.getPlayer(); | ||
BlockPos blockpos = context.getClickedPos(); | ||
BlockInWorld state = new BlockInWorld(context.getLevel(), blockpos, false); | ||
AdventureModePredicate adventureModePredicate = self().get(DataComponents.CAN_PLACE_ON); | ||
if (entityplayer != null && !entityplayer.getAbilities().mayBuild && (adventureModePredicate == null || !adventureModePredicate.test(state))) { | ||
return InteractionResult.PASS; | ||
} else { | ||
Item item = self().getItem(); | ||
InteractionResult result = ((IItemExtended) item).onItemUseFirst(self(), context); | ||
if (entityplayer != null && result == InteractionResult.SUCCESS) { | ||
entityplayer.awardStat(Stats.ITEM_USED.get(item)); | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8.3", | ||
"package": "refabricated.mixins", | ||
"compatibilityLevel": "JAVA_11", | ||
"mixins": [ | ||
], | ||
"server": [], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |