Anvil states & new textures
This commit is contained in:
parent
650c85194e
commit
28886adf33
17 changed files with 136 additions and 116 deletions
|
@ -6,15 +6,18 @@ import net.minecraft.state.property.IntProperty;
|
|||
import net.minecraft.util.StringIdentifiable;
|
||||
|
||||
public class BlockProperties {
|
||||
public static final EnumProperty<TripleShape> TRIPLE_SHAPE = EnumProperty.of("shape", TripleShape.class);
|
||||
public final static EnumProperty<PedestalState> PEDESTAL_STATE = EnumProperty.of("state", PedestalState.class);
|
||||
public static final EnumProperty<HydraluxShape> HYDRALUX_SHAPE = EnumProperty.of("shape", HydraluxShape.class);
|
||||
public final static EnumProperty<PedestalState> PEDESTAL_STATE = EnumProperty.of("state", PedestalState.class);
|
||||
public static final EnumProperty<TripleShape> TRIPLE_SHAPE = EnumProperty.of("shape", TripleShape.class);
|
||||
public static final EnumProperty<PentaShape> 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);
|
||||
|
||||
|
|
|
@ -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<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(DESTRUCTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> 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<String, String> 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
|
||||
|
|
24
src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java
Normal file
24
src/main/java/ru/betterend/mixin/common/AnvilBlockMixin.java
Normal file
|
@ -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<BlockState> 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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue