Shovel API
This commit is contained in:
parent
ba89751ea8
commit
0ff7799785
3 changed files with 39 additions and 0 deletions
20
src/main/java/ru/bclib/api/ShovelAPI.java
Normal file
20
src/main/java/ru/bclib/api/ShovelAPI.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package ru.bclib.api;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import ru.bclib.mixin.common.ShovelItemAccessor;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ShovelAPI {
|
||||||
|
/**
|
||||||
|
* Will add left-click behaviour to shovel: when it is targeting cetrain {@link Block} it will be converting to new
|
||||||
|
* {@link BlockState} on usage. Example: grass converting to path.
|
||||||
|
* @param target {@link Block} that will be converted.
|
||||||
|
* @param convert {@link BlockState} to convert block into.
|
||||||
|
*/
|
||||||
|
public static void addShovelBehaviour(Block target, BlockState convert) {
|
||||||
|
Map<Block, BlockState> map = ShovelItemAccessor.bclib_getFlattenables();
|
||||||
|
map.put(target, convert);
|
||||||
|
}
|
||||||
|
}
|
17
src/main/java/ru/bclib/mixin/common/ShovelItemAccessor.java
Normal file
17
src/main/java/ru/bclib/mixin/common/ShovelItemAccessor.java
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package ru.bclib.mixin.common;
|
||||||
|
|
||||||
|
import net.minecraft.world.item.ShovelItem;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Mixin(ShovelItem.class)
|
||||||
|
public interface ShovelItemAccessor {
|
||||||
|
@Accessor("FLATTENABLES")
|
||||||
|
static Map<Block, BlockState> bclib_getFlattenables() {
|
||||||
|
throw new AssertionError("@Accessor dummy body called");
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,6 +32,7 @@
|
||||||
"DimensionTypeMixin",
|
"DimensionTypeMixin",
|
||||||
"RecipeManagerMixin",
|
"RecipeManagerMixin",
|
||||||
"RecipeManagerMixin",
|
"RecipeManagerMixin",
|
||||||
|
"ShovelItemAccessor",
|
||||||
"BoneMealItemMixin",
|
"BoneMealItemMixin",
|
||||||
"CraftingMenuMixin",
|
"CraftingMenuMixin",
|
||||||
"shears.SheepMixin",
|
"shears.SheepMixin",
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
"ServerLevelMixin",
|
"ServerLevelMixin",
|
||||||
"BiomeSourceMixin",
|
"BiomeSourceMixin",
|
||||||
"AnvilBlockMixin",
|
"AnvilBlockMixin",
|
||||||
|
"HoeItemAccessor",
|
||||||
"AnvilMenuMixin",
|
"AnvilMenuMixin",
|
||||||
"TagLoaderMixin",
|
"TagLoaderMixin",
|
||||||
"MainMixin"
|
"MainMixin"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue