diff --git a/src/main/java/ru/betterend/blocks/BlockProperties.java b/src/main/java/ru/betterend/blocks/BlockProperties.java index 39ee9d5c..b79bf939 100644 --- a/src/main/java/ru/betterend/blocks/BlockProperties.java +++ b/src/main/java/ru/betterend/blocks/BlockProperties.java @@ -6,15 +6,18 @@ import net.minecraft.state.property.IntProperty; import net.minecraft.util.StringIdentifiable; public class BlockProperties { - public static final EnumProperty TRIPLE_SHAPE = EnumProperty.of("shape", TripleShape.class); - public final static EnumProperty PEDESTAL_STATE = EnumProperty.of("state", PedestalState.class); public static final EnumProperty HYDRALUX_SHAPE = EnumProperty.of("shape", HydraluxShape.class); + public final static EnumProperty PEDESTAL_STATE = EnumProperty.of("state", PedestalState.class); + public static final EnumProperty TRIPLE_SHAPE = EnumProperty.of("shape", TripleShape.class); public static final EnumProperty PENTA_SHAPE = EnumProperty.of("shape", PentaShape.class); - public static final BooleanProperty HAS_ITEM = BooleanProperty.of("has_item"); + public static final BooleanProperty HAS_LIGHT = BooleanProperty.of("has_light"); - public static final BooleanProperty ACTIVE = BooleanProperty.of("active"); - public static final IntProperty ROTATION = IntProperty.of("rotation", 0, 3); + public static final BooleanProperty HAS_ITEM = BooleanProperty.of("has_item"); public static final BooleanProperty NATURAL = BooleanProperty.of("natural"); + public static final BooleanProperty ACTIVE = BooleanProperty.of("active"); + + public static final IntProperty DESTRUCTION = IntProperty.of("destruction", 0, 2); + public static final IntProperty ROTATION = IntProperty.of("rotation", 0, 3); public static final IntProperty FULLNESS = IntProperty.of("fullness", 0, 3); public static final IntProperty COLOR = IntProperty.of("color", 0, 7); diff --git a/src/main/java/ru/betterend/blocks/basis/EndAnvilBlock.java b/src/main/java/ru/betterend/blocks/basis/EndAnvilBlock.java index 701f1c16..6e06f0cf 100644 --- a/src/main/java/ru/betterend/blocks/basis/EndAnvilBlock.java +++ b/src/main/java/ru/betterend/blocks/basis/EndAnvilBlock.java @@ -3,24 +3,39 @@ package ru.betterend.blocks.basis; import java.io.Reader; import java.util.Collections; import java.util.List; +import java.util.Map; + +import com.google.common.collect.Maps; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.AnvilBlock; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.MaterialColor; import net.minecraft.item.ItemStack; import net.minecraft.loot.context.LootContext; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.IntProperty; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; +import ru.betterend.blocks.BlockProperties; import ru.betterend.patterns.BlockPatterned; import ru.betterend.patterns.Patterns; public class EndAnvilBlock extends AnvilBlock implements BlockPatterned { + public static final IntProperty DESTRUCTION = BlockProperties.DESTRUCTION; + public EndAnvilBlock(MaterialColor color) { super(FabricBlockSettings.copyOf(Blocks.ANVIL).materialColor(color)); } + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(DESTRUCTION); + } + @Override public List getDroppedStacks(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); @@ -35,7 +50,18 @@ public class EndAnvilBlock extends AnvilBlock implements BlockPatterned { @Override public String getModelPattern(String block) { Identifier blockId = Registry.BLOCK.getId(this); - return Patterns.createJson(Patterns.BLOCK_ANVIL, blockId.getPath(), blockId.getPath()); + Map map = Maps.newHashMap(); + map.put("%anvil%", blockId.getPath()); + map.put("%top%", getTop(blockId, block)); + return Patterns.createJson(Patterns.BLOCK_ANVIL, map); + } + + private String getTop(Identifier blockId, String block) { + if (block.contains("item")) { + return blockId.getPath() + "_top_0"; + } + char last = block.charAt(block.length() - 1); + return blockId.getPath() + "_top_" + last; } @Override diff --git a/src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java b/src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java new file mode 100644 index 00000000..9e73f468 --- /dev/null +++ b/src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java @@ -0,0 +1,24 @@ +package ru.betterend.mixin.common; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import net.minecraft.block.AnvilBlock; +import net.minecraft.block.BlockState; +import ru.betterend.blocks.BlockProperties; +import ru.betterend.blocks.basis.EndAnvilBlock; + +@Mixin(AnvilBlock.class) +public class AnvilBlockMixin { + @Inject(method = "getLandingState", at = @At("HEAD"), cancellable = true) + private static void be_getLandingState(BlockState fallingState, CallbackInfoReturnable info) { + if (fallingState.getBlock() instanceof EndAnvilBlock) { + int destruction = fallingState.get(BlockProperties.DESTRUCTION); + BlockState state = (destruction < 2) ? fallingState.with(BlockProperties.DESTRUCTION, destruction + 1) : null; + info.setReturnValue(state); + info.cancel(); + } + } +} diff --git a/src/main/resources/assets/betterend/blockstates/thallasium_anvil.json b/src/main/resources/assets/betterend/blockstates/thallasium_anvil.json deleted file mode 100644 index 917cb573..00000000 --- a/src/main/resources/assets/betterend/blockstates/thallasium_anvil.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "variants": { - "facing=east": { - "model": "betterend:block/thallasium_anvil", - "y": 270 - }, - "facing=north": { - "model": "betterend:block/thallasium_anvil", - "y": 180 - }, - "facing=south": { - "model": "betterend:block/thallasium_anvil" - }, - "facing=west": { - "model": "betterend:block/thallasium_anvil", - "y": 90 - } - } -} \ No newline at end of file diff --git a/src/main/resources/assets/betterend/models/block/thallasium_anvil.json b/src/main/resources/assets/betterend/models/block/thallasium_anvil.json deleted file mode 100644 index dfbf1030..00000000 --- a/src/main/resources/assets/betterend/models/block/thallasium_anvil.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio", - "parent": "block/block", - "textures": { - "particle": "betterend:block/thallasium_anvil_front", - "front": "betterend:block/thallasium_anvil_front", - "back": "betterend:block/thallasium_anvil_back", - "top": "betterend:block/thallasium_anvil_top", - "panel": "betterend:block/thallasium_anvil_panel", - "bottom": "betterend:block/thallasium_anvil_bottom" - }, - "elements": [ - { - "__comment": "Bottom", - "from": [ 2, 0, 2 ], - "to": [ 14, 4, 14 ], - "faces": { - "down": { "uv": [ 2, 2, 14, 14 ], "texture": "#bottom", "cullface": "down" }, - "up": { "uv": [ 2, 2, 14, 14 ], "texture": "#panel" }, - "north": { "uv": [ 2, 12, 14, 16 ], "texture": "#back" }, - "south": { "uv": [ 2, 12, 14, 16 ], "texture": "#back" }, - "west": { "uv": [ 2, 12, 14, 16 ], "texture": "#front" }, - "east": { "uv": [ 2, 12, 14, 16 ], "texture": "#front" } - } - }, - { - "__comment": "Plate", - "from": [ 4, 4, 3 ], - "to": [ 12, 5, 13 ], - "faces": { - "up": { "uv": [ 4, 3, 12, 13 ], "texture": "#panel" }, - "north": { "uv": [ 4, 11, 12, 12 ], "texture": "#back" }, - "south": { "uv": [ 4, 11, 12, 12 ], "texture": "#back" }, - "west": { "uv": [ 3, 11, 13, 12 ], "texture": "#front" }, - "east": { "uv": [ 3, 11, 13, 12 ], "texture": "#front" } - } - }, - { - "__comment": "Support", - "from": [ 6, 5, 4 ], - "to": [ 10, 10, 12 ], - "faces": { - "north": { "uv": [ 6, 6, 10, 11 ], "texture": "#back" }, - "south": { "uv": [ 6, 6, 10, 11 ], "texture": "#back" }, - "west": { "uv": [ 4, 6, 12, 11 ], "texture": "#front" }, - "east": { "uv": [ 4, 6, 12, 11 ], "texture": "#front" } - } - }, - { - "__comment": "Top", - "from": [ 3, 10, 0 ], - "to": [ 13, 16, 16 ], - "faces": { - "down": { "uv": [ 3, 0, 13, 16 ], "texture": "#top" }, - "up": { "uv": [ 3, 0, 13, 16 ], "texture": "#top" }, - "north": { "uv": [ 3, 0, 13, 6 ], "texture": "#back" }, - "south": { "uv": [ 3, 0, 13, 6 ], "texture": "#back" }, - "west": { "uv": [ 0, 0, 16, 6 ], "texture": "#front" }, - "east": { "uv": [ 0, 0, 16, 6 ], "texture": "#front" } - } - } - ], - "display": { - "fixed": { - "rotation": [ 0, 90, 0 ], - "scale": [ 0.5, 0.5, 0.5 ] - } - } -} \ No newline at end of file diff --git a/src/main/resources/assets/betterend/models/item/thallasium_anvil.json b/src/main/resources/assets/betterend/models/item/thallasium_anvil.json deleted file mode 100644 index acefa708..00000000 --- a/src/main/resources/assets/betterend/models/item/thallasium_anvil.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parent": "betterend:block/thallasium_anvil" -} diff --git a/src/main/resources/assets/betterend/patterns/block/anvil.json b/src/main/resources/assets/betterend/patterns/block/anvil.json index 4e7ee106..8d6658d3 100644 --- a/src/main/resources/assets/betterend/patterns/block/anvil.json +++ b/src/main/resources/assets/betterend/patterns/block/anvil.json @@ -1,8 +1,68 @@ { - "parent": "minecraft:block/template_anvil", + "parent": "block/block", "textures": { - "top": "betterend:block/%block%_top", - "body": "betterend:block/%block%", - "particle": "#body" + "particle": "betterend:block/%anvil%_front", + "front": "betterend:block/%anvil%_front", + "back": "betterend:block/%anvil%_back", + "top": "betterend:block/%top%", + "panel": "betterend:block/%anvil%_panel", + "bottom": "betterend:block/%anvil%_bottom" + }, + "elements": [ + { + "__comment": "Bottom", + "from": [ 2, 0, 2 ], + "to": [ 14, 4, 14 ], + "faces": { + "down": { "uv": [ 2, 2, 14, 14 ], "texture": "#bottom", "cullface": "down" }, + "up": { "uv": [ 2, 2, 14, 14 ], "texture": "#panel" }, + "north": { "uv": [ 2, 12, 14, 16 ], "texture": "#back" }, + "south": { "uv": [ 2, 12, 14, 16 ], "texture": "#back" }, + "west": { "uv": [ 2, 12, 14, 16 ], "texture": "#front" }, + "east": { "uv": [ 2, 12, 14, 16 ], "texture": "#front" } + } + }, + { + "__comment": "Plate", + "from": [ 4, 4, 3 ], + "to": [ 12, 5, 13 ], + "faces": { + "up": { "uv": [ 4, 3, 12, 13 ], "texture": "#panel" }, + "north": { "uv": [ 4, 11, 12, 12 ], "texture": "#back" }, + "south": { "uv": [ 4, 11, 12, 12 ], "texture": "#back" }, + "west": { "uv": [ 3, 11, 13, 12 ], "texture": "#front" }, + "east": { "uv": [ 3, 11, 13, 12 ], "texture": "#front" } + } + }, + { + "__comment": "Support", + "from": [ 6, 5, 4 ], + "to": [ 10, 10, 12 ], + "faces": { + "north": { "uv": [ 6, 6, 10, 11 ], "texture": "#back" }, + "south": { "uv": [ 6, 6, 10, 11 ], "texture": "#back" }, + "west": { "uv": [ 4, 6, 12, 11 ], "texture": "#front" }, + "east": { "uv": [ 4, 6, 12, 11 ], "texture": "#front" } + } + }, + { + "__comment": "Top", + "from": [ 3, 10, 0 ], + "to": [ 13, 16, 16 ], + "faces": { + "down": { "uv": [ 3, 0, 13, 16 ], "texture": "#top" }, + "up": { "uv": [ 3, 0, 13, 16 ], "texture": "#top" }, + "north": { "uv": [ 3, 0, 13, 6 ], "texture": "#back" }, + "south": { "uv": [ 3, 0, 13, 6 ], "texture": "#back" }, + "west": { "uv": [ 0, 0, 16, 6 ], "texture": "#front" }, + "east": { "uv": [ 0, 0, 16, 6 ], "texture": "#front" } + } + } + ], + "display": { + "fixed": { + "rotation": [ 0, 90, 0 ], + "scale": [ 0.5, 0.5, 0.5 ] + } } } \ No newline at end of file diff --git a/src/main/resources/assets/betterend/patterns/blockstate/anvil.json b/src/main/resources/assets/betterend/patterns/blockstate/anvil.json index 82389017..253ff406 100644 --- a/src/main/resources/assets/betterend/patterns/blockstate/anvil.json +++ b/src/main/resources/assets/betterend/patterns/blockstate/anvil.json @@ -1,19 +1,16 @@ { "variants": { - "facing=east": { - "model": "betterend:pattern/%block%", - "y": 270 - }, - "facing=north": { - "model": "betterend:pattern/%block%", - "y": 180 - }, - "facing=south": { - "model": "betterend:pattern/%block%" - }, - "facing=west": { - "model": "betterend:pattern/%block%", - "y": 90 - } + "destruction=0,facing=east": { "model": "betterend:pattern/%block%/%block%_0", "y": 270 }, + "destruction=0,facing=north": { "model": "betterend:pattern/%block%/%block%_0", "y": 180 }, + "destruction=0,facing=south": { "model": "betterend:pattern/%block%/%block%_0" }, + "destruction=0,facing=west": { "model": "betterend:pattern/%block%/%block%_0", "y": 90 }, + "destruction=1,facing=east": { "model": "betterend:pattern/%block%/%block%_1", "y": 270 }, + "destruction=1,facing=north": { "model": "betterend:pattern/%block%/%block%_1", "y": 180 }, + "destruction=1,facing=south": { "model": "betterend:pattern/%block%/%block%_1" }, + "destruction=1,facing=west": { "model": "betterend:pattern/%block%/%block%_1", "y": 90 }, + "destruction=2,facing=east": { "model": "betterend:pattern/%block%/%block%_2", "y": 270 }, + "destruction=2,facing=north": { "model": "betterend:pattern/%block%/%block%_2", "y": 180 }, + "destruction=2,facing=south": { "model": "betterend:pattern/%block%/%block%_2" }, + "destruction=2,facing=west": { "model": "betterend:pattern/%block%/%block%_2", "y": 90 } } } \ No newline at end of file diff --git a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_back.png b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_back.png index 321f670e..fe9b06bb 100644 Binary files a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_back.png and b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_back.png differ diff --git a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_bottom.png b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_bottom.png index c54f8c26..dfdba387 100644 Binary files a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_bottom.png and b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_bottom.png differ diff --git a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_front.png b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_front.png index 299e32c7..1bf03e69 100644 Binary files a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_front.png and b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_front.png differ diff --git a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_panel.png b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_panel.png index c620d54d..85fc8e8a 100644 Binary files a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_panel.png and b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_panel.png differ diff --git a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_top.png b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_top.png deleted file mode 100644 index b83f089d..00000000 Binary files a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_top.png and /dev/null differ diff --git a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_top_0.png b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_top_0.png new file mode 100644 index 00000000..a8444900 Binary files /dev/null and b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_top_0.png differ diff --git a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_top_1.png b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_top_1.png new file mode 100644 index 00000000..9af873c2 Binary files /dev/null and b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_top_1.png differ diff --git a/src/main/resources/assets/betterend/textures/block/thallasium_anvil_top_2.png b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_top_2.png new file mode 100644 index 00000000..1e212986 Binary files /dev/null and b/src/main/resources/assets/betterend/textures/block/thallasium_anvil_top_2.png differ diff --git a/src/main/resources/betterend.mixins.common.json b/src/main/resources/betterend.mixins.common.json index aebff1d2..3c6ce7fa 100644 --- a/src/main/resources/betterend.mixins.common.json +++ b/src/main/resources/betterend.mixins.common.json @@ -32,6 +32,7 @@ "BoneMealItemMixin", "PlayerEntityMixin", "SlimeEntityMixin", + "AnvilBlockMixin", "BrewingAccessor", "EntityMixin" ],