Change loading models (WIP)
This commit is contained in:
parent
ce98c5857e
commit
1e6451e375
9 changed files with 86 additions and 23 deletions
|
@ -2,8 +2,10 @@ package ru.betterend.blocks.basis;
|
|||
|
||||
import java.io.Reader;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
|
||||
public class BarkBlock extends EndPillarBlock {
|
||||
|
@ -16,13 +18,19 @@ public class BarkBlock extends EndPillarBlock {
|
|||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, getName(blockId), blockId.getPath());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(data, getName(blockId), blockId.getPath());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockModel getBlockModel(BlockState blockState) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getName(ResourceLocation blockId) {
|
||||
String name = blockId.getPath();
|
||||
return name.replace("_bark", "_log_side");
|
||||
|
|
|
@ -24,11 +24,6 @@ public class BlockBase extends Block implements BlockPatterned {
|
|||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public BlockModel getBlockModel(BlockState state) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String block = Registry.BLOCK.getKey(this).getPath();
|
||||
|
@ -36,13 +31,23 @@ public class BlockBase extends Block implements BlockPatterned {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
public String getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel() {
|
||||
return getBlockModel(defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SIMPLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getBlockModel(BlockState blockState) {
|
||||
return BlockModel.fromString(getModelString(""));
|
||||
}
|
||||
}
|
|
@ -7,7 +7,11 @@ import java.util.Map;
|
|||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.mojang.math.Transformation;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -69,6 +73,11 @@ public class EndAnvilBlock extends AnvilBlock implements BlockPatterned {
|
|||
return Patterns.createJson(Patterns.BLOCK_ANVIL, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel() {
|
||||
return getBlockModel(defaultBlockState());
|
||||
}
|
||||
|
||||
protected String getTop(ResourceLocation blockId, String block) {
|
||||
if (block.contains("item")) {
|
||||
return blockId.getPath() + "_top_0";
|
||||
|
@ -81,4 +90,18 @@ public class EndAnvilBlock extends AnvilBlock implements BlockPatterned {
|
|||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_ANVIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getBlockModel(BlockState blockState) {
|
||||
Direction facing = blockState.getValue(FACING);
|
||||
int destruction = blockState.getValue(DESTRUCTION);
|
||||
MultiVariant variant;
|
||||
Transformation transform;
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("%anvil%", blockId.getPath());
|
||||
map.put("%top%", "_top_" + destruction);
|
||||
String jsonString = Patterns.createJson(Patterns.BLOCK_ANVIL, map);
|
||||
return BlockModel.fromString(jsonString);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -15,7 +16,7 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
|||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
|
||||
public class EndPillarBlock extends RotatedPillarBlock implements BlockPatterned {
|
||||
public abstract class EndPillarBlock extends RotatedPillarBlock implements BlockPatterned {
|
||||
public EndPillarBlock(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
@ -28,6 +29,11 @@ public class EndPillarBlock extends RotatedPillarBlock implements BlockPatterned
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel() {
|
||||
return getBlockModel(defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
|
|
|
@ -30,7 +30,7 @@ public class StrippableBarkBlock extends BarkBlock {
|
|||
world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
if (!world.isClientSide) {
|
||||
world.setBlock(pos, striped.defaultBlockState().setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)), 11);
|
||||
if (player != null && !player.isCreative()) {
|
||||
if (!player.isCreative()) {
|
||||
player.getMainHandItem().hurt(1, world.random, (ServerPlayer) player);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue