Merge branch 'experimental'
This commit is contained in:
commit
df71f23d35
118 changed files with 2135 additions and 2898 deletions
|
@ -9,7 +9,7 @@ import ru.betterend.api.BetterEndPlugin;
|
|||
import ru.betterend.config.Configs;
|
||||
import ru.betterend.effects.EndEnchantments;
|
||||
import ru.betterend.effects.EndPotions;
|
||||
import ru.betterend.events.PlayerAdvancementsEvents;
|
||||
import ru.betterend.events.PlayerAdvancementsCallback;
|
||||
import ru.betterend.integration.Integrations;
|
||||
import ru.betterend.item.GuideBookItem;
|
||||
import ru.betterend.recipe.AlloyingRecipes;
|
||||
|
@ -78,7 +78,7 @@ public class BetterEnd implements ModInitializer {
|
|||
Configs.saveConfigs();
|
||||
|
||||
if (hasGuideBook()) {
|
||||
PlayerAdvancementsEvents.PLAYER_ADVENCEMENT_COMPLETE.register((player, advancement, criterionName) -> {
|
||||
PlayerAdvancementsCallback.PLAYER_ADVANCEMENT_COMPLETE.register((player, advancement, criterionName) -> {
|
||||
ResourceLocation advId = new ResourceLocation("minecraft:end/enter_end_gateway");
|
||||
if (advId.equals(advancement.getId())) {
|
||||
player.addItem(new ItemStack(GuideBookItem.GUIDE_BOOK));
|
||||
|
@ -102,6 +102,10 @@ public class BetterEnd implements ModInitializer {
|
|||
public static String getStringId(String id) {
|
||||
return String.format("%s:%s", MOD_ID, id);
|
||||
}
|
||||
|
||||
public static boolean isModId(ResourceLocation id) {
|
||||
return id.getNamespace().equals(MOD_ID);
|
||||
}
|
||||
|
||||
public static boolean isDevEnvironment() {
|
||||
return FabricLoader.getInstance().isDevelopmentEnvironment();
|
||||
|
|
|
@ -1,35 +1,57 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.item.material.EndToolMaterial;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class AeterniumAnvil extends EndAnvilBlock {
|
||||
private static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION_LONG;
|
||||
private static final IntegerProperty DESTRUCTION_LONG = BlockProperties.DESTRUCTION_LONG;
|
||||
|
||||
public AeterniumAnvil() {
|
||||
super(EndBlocks.AETERNIUM_BLOCK.defaultMaterialColor(), EndToolMaterial.AETERNIUM.getLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(DESTRUCTION);
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntegerProperty getDestructionProperty() {
|
||||
return DESTRUCTION;
|
||||
return DESTRUCTION_LONG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_ANVIL_LONG;
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
String name = blockId.getPath();
|
||||
int damage = getDamageState(blockState);
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%anvil%", name);
|
||||
textures.put("%top%", name + "_top_" + damage);
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_ANVIL, textures);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
int damage = getDamageState(blockState);
|
||||
String modId = stateId.getNamespace();
|
||||
String modelId = "block/" + stateId.getPath() + "_top_" + damage;
|
||||
ResourceLocation modelLocation = new ResourceLocation(modId, modelId);
|
||||
registerBlockModel(stateId, modelLocation, blockState, modelCache);
|
||||
return ModelsHelper.createFacingModel(modelLocation, blockState.getValue(FACING), false, false);
|
||||
}
|
||||
|
||||
private int getDamageState(BlockState blockState) {
|
||||
IntegerProperty destructionProperty = getDestructionProperty();
|
||||
int damage = blockState.getValue(destructionProperty);
|
||||
return damage < 3 ? 0 : damage < 6 ? 1 : 2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class BlockProperties {
|
|||
public static final IntegerProperty SIZE = IntegerProperty.create("size", 0, 7);
|
||||
public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 3);
|
||||
|
||||
public static enum TripleShape implements StringRepresentable {
|
||||
public enum TripleShape implements StringRepresentable {
|
||||
TOP("top", 0),
|
||||
MIDDLE("middle", 1),
|
||||
BOTTOM("bottom", 2);
|
||||
|
@ -62,7 +62,7 @@ public class BlockProperties {
|
|||
}
|
||||
}
|
||||
|
||||
public static enum PedestalState implements StringRepresentable {
|
||||
public enum PedestalState implements StringRepresentable {
|
||||
PEDESTAL_TOP("pedestal_top"),
|
||||
COLUMN_TOP("column_top"),
|
||||
BOTTOM("bottom"),
|
||||
|
@ -87,7 +87,7 @@ public class BlockProperties {
|
|||
}
|
||||
}
|
||||
|
||||
public static enum HydraluxShape implements StringRepresentable {
|
||||
public enum HydraluxShape implements StringRepresentable {
|
||||
FLOWER_BIG_BOTTOM("flower_big_bottom", true),
|
||||
FLOWER_BIG_TOP("flower_big_top", true),
|
||||
FLOWER_SMALL_BOTTOM("flower_small_bottom", true),
|
||||
|
@ -118,7 +118,7 @@ public class BlockProperties {
|
|||
}
|
||||
}
|
||||
|
||||
public static enum PentaShape implements StringRepresentable {
|
||||
public enum PentaShape implements StringRepresentable {
|
||||
BOTTOM("bottom"),
|
||||
PRE_BOTTOM("pre_bottom"),
|
||||
MIDDLE("middle"),
|
||||
|
@ -142,7 +142,7 @@ public class BlockProperties {
|
|||
}
|
||||
}
|
||||
|
||||
public static enum LumecornShape implements StringRepresentable {
|
||||
public enum LumecornShape implements StringRepresentable {
|
||||
LIGHT_TOP("light_top", 15),
|
||||
LIGHT_TOP_MIDDLE("light_top_middle", 15),
|
||||
LIGHT_MIDDLE("light_middle", 15),
|
||||
|
@ -174,7 +174,7 @@ public class BlockProperties {
|
|||
}
|
||||
}
|
||||
|
||||
public static enum CactusBottom implements StringRepresentable {
|
||||
public enum CactusBottom implements StringRepresentable {
|
||||
EMPTY("empty"),
|
||||
SAND("sand"),
|
||||
MOSS("moss");
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -18,13 +19,15 @@ import net.minecraft.world.level.material.Material;
|
|||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.blocks.basis.EndLanternBlock;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class BulbVineLanternBlock extends EndLanternBlock implements IRenderTypeable, BlockPatterned {
|
||||
public class BulbVineLanternBlock extends EndLanternBlock implements IRenderTypeable, BlockModelProvider {
|
||||
private static final VoxelShape SHAPE_CEIL = Block.box(4, 4, 4, 12, 16, 12);
|
||||
private static final VoxelShape SHAPE_FLOOR = Block.box(4, 0, 4, 12, 12, 12);
|
||||
|
||||
|
@ -52,25 +55,16 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
|
|||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("%glow%", getGlowTexture());
|
||||
map.put("%metal%", getMetalTexture(blockId));
|
||||
if (block.contains("item") || block.contains("ceil")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_CEIL, map);
|
||||
}
|
||||
else {
|
||||
return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_FLOOR, map);
|
||||
}
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%glow%", getGlowTexture());
|
||||
textures.put("%metal%", getMetalTexture(resourceLocation));
|
||||
Optional<String> pattern = blockState.getValue(IS_FLOOR) ?
|
||||
Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_FLOOR, textures) :
|
||||
Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_CEIL, textures);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
protected String getMetalTexture(ResourceLocation blockId) {
|
||||
|
@ -82,9 +76,5 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
|
|||
protected String getGlowTexture() {
|
||||
return "bulb_vine_lantern_bulb";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_BULB_LANTERN;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,16 +14,12 @@ public class BulbVineLanternColoredBlock extends BulbVineLanternBlock implements
|
|||
|
||||
@Override
|
||||
public BlockColor getProvider() {
|
||||
return (state, world, pos, tintIndex) -> {
|
||||
return getColor();
|
||||
};
|
||||
return (state, world, pos, tintIndex) -> getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemColor getItemProvider() {
|
||||
return (stack, tintIndex) -> {
|
||||
return getColor();
|
||||
};
|
||||
return (stack, tintIndex) -> getColor();
|
||||
}
|
||||
|
||||
private int getColor() {
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -16,13 +20,15 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.blocks.basis.AttachedBlock;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, BlockPatterned {
|
||||
public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, BlockModelProvider {
|
||||
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
||||
|
||||
public ChandelierBlock(Block source) {
|
||||
|
@ -38,35 +44,55 @@ public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, B
|
|||
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
return BOUNDING_SHAPES.get(state.getValue(FACING));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return ModelsHelper.createItemModel(blockId.getPath());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
|
||||
}
|
||||
else if (block.contains("ceil")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_CEIL, blockId.getPath());
|
||||
}
|
||||
else if (block.contains("wall")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_WALL, blockId.getPath());
|
||||
}
|
||||
else {
|
||||
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_FLOOR, blockId.getPath());
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
Optional<String> pattern;
|
||||
switch (blockState.getValue(FACING)) {
|
||||
case UP:
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_CHANDELIER_FLOOR, resourceLocation.getPath());
|
||||
break;
|
||||
case DOWN:
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_CHANDELIER_CEIL, resourceLocation.getPath());
|
||||
break;
|
||||
default:
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_CHANDELIER_WALL, resourceLocation.getPath());
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_CHANDELIER;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String state = "_wall";
|
||||
BlockModelRotation rotation = BlockModelRotation.X0_Y0;
|
||||
switch (blockState.getValue(FACING)) {
|
||||
case UP:
|
||||
state = "_floor";
|
||||
break;
|
||||
case DOWN:
|
||||
state = "_ceil";
|
||||
break;
|
||||
case EAST:
|
||||
rotation = BlockModelRotation.X0_Y270;
|
||||
break;
|
||||
case NORTH:
|
||||
rotation = BlockModelRotation.X0_Y180;
|
||||
break;
|
||||
case WEST:
|
||||
rotation = BlockModelRotation.X0_Y90;
|
||||
break;
|
||||
}
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + state);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
BOUNDING_SHAPES.put(Direction.UP, Block.box(5, 0, 5, 11, 13, 11));
|
||||
BOUNDING_SHAPES.put(Direction.DOWN, Block.box(5, 3, 5, 11, 16, 11));
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -25,12 +26,13 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderTypeable, BlockPatterned {
|
||||
public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderTypeable, BlockModelProvider {
|
||||
public EmeraldIceBlock() {
|
||||
super(FabricBlockSettings.copyOf(Blocks.ICE));
|
||||
}
|
||||
|
@ -85,21 +87,9 @@ public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderType
|
|||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String block = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, block, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SIMPLE;
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,19 +8,18 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.basis.PedestalBlock;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
|
||||
public class EndPedestal extends PedestalBlock {
|
||||
|
||||
public EndPedestal(Block parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
protected Map<String, String> createTexturesMap() {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
||||
String name = blockId.getPath();
|
||||
Map<String, String> textures = new HashMap<String, String>() {
|
||||
return new HashMap<String, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put("%mod%", BetterEnd.MOD_ID );
|
||||
|
@ -30,17 +29,5 @@ public class EndPedestal extends PedestalBlock {
|
|||
put("%bottom%", name + "_polished");
|
||||
}
|
||||
};
|
||||
if (block.contains("column_top")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
|
||||
} else if (block.contains("column")) {
|
||||
return Patterns.createJson(Patterns.BLOKC_PEDESTAL_COLUMN, textures);
|
||||
} else if (block.contains("top")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_TOP, textures);
|
||||
} else if (block.contains("bottom")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_BOTTOM, textures);
|
||||
} else if (block.contains("pillar")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_PILLAR, textures);
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.interfaces.IColorProvider;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements IColorProvider {
|
||||
|
@ -28,21 +32,11 @@ public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements ICo
|
|||
return BlocksHelper.getBlockColor(this);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
String path = "betterend:block/block_petal_colored";
|
||||
return Patterns.createJson(data, path, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
String path = "betterend:block/block_petal_colored";
|
||||
return Patterns.createJson(Patterns.BLOCK_PETAL_COLORED, path, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_DIRECT;
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_PETAL_COLORED, path, path);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -21,15 +21,17 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IColorProvider;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable, BlockPatterned, IColorProvider {
|
||||
public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable, BlockModelProvider, IColorProvider {
|
||||
public static final IntegerProperty COLOR = BlockProperties.COLOR;
|
||||
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
|
||||
private final Vec3i colorStart;
|
||||
|
@ -65,23 +67,18 @@ public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable,
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Lists.newArrayList(new ItemStack(this));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String block = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, block, block);
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
return Patterns.createJson(Patterns.BLOCK_COLORED, "jellyshroom_cap");
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_COLORED, "jellyshroom_cap");
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SIMPLE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockColor getProvider() {
|
||||
return (state, world, pos, tintIndex) -> {
|
||||
|
|
|
@ -7,19 +7,18 @@ import net.minecraft.core.Registry;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.betterend.blocks.basis.PedestalBlock;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
|
||||
public class PedestalVanilla extends PedestalBlock {
|
||||
|
||||
public PedestalVanilla(Block parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
protected Map<String, String> createTexturesMap() {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
||||
String name = blockId.getPath().replace("_block", "");
|
||||
Map<String, String> textures = new HashMap<String, String>() {
|
||||
return new HashMap<String, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put("%mod%", blockId.getNamespace() );
|
||||
|
@ -29,17 +28,5 @@ public class PedestalVanilla extends PedestalBlock {
|
|||
put("%bottom%", "polished_" + name);
|
||||
}
|
||||
};
|
||||
if (block.contains("column_top")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
|
||||
} else if (block.contains("column")) {
|
||||
return Patterns.createJson(Patterns.BLOKC_PEDESTAL_COLUMN, textures);
|
||||
} else if (block.contains("top")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_TOP, textures);
|
||||
} else if (block.contains("bottom")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_BOTTOM, textures);
|
||||
} else if (block.contains("pillar")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_PILLAR, textures);
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import ru.betterend.blocks.basis.EndTerrainBlock;
|
||||
import ru.betterend.registry.EndParticles;
|
||||
|
||||
public class ShadowGrassBlock extends EndTerrainBlock {
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -26,12 +27,12 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
|||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderTypeable, BlockPatterned {
|
||||
public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderTypeable, BlockModelProvider {
|
||||
public static final IntegerProperty COLOR = BlockProperties.COLOR;
|
||||
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(0);
|
||||
|
||||
|
@ -66,23 +67,6 @@ public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderType
|
|||
return MHelper.RANDOM.nextInt(4) == 0 ? Lists.newArrayList(new ItemStack(EndBlocks.UMBRELLA_TREE_SAPLING)) : Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String block = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, block, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SIMPLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, BlockGetter world, BlockPos pos) {
|
||||
|
@ -98,4 +82,9 @@ public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderType
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,22 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class BarkBlock extends EndPillarBlock {
|
||||
public BarkBlock(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
protected Optional<String> createBlockPattern(ResourceLocation blockId) {
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
private String getName(ResourceLocation blockId) {
|
||||
String name = blockId.getPath();
|
||||
return name.replace("_bark", "_log_side");
|
||||
|
|
|
@ -1,42 +1,31 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
|
||||
public class BlockBase extends Block implements BlockPatterned {
|
||||
public BlockBase(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String block = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, block, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SIMPLE;
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class BlockBase extends Block implements BlockModelProvider {
|
||||
public BlockBase(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return getBlockModel(blockId, defaultBlockState());
|
||||
}
|
||||
}
|
|
@ -1,13 +1,15 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -19,11 +21,13 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
|||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndAnvilBlock extends AnvilBlock implements BlockPatterned {
|
||||
public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
|
||||
private static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION;
|
||||
protected final int level;
|
||||
|
||||
|
@ -35,7 +39,7 @@ public class EndAnvilBlock extends AnvilBlock implements BlockPatterned {
|
|||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
builder.add(DESTRUCTION);
|
||||
builder.add(getDestructionProperty());
|
||||
}
|
||||
|
||||
public IntegerProperty getDestructionProperty() {
|
||||
|
@ -53,21 +57,6 @@ public class EndAnvilBlock extends AnvilBlock implements BlockPatterned {
|
|||
stack.getOrCreateTag().putInt("level", level);
|
||||
return Collections.singletonList(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("%anvil%", blockId.getPath());
|
||||
map.put("%top%", getTop(blockId, block));
|
||||
return Patterns.createJson(Patterns.BLOCK_ANVIL, map);
|
||||
}
|
||||
|
||||
protected String getTop(ResourceLocation blockId, String block) {
|
||||
if (block.contains("item")) {
|
||||
|
@ -76,9 +65,32 @@ public class EndAnvilBlock extends AnvilBlock implements BlockPatterned {
|
|||
char last = block.charAt(block.length() - 1);
|
||||
return blockId.getPath() + "_top_" + last;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_ANVIL;
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return getBlockModel(blockId, defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
IntegerProperty destructionProperty = getDestructionProperty();
|
||||
int destruction = blockState.getValue(destructionProperty);
|
||||
String name = blockId.getPath();
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%anvil%", name);
|
||||
textures.put("%top%", name + "_top_" + destruction);
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_ANVIL, textures);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
IntegerProperty destructionProperty = getDestructionProperty();
|
||||
int destruction = blockState.getValue(destructionProperty);
|
||||
String modId = stateId.getNamespace();
|
||||
String modelId = "block/" + stateId.getPath() + "_top_" + destruction;
|
||||
ResourceLocation modelLocation = new ResourceLocation(modId, modelId);
|
||||
registerBlockModel(stateId, modelLocation, blockState, modelCache);
|
||||
return ModelsHelper.createFacingModel(modelLocation, blockState.getValue(FACING), false, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
@ -25,12 +30,14 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.blocks.entities.EBarrelBlockEntity;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
public class EndBarrelBlock extends BarrelBlock implements BlockPatterned {
|
||||
public class EndBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
||||
public EndBarrelBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).noOcclusion());
|
||||
}
|
||||
|
@ -87,24 +94,39 @@ public class EndBarrelBlock extends BarrelBlock implements BlockPatterned {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String block = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, block, block);
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return getBlockModel(blockId, defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||
if (block.contains("open")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
String texture = blockId.getPath();
|
||||
Optional<String> pattern;
|
||||
if (blockState.getValue(OPEN)) {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture);
|
||||
} else {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_BOTTOM_TOP, texture, texture);
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_BOTTOM_TOP, texture, texture);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_BARREL;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String open = blockState.getValue(OPEN) ? "_open" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + open);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
Direction facing = blockState.getValue(FACING);
|
||||
BlockModelRotation rotation = BlockModelRotation.X0_Y0;
|
||||
switch (facing) {
|
||||
case NORTH: rotation = BlockModelRotation.X90_Y0; break;
|
||||
case EAST: rotation = BlockModelRotation.X90_Y90; break;
|
||||
case SOUTH: rotation = BlockModelRotation.X90_Y180; break;
|
||||
case WEST: rotation = BlockModelRotation.X90_Y270; break;
|
||||
case DOWN: rotation = BlockModelRotation.X180_Y0; break;
|
||||
}
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
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,9 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndBookshelfBlock extends BlockBase {
|
||||
public EndBookshelfBlock(Block source) {
|
||||
|
@ -33,24 +36,14 @@ public class EndBookshelfBlock extends BlockBase {
|
|||
}
|
||||
return Collections.singletonList(new ItemStack(Items.BOOK, 3));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SIMPLE;
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_BOOKSHELF,
|
||||
getName(blockId), blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(Patterns.BLOCK_BOOKSHELF, getName(blockId), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(data, getName(blockId), blockId.getPath());
|
||||
}
|
||||
|
||||
|
||||
private String getName(ResourceLocation blockId) {
|
||||
String name = blockId.getPath();
|
||||
return name.replace("_bookshelf", "");
|
||||
|
|
77
src/main/java/ru/betterend/blocks/basis/EndButtonBlock.java
Normal file
77
src/main/java/ru/betterend/blocks/basis/EndButtonBlock.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.ButtonBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.AttachFace;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class EndButtonBlock extends ButtonBlock implements BlockModelProvider {
|
||||
|
||||
private final Block parent;
|
||||
|
||||
protected EndButtonBlock(Block parent, Properties properties, boolean sensitive) {
|
||||
super(sensitive, properties);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_BUTTON, parentId.getPath(), blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
Optional<String> pattern = blockState.getValue(POWERED) ?
|
||||
Patterns.createJson(Patterns.BLOCK_BUTTON_PRESSED, parentId.getPath(), blockId.getPath()) :
|
||||
Patterns.createJson(Patterns.BLOCK_BUTTON, parentId.getPath(), blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String powered = blockState.getValue(POWERED) ? "_powered" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + powered);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
AttachFace face = blockState.getValue(FACE);
|
||||
boolean isCeiling = face == AttachFace.CEILING;
|
||||
int x = 0, y = 0;
|
||||
switch (face) {
|
||||
case CEILING: x = 180; break;
|
||||
case WALL: x = 90; break;
|
||||
}
|
||||
switch (blockState.getValue(FACING)) {
|
||||
case NORTH: if (isCeiling) { y = 180; } break;
|
||||
case EAST: y = isCeiling ? 270 : 90; break;
|
||||
case SOUTH: if(!isCeiling) { y = 180; } break;
|
||||
case WEST: y = isCeiling ? 90 : 270; break;
|
||||
}
|
||||
BlockModelRotation rotation = BlockModelRotation.by(x, y);
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), face == AttachFace.WALL);
|
||||
}
|
||||
}
|
|
@ -1,10 +1,14 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -13,12 +17,14 @@ import net.minecraft.world.level.block.ChainBlock;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndChainBlock extends ChainBlock implements BlockPatterned, IRenderTypeable {
|
||||
public class EndChainBlock extends ChainBlock implements BlockModelProvider, IRenderTypeable {
|
||||
public EndChainBlock(MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.CHAIN).materialColor(color));
|
||||
}
|
||||
|
@ -27,27 +33,28 @@ public class EndChainBlock extends ChainBlock implements BlockPatterned, IRender
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return ModelsHelper.createItemModel(blockId.getPath());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_CHAIN, blockId.getPath(), blockId.getPath());
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
String name = blockId.getPath();
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_CHAIN, name, name);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_CHAIN;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
Direction.Axis axis = blockState.getValue(AXIS);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createRotatedModel(modelId, axis);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
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;
|
||||
|
@ -13,17 +14,17 @@ import net.minecraft.world.level.block.ChestBlock;
|
|||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
public class EndChestBlock extends ChestBlock implements BlockPatterned {
|
||||
public class EndChestBlock extends ChestBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
public EndChestBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).noOcclusion(), () -> {
|
||||
return EndBlockEntities.CHEST;
|
||||
});
|
||||
super(FabricBlockSettings.copyOf(source).noOcclusion(), () -> EndBlockEntities.CHEST);
|
||||
this.parent = source;
|
||||
}
|
||||
|
||||
|
@ -40,26 +41,16 @@ public class EndChestBlock extends ChestBlock implements BlockPatterned {
|
|||
drop.add(new ItemStack(this.asItem()));
|
||||
return drop;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_CHEST, blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String path) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (path.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_CHEST, blockId.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SIMPLE;
|
||||
return ModelsHelper.createBlockEmpty(parentId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -12,10 +15,13 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.ComposterBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.ModelsHelper.MultiPartBuilder;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndComposterBlock extends ComposterBlock implements BlockPatterned {
|
||||
public class EndComposterBlock extends ComposterBlock implements BlockModelProvider {
|
||||
public EndComposterBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source));
|
||||
}
|
||||
|
@ -24,22 +30,37 @@ public class EndComposterBlock extends ComposterBlock implements BlockPatterned
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this.asItem()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String blockId = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, blockId, blockId);
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
String blockName = blockId.getPath();
|
||||
return Patterns.createJson(Patterns.BLOCK_COMPOSTER, blockName);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_COMPOSTER, blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_COMPOSTER;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
|
||||
MultiPartBuilder builder = MultiPartBuilder.create(stateDefinition);
|
||||
LEVEL.getPossibleValues().forEach(level -> {
|
||||
if (level > 0) {
|
||||
ResourceLocation contentId;
|
||||
if (level > 7) {
|
||||
contentId = new ResourceLocation("block/composter_contents_ready");
|
||||
} else {
|
||||
contentId = new ResourceLocation("block/composter_contents" + level);
|
||||
}
|
||||
builder.part(contentId).setCondition(state -> state.getValue(LEVEL).equals(level)).add();
|
||||
}
|
||||
});
|
||||
builder.part(modelId).add();
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
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;
|
||||
|
@ -13,10 +14,12 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.CraftingTableBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndCraftingTableBlock extends CraftingTableBlock implements BlockPatterned {
|
||||
public class EndCraftingTableBlock extends CraftingTableBlock implements BlockModelProvider {
|
||||
public EndCraftingTableBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source));
|
||||
}
|
||||
|
@ -25,18 +28,16 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockPa
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this.asItem()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String blockId = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, blockId, blockId);
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
String blockName = blockId.getPath();
|
||||
return Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put("%particle%", blockName + "_front");
|
||||
|
@ -48,10 +49,6 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockPa
|
|||
put("%east%", blockName + "_side");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SIMPLE;
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,33 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.DoorHingeSide;
|
||||
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockPatterned {
|
||||
public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockModelProvider {
|
||||
public EndDoorBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).strength(3F, 3F).noOcclusion());
|
||||
}
|
||||
|
@ -35,33 +44,121 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockPat
|
|||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String blockId = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, blockId, blockId);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
String blockName = resourceLocation.getPath();
|
||||
DoorType doorType = getDoorType(blockState);
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM, blockName, blockName);
|
||||
switch (doorType) {
|
||||
case TOP_HINGE: {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_DOOR_TOP_HINGE, blockName, blockName);
|
||||
break;
|
||||
}
|
||||
case BOTTOM_HINGE: {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM_HINGE, blockName, blockName);
|
||||
break;
|
||||
}
|
||||
case TOP: {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_DOOR_TOP, blockName, blockName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
String blockId = Registry.BLOCK.getKey(this).getPath();
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_GENERATED, block);
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
Direction facing = blockState.getValue(FACING);
|
||||
DoorType doorType = getDoorType(blockState);
|
||||
boolean open = blockState.getValue(OPEN);
|
||||
boolean hinge = doorType.isHinge();
|
||||
BlockModelRotation rotation = BlockModelRotation.X0_Y0;
|
||||
switch (facing) {
|
||||
case EAST: {
|
||||
if (hinge && open) {
|
||||
rotation = BlockModelRotation.X0_Y90;
|
||||
} else if (open) {
|
||||
rotation = BlockModelRotation.X0_Y270;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
if (!hinge && !open || hinge && !open) {
|
||||
rotation = BlockModelRotation.X0_Y90;
|
||||
} else if (hinge) {
|
||||
rotation = BlockModelRotation.X0_Y180;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
if (!hinge && !open || hinge && !open) {
|
||||
rotation = BlockModelRotation.X0_Y180;
|
||||
} else if (hinge) {
|
||||
rotation = BlockModelRotation.X0_Y270;
|
||||
} else {
|
||||
rotation = BlockModelRotation.X0_Y90;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
if (!hinge && !open || hinge && !open) {
|
||||
rotation = BlockModelRotation.X0_Y270;
|
||||
} else if (!hinge) {
|
||||
rotation = BlockModelRotation.X0_Y180;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (block.contains("top_hinge")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_DOOR_TOP_HINGE, blockId, blockId);
|
||||
}
|
||||
if (block.contains("bottom_hinge")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM_HINGE, blockId, blockId);
|
||||
}
|
||||
if (block.contains("top")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_DOOR_TOP, blockId, blockId);
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM, blockId, blockId);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_" + doorType);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_DOOR;
|
||||
|
||||
protected DoorType getDoorType(BlockState blockState) {
|
||||
boolean isHinge = isHinge(blockState.getValue(HINGE), blockState.getValue(OPEN));
|
||||
switch (blockState.getValue(HALF)) {
|
||||
case UPPER: {
|
||||
return isHinge ? DoorType.TOP_HINGE : DoorType.TOP;
|
||||
}
|
||||
case LOWER: {
|
||||
return isHinge ? DoorType.BOTTOM_HINGE : DoorType.BOTTOM;
|
||||
}
|
||||
}
|
||||
return DoorType.BOTTOM;
|
||||
}
|
||||
|
||||
private boolean isHinge(DoorHingeSide hingeSide, boolean open) {
|
||||
boolean isHinge = hingeSide == DoorHingeSide.RIGHT;
|
||||
return isHinge && !open || !isHinge && open;
|
||||
}
|
||||
|
||||
protected enum DoorType implements StringRepresentable {
|
||||
BOTTOM_HINGE("bottom_hinge"),
|
||||
TOP_HINGE("top_hinge"),
|
||||
BOTTOM("bottom"),
|
||||
TOP("top");
|
||||
|
||||
private final String name;
|
||||
|
||||
DoorType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isHinge() {
|
||||
return this == BOTTOM_HINGE ||
|
||||
this == TOP_HINGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getSerializedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSerializedName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
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.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -12,10 +11,18 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.FenceBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.ModelsHelper.MultiPartBuilder;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndFenceBlock extends FenceBlock implements BlockPatterned {
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class EndFenceBlock extends FenceBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
public EndFenceBlock(Block source) {
|
||||
|
@ -27,29 +34,47 @@ public class EndFenceBlock extends FenceBlock implements BlockPatterned {
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_FENCE, parentId.getPath(), blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_FENCE, parentId.getPath(), blockId.getPath());
|
||||
String path = blockId.getPath();
|
||||
Optional<String> pattern = Optional.empty();
|
||||
if (path.endsWith("_post")) {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_FENCE_POST, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
if (block.contains("side")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_FENCE_SIDE, parentId.getPath(), blockId.getPath());
|
||||
if (path.endsWith("_side")) {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_FENCE_SIDE, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_FENCE_POST, parentId.getPath(), blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_FENCE;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation postId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_post");
|
||||
ResourceLocation sideId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_side");
|
||||
registerBlockModel(postId, postId, blockState, modelCache);
|
||||
registerBlockModel(sideId, sideId, blockState, modelCache);
|
||||
|
||||
MultiPartBuilder builder = MultiPartBuilder.create(stateDefinition);
|
||||
builder.part(sideId).setCondition(state -> state.getValue(NORTH)).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(EAST))
|
||||
.setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(SOUTH))
|
||||
.setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(WEST))
|
||||
.setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add();
|
||||
builder.part(postId).add();
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -23,17 +25,17 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.blocks.entities.EFurnaceBlockEntity;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned, IRenderTypeable {
|
||||
public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider, IRenderTypeable {
|
||||
public EndFurnaceBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).luminance((state) -> {
|
||||
return state.getValue(LIT) ? 13 : 0;
|
||||
}));
|
||||
super(FabricBlockSettings.copyOf(source).luminance(state -> state.getValue(LIT) ? 13 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,33 +51,37 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockPatterned, IRe
|
|||
player.awardStat(Stats.INTERACT_WITH_FURNACE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("%top%", blockId.getPath() + "_top");
|
||||
map.put("%side%", blockId.getPath() + "_side");
|
||||
if (block.contains("_on")) {
|
||||
map.put("%front%", blockId.getPath() + "_front_on");
|
||||
map.put("%glow%", blockId.getPath() + "_glow");
|
||||
return Patterns.createJson(Patterns.BLOCK_FURNACE_GLOW, map);
|
||||
}
|
||||
else {
|
||||
map.put("%front%", blockId.getPath() + "_front");
|
||||
return Patterns.createJson(Patterns.BLOCK_FURNACE, map);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
String blockName = blockId.getPath();
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%top%", blockName + "_top");
|
||||
textures.put("%side%", blockName + "_side");
|
||||
Optional<String> pattern;
|
||||
if (blockState.getValue(LIT)) {
|
||||
textures.put("%front%", blockName + "_front_on");
|
||||
textures.put("%glow%", blockName + "_glow");
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_FURNACE_LIT, textures);
|
||||
} else {
|
||||
textures.put("%front%", blockName + "_front");
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_FURNACE, textures);
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_FURNACE;
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String lit = blockState.getValue(LIT) ? "_lit" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + lit);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createFacingModel(modelId, blockState.getValue(FACING), false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -12,10 +15,12 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.FenceGateBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndGateBlock extends FenceGateBlock implements BlockPatterned {
|
||||
public class EndGateBlock extends FenceGateBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
public EndGateBlock(Block source) {
|
||||
|
@ -27,33 +32,36 @@ public class EndGateBlock extends FenceGateBlock implements BlockPatterned {
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
boolean inWall = blockState.getValue(IN_WALL);
|
||||
boolean isOpen = blockState.getValue(OPEN);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("wall")) {
|
||||
if (block.contains("open")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_GATE_OPEN_WALL, parentId.getPath(), blockId.getPath());
|
||||
} else {
|
||||
return Patterns.createJson(Patterns.BLOCK_GATE_CLOSED_WALL, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
Optional<String> pattern;
|
||||
if (inWall) {
|
||||
pattern = isOpen ? Patterns.createJson(Patterns.BLOCK_GATE_OPEN_WALL, parentId.getPath(), blockId.getPath()) :
|
||||
Patterns.createJson(Patterns.BLOCK_GATE_CLOSED_WALL, parentId.getPath(), blockId.getPath());
|
||||
} else {
|
||||
pattern = isOpen ? Patterns.createJson(Patterns.BLOCK_GATE_OPEN, parentId.getPath(), blockId.getPath()) :
|
||||
Patterns.createJson(Patterns.BLOCK_GATE_CLOSED, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
if (block.contains("open")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_GATE_OPEN, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_GATE_CLOSED, parentId.getPath(), blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_GATE;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
boolean inWall = blockState.getValue(IN_WALL);
|
||||
boolean isOpen = blockState.getValue(OPEN);
|
||||
String state = "" + (inWall ? "_wall" : "") + (isOpen ? "_open" : "_closed");
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + state);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createFacingModel(modelId, blockState.getValue(FACING), true, false);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,11 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -25,13 +28,15 @@ import net.minecraft.world.level.material.FluidState;
|
|||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable, BlockPatterned {
|
||||
public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable, BlockModelProvider {
|
||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
protected static final VoxelShape EAST_SHAPE = Block.box(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 16.0D);
|
||||
|
@ -136,24 +141,22 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
|
|||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String blockId = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, blockId, blockId);
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return ModelsHelper.createBlockItem(blockId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_LADDER, blockId.getPath());
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_LADDER, blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_LADDER;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createFacingModel(modelId, blockState.getValue(FACING), false, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
@ -19,6 +21,9 @@ import net.minecraft.world.level.material.Fluid;
|
|||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class EndLanternBlock extends BlockBaseNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer {
|
||||
public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR;
|
||||
|
@ -116,4 +121,13 @@ public class EndLanternBlock extends BlockBaseNotFull implements SimpleWaterlogg
|
|||
public FluidState getFluidState(BlockState state) {
|
||||
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String floor = blockState.getValue(IS_FLOOR) ? "_floor" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + floor);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createBlockSimple(modelId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -22,11 +23,11 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
|||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class EndLeavesBlock extends LeavesBlock implements BlockPatterned, IRenderTypeable {
|
||||
public class EndLeavesBlock extends LeavesBlock implements BlockModelProvider, IRenderTypeable {
|
||||
private final Block sapling;
|
||||
|
||||
public EndLeavesBlock(Block sapling, MaterialColor color) {
|
||||
|
@ -52,24 +53,7 @@ public class EndLeavesBlock extends LeavesBlock implements BlockPatterned, IRend
|
|||
.isViewBlocking((state, world, pos) -> false));
|
||||
this.sapling = sapling;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String blockId = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, blockId, blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
String blockId = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId, blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SIMPLE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
|
@ -90,4 +74,9 @@ public class EndLeavesBlock extends LeavesBlock implements BlockPatterned, IRend
|
|||
}
|
||||
return MHelper.RANDOM.nextInt(16) == 0 ? Lists.newArrayList(new ItemStack(sapling)) : Lists.newArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -15,12 +19,14 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.IronBarsBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndMetalPaneBlock extends IronBarsBlock implements BlockPatterned, IRenderTypeable {
|
||||
public class EndMetalPaneBlock extends IronBarsBlock implements BlockModelProvider, IRenderTypeable {
|
||||
public EndMetalPaneBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).strength(5.0F, 6.0F).noOcclusion());
|
||||
}
|
||||
|
@ -29,15 +35,8 @@ public class EndMetalPaneBlock extends IronBarsBlock implements BlockPatterned,
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());
|
||||
|
@ -49,7 +48,50 @@ public class EndMetalPaneBlock extends IronBarsBlock implements BlockPatterned,
|
|||
return Patterns.createJson(Patterns.BLOCK_BARS_SIDE, blockId.getPath(), blockId.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createBlockItem(resourceLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
ResourceLocation thisId = Registry.BLOCK.getKey(this);
|
||||
String path = blockId.getPath();
|
||||
Optional<String> pattern = Optional.empty();
|
||||
if (path.endsWith("_post")) {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_BARS_POST, thisId.getPath(), thisId.getPath());
|
||||
}
|
||||
if (path.endsWith("_side")) {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_BARS_SIDE, thisId.getPath(), thisId.getPath());
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation postId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_post");
|
||||
ResourceLocation sideId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_side");
|
||||
registerBlockModel(postId, postId, blockState, modelCache);
|
||||
registerBlockModel(sideId, sideId, blockState, modelCache);
|
||||
|
||||
ModelsHelper.MultiPartBuilder builder = ModelsHelper.MultiPartBuilder.create(stateDefinition);
|
||||
builder.part(postId).setCondition(state ->
|
||||
!state.getValue(NORTH) && !state.getValue(EAST) &&
|
||||
!state.getValue(SOUTH) && !state.getValue(WEST)).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(NORTH)).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(EAST))
|
||||
.setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(SOUTH))
|
||||
.setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(WEST))
|
||||
.setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add();
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) {
|
||||
if (direction.getAxis().isVertical() && stateFrom.getBlock().is(this) && !stateFrom.equals(state)) {
|
||||
|
@ -57,12 +99,7 @@ public class EndMetalPaneBlock extends IronBarsBlock implements BlockPatterned,
|
|||
}
|
||||
return super.skipRendering(state, stateFrom, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_BARS;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.WeightedPressurePlateBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
|
||||
public class EndMetalPlateBlock extends WeightedPressurePlateBlock implements BlockPatterned {
|
||||
private final Block parent;
|
||||
|
||||
public EndMetalPlateBlock(Block source) {
|
||||
super(15, FabricBlockSettings.copyOf(source).noCollission().noOcclusion().requiresCorrectToolForDrops().strength(0.5F));
|
||||
this.parent = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("down")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_PLATE;
|
||||
}
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -20,17 +19,16 @@ import net.minecraft.world.level.material.Material;
|
|||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class EndOreBlock extends OreBlock implements BlockPatterned {
|
||||
public class EndOreBlock extends OreBlock implements BlockModelProvider {
|
||||
private final Item dropItem;
|
||||
private final int minCount;
|
||||
private final int maxCount;
|
||||
private final int expirience;
|
||||
private final int experience;
|
||||
|
||||
public EndOreBlock(Item drop, int minCount, int maxCount, int expirience) {
|
||||
public EndOreBlock(Item drop, int minCount, int maxCount, int experience) {
|
||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND)
|
||||
.hardness(3F)
|
||||
.resistance(9F)
|
||||
|
@ -39,12 +37,12 @@ public class EndOreBlock extends OreBlock implements BlockPatterned {
|
|||
this.dropItem = drop;
|
||||
this.minCount = minCount;
|
||||
this.maxCount = maxCount;
|
||||
this.expirience = expirience;
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int xpOnDrop(Random random) {
|
||||
return this.expirience > 0 ? random.nextInt(expirience) + 1 : 0;
|
||||
return this.experience > 0 ? random.nextInt(experience) + 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,21 +68,9 @@ public class EndOreBlock extends OreBlock implements BlockPatterned {
|
|||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String block = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, block, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SIMPLE;
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,70 +1,82 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
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.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
|
||||
public class EndPathBlock extends BlockBaseNotFull {
|
||||
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 15, 16);
|
||||
|
||||
public EndPathBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).isValidSpawn((state, world, pos, type) -> { return false; }));
|
||||
if (source instanceof EndTerrainBlock) {
|
||||
EndTerrainBlock terrain = (EndTerrainBlock) source;
|
||||
terrain.setPathBlock(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||
if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
return Collections.singletonList(new ItemStack(Blocks.END_STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
String name = Registry.BLOCK.getKey(this).getPath();
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("%top%", name + "_top");
|
||||
map.put("%side%", name.replace("_path", "") + "_side");
|
||||
return Patterns.createJson(Patterns.BLOCK_PATH, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_ROTATED_TOP;
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndPathBlock extends BlockBaseNotFull {
|
||||
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 15, 16);
|
||||
|
||||
public EndPathBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).isValidSpawn((state, world, pos, type) -> { return false; }));
|
||||
if (source instanceof EndTerrainBlock) {
|
||||
EndTerrainBlock terrain = (EndTerrainBlock) source;
|
||||
terrain.setPathBlock(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||
if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
return Collections.singletonList(new ItemStack(Blocks.END_STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return getBlockModel(blockId, defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
String name = resourceLocation.getPath();
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%top%", name + "_top");
|
||||
textures.put("%side%", name.replace("_path", "") + "_side");
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_PATH, textures);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createRandomTopModel(modelId);
|
||||
}
|
||||
}
|
|
@ -1,10 +1,13 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -12,10 +15,12 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.RotatedPillarBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndPillarBlock extends RotatedPillarBlock implements BlockPatterned {
|
||||
public class EndPillarBlock extends RotatedPillarBlock implements BlockModelProvider {
|
||||
public EndPillarBlock(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
@ -28,21 +33,27 @@ public class EndPillarBlock extends RotatedPillarBlock implements BlockPatterned
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, texture, texture);
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return getBlockModel(blockId, defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(Patterns.BLOCK_PILLAR, texture, texture);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
Optional<String> pattern = createBlockPattern(blockId);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_PILLAR;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createRotatedModel(modelId, blockState.getValue(AXIS));
|
||||
}
|
||||
|
||||
protected Optional<String> createBlockPattern(ResourceLocation blockId) {
|
||||
return Patterns.createBlockPillar(blockId.getPath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -12,10 +15,12 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.PressurePlateBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndPlateBlock extends PressurePlateBlock implements BlockPatterned {
|
||||
public class EndPlateBlock extends PressurePlateBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
public EndPlateBlock(Sensitivity rule, Block source) {
|
||||
|
@ -27,26 +32,30 @@ public class EndPlateBlock extends PressurePlateBlock implements BlockPatterned
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("down")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), blockId.getPath());
|
||||
Optional<String> pattern;
|
||||
if (blockState.getValue(POWERED)) {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), resourceLocation.getPath());
|
||||
} else {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), resourceLocation.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return this.stateDefinition.getProperty("facing") != null ? Patterns.STATE_PLATE_ROTATED : Patterns.STATE_PLATE;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String state = blockState.getValue(POWERED) ? "_down" : "_up";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + state);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createBlockSimple(modelId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -38,13 +39,15 @@ import net.minecraft.world.level.material.Fluids;
|
|||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.blocks.entities.ESignBlockEntity;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.interfaces.ISpetialItem;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class EndSignBlock extends SignBlock implements BlockPatterned, ISpetialItem {
|
||||
public class EndSignBlock extends SignBlock implements BlockModelProvider, ISpetialItem {
|
||||
public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16;
|
||||
public static final BooleanProperty FLOOR = BooleanProperty.create("floor");
|
||||
private static final VoxelShape[] WALL_SHAPES = new VoxelShape[] {
|
||||
|
@ -79,14 +82,15 @@ public class EndSignBlock extends SignBlock implements BlockPatterned, ISpetialI
|
|||
|
||||
@Override
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
|
||||
if (placer != null && placer instanceof Player) {
|
||||
if (placer instanceof Player) {
|
||||
ESignBlockEntity sign = (ESignBlockEntity) world.getBlockEntity(pos);
|
||||
if (!world.isClientSide) {
|
||||
sign.setAllowedPlayerEditor((Player) placer);
|
||||
((ServerPlayer) placer).connection.send(new ClientboundOpenSignEditorPacket(pos));
|
||||
}
|
||||
else {
|
||||
sign.setEditable(true);
|
||||
if (sign != null) {
|
||||
if (!world.isClientSide) {
|
||||
sign.setAllowedPlayerEditor((Player) placer);
|
||||
((ServerPlayer) placer).connection.send(new ClientboundOpenSignEditorPacket(pos));
|
||||
} else {
|
||||
sign.setEditable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,8 +132,7 @@ public class EndSignBlock extends SignBlock implements BlockPatterned, ISpetialI
|
|||
BlockPos blockPos = ctx.getClickedPos();
|
||||
Direction[] directions = ctx.getNearestLookingDirections();
|
||||
|
||||
for (int i = 0; i < directions.length; ++i) {
|
||||
Direction direction = directions[i];
|
||||
for (Direction direction : directions) {
|
||||
if (direction.getAxis().isHorizontal()) {
|
||||
Direction dir = direction.getOpposite();
|
||||
int rot = Mth.floor((180.0 + dir.toYRot() * 16.0 / 360.0) + 0.5 + 4) & 15;
|
||||
|
@ -143,28 +146,13 @@ public class EndSignBlock extends SignBlock implements BlockPatterned, ISpetialI
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
||||
return ModelsHelper.createBlockEmpty(parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String path) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (path.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_GENERATED, path);
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SIMPLE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, Rotation rotation) {
|
||||
return (BlockState) state.setValue(ROTATION, rotation.rotate((Integer) state.getValue(ROTATION), 16));
|
||||
|
|
|
@ -1,21 +1,28 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SlabBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndSlabBlock extends SlabBlock implements BlockPatterned {
|
||||
public class EndSlabBlock extends SlabBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
public EndSlabBlock(Block source) {
|
||||
|
@ -27,23 +34,28 @@ public class EndSlabBlock extends SlabBlock implements BlockPatterned {
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(Patterns.BLOCK_SLAB, parentId.getPath(), blockId.getPath());
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_SLAB, parentId.getPath(), blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SLAB;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
SlabType type = blockState.getValue(TYPE);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_" + type);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
if (type == SlabType.TOP) {
|
||||
return ModelsHelper.createMultiVariant(modelId, BlockModelRotation.X180_Y0.getRotation(), true);
|
||||
}
|
||||
return ModelsHelper.createBlockSimple(modelId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,29 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.StairBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Half;
|
||||
import net.minecraft.world.level.block.state.properties.StairsShape;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndStairsBlock extends StairBlock implements BlockPatterned {
|
||||
public class EndStairsBlock extends StairBlock implements BlockModelProvider {
|
||||
|
||||
private final Block parent;
|
||||
|
||||
|
@ -28,29 +36,72 @@ public class EndStairsBlock extends StairBlock implements BlockPatterned {
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("inner")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_STAIR_INNER, parentId.getPath(), blockId.getPath());
|
||||
Optional<String> pattern = Optional.empty();
|
||||
switch (blockState.getValue(SHAPE)) {
|
||||
case STRAIGHT:
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_STAIR, parentId.getPath(), blockId.getPath());
|
||||
break;
|
||||
case INNER_LEFT:
|
||||
case INNER_RIGHT:
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_STAIR_INNER, parentId.getPath(), blockId.getPath());
|
||||
break;
|
||||
case OUTER_LEFT:
|
||||
case OUTER_RIGHT:
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_STAIR_OUTER, parentId.getPath(), blockId.getPath());
|
||||
break;
|
||||
}
|
||||
if (block.contains("outer")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_STAIR_OUTER, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_STAIR, parentId.getPath(), blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_STAIRS;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String state = "";
|
||||
StairsShape shape = blockState.getValue(SHAPE);
|
||||
switch (shape) {
|
||||
case INNER_LEFT:
|
||||
case INNER_RIGHT:
|
||||
state = "_inner"; break;
|
||||
case OUTER_LEFT:
|
||||
case OUTER_RIGHT:
|
||||
state = "_outer"; break;
|
||||
}
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + state);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
|
||||
boolean isTop = blockState.getValue(HALF) == Half.TOP;
|
||||
boolean isLeft = shape == StairsShape.INNER_LEFT ||
|
||||
shape == StairsShape.OUTER_LEFT;
|
||||
boolean isRight = shape == StairsShape.INNER_RIGHT ||
|
||||
shape == StairsShape.OUTER_RIGHT;
|
||||
int y = 0;
|
||||
int x = isTop ? 180 : 0;
|
||||
switch (blockState.getValue(FACING)) {
|
||||
case NORTH:
|
||||
if (isTop && !isRight) y = 270;
|
||||
else if (!isTop) y = isLeft ? 180 : 270;
|
||||
break;
|
||||
case EAST:
|
||||
if (isTop && isRight) y = 90;
|
||||
else if (!isTop && isLeft) y = 270;
|
||||
break;
|
||||
case SOUTH:
|
||||
if (isTop) y = isRight ? 180 : 90;
|
||||
else if (!isLeft) y = 90;
|
||||
break;
|
||||
case WEST:
|
||||
y = (isTop && isRight) ? 270 : (!isTop && isLeft) ? 90 : 180;
|
||||
break;
|
||||
}
|
||||
BlockModelRotation rotation = BlockModelRotation.by(x, y);
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,55 +1,33 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.StoneButtonBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndStoneButtonBlock extends EndButtonBlock {
|
||||
|
||||
public class EndStoneButtonBlock extends StoneButtonBlock implements BlockPatterned {
|
||||
private final Block parent;
|
||||
|
||||
public EndStoneButtonBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).noOcclusion());
|
||||
this.parent = source;
|
||||
super(source, FabricBlockSettings.copyOf(source).noOcclusion(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_BUTTON, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
if (block.contains("pressed")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_BUTTON_PRESSED, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_BUTTON, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_BUTTON;
|
||||
protected SoundEvent getSound(boolean clicked) {
|
||||
return clicked ? SoundEvents.STONE_BUTTON_CLICK_ON : SoundEvents.STONE_BUTTON_CLICK_OFF;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class EndStonelateBlock extends EndPlateBlock {
|
||||
public EndStonelateBlock(Block source) {
|
||||
super(Sensitivity.MOBS, source);
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks.basis;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class EndStonePlateBlock extends EndPlateBlock {
|
||||
public EndStonePlateBlock(Block source) {
|
||||
super(Sensitivity.MOBS, source);
|
||||
}
|
||||
}
|
|
@ -1,111 +1,121 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.SnowLayerBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.lighting.LayerLightEngine;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
|
||||
public class EndTerrainBlock extends BlockBase {
|
||||
private Block pathBlock;
|
||||
|
||||
public EndTerrainBlock(MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sound(BlockSounds.TERRAIN_SOUND).randomTicks());
|
||||
}
|
||||
|
||||
public void setPathBlock(Block roadBlock) {
|
||||
this.pathBlock = roadBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (pathBlock != null && player.getMainHandItem().getItem().is(FabricToolTags.SHOVELS)) {
|
||||
world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
if (!world.isClientSide) {
|
||||
world.setBlockAndUpdate(pos, pathBlock.defaultBlockState());
|
||||
if (!player.isCreative()) {
|
||||
player.getMainHandItem().hurt(1, world.random, (ServerPlayer) player);
|
||||
}
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||
if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
return Collections.singletonList(new ItemStack(Blocks.END_STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||
if (random.nextInt(16) == 0 && !canStay(state, world, pos)) {
|
||||
world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canStay(BlockState state, LevelReader worldView, BlockPos pos) {
|
||||
BlockPos blockPos = pos.above();
|
||||
BlockState blockState = worldView.getBlockState(blockPos);
|
||||
if (blockState.is(Blocks.SNOW) && (Integer) blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
|
||||
return true;
|
||||
}
|
||||
else if (blockState.getFluidState().getAmount() == 8) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
|
||||
return i < 5;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
String name = Registry.BLOCK.getKey(this).getPath();
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("%top%", "betterend:block/" + name + "_top");
|
||||
map.put("%side%", "betterend:block/" + name + "_side");
|
||||
map.put("%bottom%", "minecraft:block/end_stone");
|
||||
return Patterns.createJson(Patterns.BLOCK_TOP_SIDE_BOTTOM, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_ROTATED_TOP;
|
||||
}
|
||||
}
|
||||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.SnowLayerBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.lighting.LayerLightEngine;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.blocks.BlockSounds;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndTerrainBlock extends BlockBase {
|
||||
private Block pathBlock;
|
||||
|
||||
public EndTerrainBlock(MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sound(BlockSounds.TERRAIN_SOUND).randomTicks());
|
||||
}
|
||||
|
||||
public void setPathBlock(Block roadBlock) {
|
||||
this.pathBlock = roadBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (pathBlock != null && player.getMainHandItem().getItem().is(FabricToolTags.SHOVELS)) {
|
||||
world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
if (!world.isClientSide) {
|
||||
world.setBlockAndUpdate(pos, pathBlock.defaultBlockState());
|
||||
if (!player.isCreative()) {
|
||||
player.getMainHandItem().hurt(1, world.random, (ServerPlayer) player);
|
||||
}
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||
if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
return Collections.singletonList(new ItemStack(Blocks.END_STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||
if (random.nextInt(16) == 0 && !canStay(state, world, pos)) {
|
||||
world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canStay(BlockState state, LevelReader worldView, BlockPos pos) {
|
||||
BlockPos blockPos = pos.above();
|
||||
BlockState blockState = worldView.getBlockState(blockPos);
|
||||
if (blockState.is(Blocks.SNOW) && (Integer) blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
|
||||
return true;
|
||||
}
|
||||
else if (blockState.getFluidState().getAmount() == 8) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
|
||||
return i < 5;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return getBlockModel(blockId, defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
String name = resourceLocation.getPath();
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%top%", "betterend:block/" + name + "_top");
|
||||
textures.put("%side%", "betterend:block/" + name + "_side");
|
||||
textures.put("%bottom%", "minecraft:block/end_stone");
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_TOP_SIDE_BOTTOM, textures);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createRandomTopModel(modelId);
|
||||
}
|
||||
}
|
|
@ -1,24 +1,27 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.TrapDoorBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Half;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndTrapdoorBlock extends TrapDoorBlock implements IRenderTypeable, BlockPatterned {
|
||||
public class EndTrapdoorBlock extends TrapDoorBlock implements IRenderTypeable, BlockModelProvider {
|
||||
public EndTrapdoorBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).strength(3.0F, 3.0F).noOcclusion());
|
||||
}
|
||||
|
@ -32,28 +35,48 @@ public class EndTrapdoorBlock extends TrapDoorBlock implements IRenderTypeable,
|
|||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String block = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, block, block);
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
String name = blockId.getPath();
|
||||
return Patterns.createJson(Patterns.BLOCK_TRAPDOOR, new HashMap<String, String>() {
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
String name = resourceLocation.getPath();
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_TRAPDOOR, new HashMap<String, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put("%block%", name);
|
||||
put("%texture%", name.replace("trapdoor", "door_side"));
|
||||
}
|
||||
});
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_TRAPDOOR;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
boolean isTop = blockState.getValue(HALF) == Half.TOP;
|
||||
boolean isOpen = blockState.getValue(OPEN);
|
||||
int y = 0;
|
||||
int x = (isTop && isOpen) ? 270 : isTop ? 180 : isOpen ? 90 : 0;
|
||||
switch (blockState.getValue(FACING)) {
|
||||
case EAST:
|
||||
y = (isTop && isOpen) ? 270 : 90;
|
||||
break;
|
||||
case NORTH:
|
||||
if (isTop && isOpen) y = 180;
|
||||
break;
|
||||
case SOUTH:
|
||||
y = (isTop && isOpen) ? 0 : 180;
|
||||
break;
|
||||
case WEST:
|
||||
y = (isTop && isOpen) ? 90 : 270;
|
||||
break;
|
||||
}
|
||||
BlockModelRotation rotation = BlockModelRotation.by(x, y);
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,28 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.WallBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.WallSide;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndWallBlock extends WallBlock implements BlockPatterned {
|
||||
public class EndWallBlock extends WallBlock implements BlockModelProvider {
|
||||
|
||||
private final Block parent;
|
||||
|
||||
|
@ -28,32 +35,60 @@ public class EndWallBlock extends WallBlock implements BlockPatterned {
|
|||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_WALL, parentId.getPath(), blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_WALL, parentId.getPath(), blockId.getPath());
|
||||
String path = blockId.getPath();
|
||||
Optional<String> pattern = Optional.empty();
|
||||
if (path.endsWith("_post")) {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_WALL_POST, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
if (block.contains("side_tall")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_WALL_SIDE_TALL, parentId.getPath(), blockId.getPath());
|
||||
if (path.endsWith("_side")) {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_WALL_SIDE, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
if (block.contains("side")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_WALL_SIDE, parentId.getPath(), blockId.getPath());
|
||||
if (path.endsWith("_side_tall")) {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_WALL_SIDE_TALL, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_WALL_POST, parentId.getPath(), blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_WALL;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation postId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_post");
|
||||
ResourceLocation sideId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_side");
|
||||
ResourceLocation sideTallId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_side_tall");
|
||||
registerBlockModel(postId, postId, blockState, modelCache);
|
||||
registerBlockModel(sideId, sideId, blockState, modelCache);
|
||||
registerBlockModel(sideTallId, sideTallId, blockState, modelCache);
|
||||
|
||||
ModelsHelper.MultiPartBuilder builder = ModelsHelper.MultiPartBuilder.create(stateDefinition);
|
||||
builder.part(sideId).setCondition(state -> state.getValue(NORTH_WALL) == WallSide.LOW).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(EAST_WALL) == WallSide.LOW)
|
||||
.setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(SOUTH_WALL) == WallSide.LOW)
|
||||
.setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideId).setCondition(state -> state.getValue(WEST_WALL) == WallSide.LOW)
|
||||
.setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideTallId).setCondition(state -> state.getValue(NORTH_WALL) == WallSide.TALL).setUVLock(true).add();
|
||||
builder.part(sideTallId).setCondition(state -> state.getValue(EAST_WALL) == WallSide.TALL)
|
||||
.setTransformation(BlockModelRotation.X0_Y90.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideTallId).setCondition(state -> state.getValue(SOUTH_WALL) == WallSide.TALL)
|
||||
.setTransformation(BlockModelRotation.X0_Y180.getRotation()).setUVLock(true).add();
|
||||
builder.part(sideTallId).setCondition(state -> state.getValue(WEST_WALL) == WallSide.TALL)
|
||||
.setTransformation(BlockModelRotation.X0_Y270.getRotation()).setUVLock(true).add();
|
||||
builder.part(postId).setCondition(state -> state.getValue(UP)).add();
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.WeightedPressurePlateBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndWeightedPlateBlock extends WeightedPressurePlateBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
public EndWeightedPlateBlock(Block source) {
|
||||
super(15, FabricBlockSettings.copyOf(source).noCollission().noOcclusion().requiresCorrectToolForDrops().strength(0.5F));
|
||||
this.parent = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
Optional<String> pattern;
|
||||
if (blockState.getValue(POWER) > 0) {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), resourceLocation.getPath());
|
||||
} else {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), resourceLocation.getPath());
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String state = blockState.getValue(POWER) > 0 ? "_down" : "_up";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + state);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createBlockSimple(modelId);
|
||||
}
|
||||
}
|
|
@ -1,55 +1,30 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.WoodButtonBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndWoodenButtonBlock extends EndButtonBlock {
|
||||
|
||||
public class EndWoodenButtonBlock extends WoodButtonBlock implements BlockPatterned {
|
||||
private final Block parent;
|
||||
|
||||
public EndWoodenButtonBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).strength(0.5F, 0.5F).noOcclusion());
|
||||
this.parent = source;
|
||||
super(source, FabricBlockSettings.copyOf(source).strength(0.5F, 0.5F).noOcclusion(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_BUTTON, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
if (block.contains("pressed")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_BUTTON_PRESSED, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_BUTTON, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_BUTTON;
|
||||
protected SoundEvent getSound(boolean clicked) {
|
||||
return clicked ? SoundEvents.WOODEN_BUTTON_CLICK_ON : SoundEvents.WOODEN_BUTTON_CLICK_OFF;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -26,13 +26,15 @@ import net.minecraft.world.level.material.Material;
|
|||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.registry.EndTags;
|
||||
|
||||
public abstract class FeatureSaplingBlock extends SaplingBlock implements IRenderTypeable, BlockPatterned {
|
||||
public abstract class FeatureSaplingBlock extends SaplingBlock implements IRenderTypeable, BlockModelProvider {
|
||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
||||
|
||||
public FeatureSaplingBlock() {
|
||||
|
@ -108,22 +110,13 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements IRende
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createBlockItem(resourceLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
if (block.contains("item")) {
|
||||
block = block.split("/")[1];
|
||||
return Patterns.createJson(Patterns.ITEM_BLOCK, block);
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_CROSS, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SAPLING;
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_CROSS, resourceLocation.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.io.Reader;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -42,7 +44,8 @@ import ru.betterend.blocks.BlockProperties;
|
|||
import ru.betterend.blocks.BlockProperties.PedestalState;
|
||||
import ru.betterend.blocks.InfusionPedestal;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.rituals.InfusionRitual;
|
||||
|
||||
|
@ -333,18 +336,55 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
|
|||
public int getAnalogOutputSignal(BlockState state, Level world, BlockPos pos) {
|
||||
return state.getValue(HAS_ITEM) ? 15 : 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, texture, texture);
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return getBlockModel(blockId, defaultBlockState());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
Map<String, String> textures = createTexturesMap();
|
||||
PedestalState state = blockState.getValue(STATE);
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
|
||||
switch (state) {
|
||||
case COLUMN_TOP: {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
|
||||
break;
|
||||
}
|
||||
case COLUMN: {
|
||||
pattern = Patterns.createJson(Patterns.BLOKC_PEDESTAL_COLUMN, textures);
|
||||
break;
|
||||
}
|
||||
case PEDESTAL_TOP: {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_TOP, textures);
|
||||
break;
|
||||
}
|
||||
case BOTTOM: {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_BOTTOM, textures);
|
||||
break;
|
||||
}
|
||||
case PILLAR: {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_PILLAR, textures);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
PedestalState state = blockState.getValue(STATE);
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + "_" + state);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createBlockSimple(modelId);
|
||||
}
|
||||
|
||||
protected Map<String, String> createTexturesMap() {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
||||
String name = blockId.getPath();
|
||||
Map<String, String> textures = new HashMap<String, String>() {
|
||||
return new HashMap<String, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put("%mod%", blockId.getNamespace() );
|
||||
|
@ -354,23 +394,6 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
|
|||
put("%bottom%", name + "_bottom");
|
||||
}
|
||||
};
|
||||
if (block.contains("column_top")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
|
||||
} else if (block.contains("column")) {
|
||||
return Patterns.createJson(Patterns.BLOKC_PEDESTAL_COLUMN, textures);
|
||||
} else if (block.contains("top")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_TOP, textures);
|
||||
} else if (block.contains("bottom")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_BOTTOM, textures);
|
||||
} else if (block.contains("pillar")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_PILLAR, textures);
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_PEDESTAL;
|
||||
}
|
||||
|
||||
static {
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class SimpleLeavesBlock extends BlockBaseNotFull implements IRenderTypeable {
|
||||
public SimpleLeavesBlock(MaterialColor color) {
|
||||
|
@ -35,23 +34,6 @@ public class SimpleLeavesBlock extends BlockBaseNotFull implements IRenderTypeab
|
|||
.isSuffocating((state, world, pos) -> false)
|
||||
.isViewBlocking((state, world, pos) -> false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, texture, texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, texture, texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_SIMPLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -28,10 +31,15 @@ import net.minecraft.world.level.material.FluidState;
|
|||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class StalactiteBlock extends BlockBaseNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, IRenderTypeable {
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
|
@ -192,19 +200,20 @@ public class StalactiteBlock extends BlockBaseNotFull implements SimpleWaterlogg
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_CROSS_SHADED, block);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_CROSS_SHADED, resourceLocation.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_STALACTITE;
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
BlockModelRotation rotation = blockState.getValue(IS_FLOOR) ? BlockModelRotation.X0_Y0 : BlockModelRotation.X180_Y0;
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
stateId.getPath() + "_" + blockState.getValue(SIZE));
|
||||
registerBlockModel(modelId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
|
||||
return false;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Vec3i;
|
||||
|
@ -15,9 +16,11 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.blocks.AuroraCrystalBlock;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.interfaces.IColorProvider;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class StoneLanternBlock extends EndLanternBlock implements IColorProvider {
|
||||
|
@ -61,24 +64,13 @@ public class StoneLanternBlock extends EndLanternBlock implements IColorProvider
|
|||
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
return state.getValue(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_STONE_LANTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||
if (block.contains("ceil")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_CEIL, texture, texture);
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_FLOOR, texture, texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
String block = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, block, block);
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
String blockName = resourceLocation.getPath();
|
||||
Optional<String> pattern = blockState.getValue(IS_FLOOR) ?
|
||||
Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_FLOOR, blockName, blockName) :
|
||||
Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_CEIL, blockName, blockName);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
||||
import net.minecraft.client.renderer.block.model.Variant;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -23,10 +32,11 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
|||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||
import ru.betterend.blocks.EndTerrainBlock;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class TripleTerrainBlock extends EndTerrainBlock {
|
||||
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||
|
@ -47,25 +57,7 @@ public class TripleTerrainBlock extends EndTerrainBlock {
|
|||
TripleShape shape = dir == Direction.UP ? TripleShape.BOTTOM : dir == Direction.DOWN ? TripleShape.TOP : TripleShape.MIDDLE;
|
||||
return this.defaultBlockState().setValue(SHAPE, shape);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
String name = Registry.BLOCK.getKey(this).getPath();
|
||||
if (block.endsWith("_middle")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, name + "_top", name + "_top");
|
||||
}
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("%top%", "betterend:block/" + name + "_top");
|
||||
map.put("%side%", "betterend:block/" + name + "_side");
|
||||
map.put("%bottom%", "minecraft:block/end_stone");
|
||||
return Patterns.createJson(Patterns.BLOCK_TOP_SIDE_BOTTOM, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_TRIPLE_ROTATED_TOP;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
TripleShape shape = state.getValue(SHAPE);
|
||||
|
@ -80,9 +72,7 @@ public class TripleTerrainBlock extends EndTerrainBlock {
|
|||
TripleShape shape = state.getValue(SHAPE);
|
||||
if (shape == TripleShape.BOTTOM) {
|
||||
super.randomTick(state, world, pos, random);
|
||||
return;
|
||||
}
|
||||
else if (random.nextInt(16) == 0) {
|
||||
} else if (random.nextInt(16) == 0) {
|
||||
boolean bottom = canStayBottom(world, pos);
|
||||
if (shape == TripleShape.TOP) {
|
||||
if (!bottom) {
|
||||
|
@ -93,11 +83,9 @@ public class TripleTerrainBlock extends EndTerrainBlock {
|
|||
boolean top = canStay(state, world, pos) || isMiddle(world.getBlockState(pos.above()));
|
||||
if (!top && !bottom) {
|
||||
world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState());
|
||||
}
|
||||
else if (top && !bottom) {
|
||||
} else if (top && !bottom) {
|
||||
world.setBlockAndUpdate(pos, state.setValue(SHAPE, TripleShape.BOTTOM));
|
||||
}
|
||||
else if (!top && bottom) {
|
||||
} else if (!top) {
|
||||
world.setBlockAndUpdate(pos, state.setValue(SHAPE, TripleShape.TOP));
|
||||
}
|
||||
}
|
||||
|
@ -109,16 +97,59 @@ public class TripleTerrainBlock extends EndTerrainBlock {
|
|||
BlockState blockState = world.getBlockState(blockPos);
|
||||
if (isMiddle(blockState)) {
|
||||
return true;
|
||||
}
|
||||
else if (blockState.getFluidState().getAmount() == 8) {
|
||||
} else if (blockState.getFluidState().getAmount() == 8) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return !blockState.isFaceSturdy(world, blockPos, Direction.UP);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isMiddle(BlockState state) {
|
||||
return state.is(this) && state.getValue(SHAPE) == TripleShape.MIDDLE;
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return getBlockModel(blockId, defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
String name = resourceLocation.getPath();
|
||||
Optional<String> pattern;
|
||||
if (isMiddle(blockState)) {
|
||||
pattern = Patterns.createBlockSimple(name + "_top");
|
||||
} else {
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%top%", "betterend:block/" + name + "_top");
|
||||
textures.put("%side%", "betterend:block/" + name + "_side");
|
||||
textures.put("%bottom%", "minecraft:block/end_stone");
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_TOP_SIDE_BOTTOM, textures);
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
boolean isMiddle = isMiddle(blockState);
|
||||
String middle = isMiddle ? "_middle" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + middle);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
if (isMiddle) {
|
||||
List<Variant> variants = Lists.newArrayList();
|
||||
for (BlockModelRotation rotation : BlockModelRotation.values()) {
|
||||
variants.add(new Variant(modelId, rotation.getRotation(), false, 1));
|
||||
}
|
||||
return new MultiVariant(variants);
|
||||
} else if (blockState.getValue(SHAPE) == TripleShape.TOP) {
|
||||
return new MultiVariant(Lists.newArrayList(
|
||||
new Variant(modelId, BlockModelRotation.X180_Y0.getRotation(), false, 1),
|
||||
new Variant(modelId, BlockModelRotation.X180_Y90.getRotation(), false, 1),
|
||||
new Variant(modelId, BlockModelRotation.X180_Y180.getRotation(), false, 1),
|
||||
new Variant(modelId, BlockModelRotation.X180_Y270.getRotation(), false, 1)
|
||||
));
|
||||
}
|
||||
return ModelsHelper.createRandomTopModel(modelId);
|
||||
}
|
||||
|
||||
protected boolean isMiddle(BlockState blockState) {
|
||||
return blockState.is(this) && blockState.getValue(SHAPE) == TripleShape.MIDDLE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import ru.betterend.blocks.basis.EndStairsBlock;
|
|||
import ru.betterend.blocks.basis.EndTrapdoorBlock;
|
||||
import ru.betterend.blocks.basis.EndWoodenPlateBlock;
|
||||
import ru.betterend.item.EndArmorItem;
|
||||
import ru.betterend.item.PatternedItem;
|
||||
import ru.betterend.item.ModelProviderItem;
|
||||
import ru.betterend.item.tool.EndAxeItem;
|
||||
import ru.betterend.item.tool.EndHammerItem;
|
||||
import ru.betterend.item.tool.EndHoeItem;
|
||||
|
@ -120,8 +120,8 @@ public class MetalMaterial {
|
|||
bulb_lantern = EndBlocks.registerBlock(name + "_bulb_lantern", new BulbVineLanternBlock(lanternProperties));
|
||||
bulb_lantern_colored = new ColoredMaterial(BulbVineLanternColoredBlock::new, bulb_lantern, false);
|
||||
|
||||
nugget = EndItems.registerItem(name + "_nugget", new PatternedItem(itemSettings));
|
||||
ingot = EndItems.registerItem(name + "_ingot", new PatternedItem(itemSettings));
|
||||
nugget = EndItems.registerItem(name + "_nugget", new ModelProviderItem(itemSettings));
|
||||
ingot = EndItems.registerItem(name + "_ingot", new ModelProviderItem(itemSettings));
|
||||
|
||||
shovelHead = EndItems.registerItem(name + "_shovel_head");
|
||||
pickaxeHead = EndItems.registerItem(name + "_pickaxe_head");
|
||||
|
|
|
@ -13,7 +13,7 @@ import ru.betterend.blocks.basis.EndPillarBlock;
|
|||
import ru.betterend.blocks.basis.EndSlabBlock;
|
||||
import ru.betterend.blocks.basis.EndStairsBlock;
|
||||
import ru.betterend.blocks.basis.EndStoneButtonBlock;
|
||||
import ru.betterend.blocks.basis.EndStonelateBlock;
|
||||
import ru.betterend.blocks.basis.EndStonePlateBlock;
|
||||
import ru.betterend.blocks.basis.EndWallBlock;
|
||||
import ru.betterend.blocks.basis.StoneLanternBlock;
|
||||
import ru.betterend.recipe.CraftingRecipes;
|
||||
|
@ -54,7 +54,7 @@ public class StoneMaterial {
|
|||
slab = EndBlocks.registerBlock(name + "_slab", new EndSlabBlock(stone));
|
||||
wall = EndBlocks.registerBlock(name + "_wall", new EndWallBlock(stone));
|
||||
button = EndBlocks.registerBlock(name + "_button", new EndStoneButtonBlock(stone));
|
||||
pressure_plate = EndBlocks.registerBlock(name + "_plate", new EndStonelateBlock(stone));
|
||||
pressure_plate = EndBlocks.registerBlock(name + "_plate", new EndStonePlateBlock(stone));
|
||||
pedestal = EndBlocks.registerBlock(name + "_pedestal", new EndPedestal(stone));
|
||||
lantern = EndBlocks.registerBlock(name + "_lantern", new StoneLanternBlock(stone));
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package ru.betterend.client.models;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.BetterEnd;
|
||||
|
||||
import static net.minecraft.client.resources.model.ModelBakery.MISSING_MODEL_LOCATION;
|
||||
|
||||
public interface BlockModelProvider extends ItemModelProvider {
|
||||
default @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
Optional<String> pattern = Patterns.createBlockSimple(resourceLocation.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
default UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createBlockSimple(modelId);
|
||||
}
|
||||
|
||||
default void registerBlockModel(ResourceLocation stateId, ResourceLocation modelId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
if (!modelCache.containsKey(modelId)) {
|
||||
BlockModel model = getBlockModel(stateId, blockState);
|
||||
if (model != null) {
|
||||
model.name = modelId.toString();
|
||||
modelCache.put(modelId, model);
|
||||
} else {
|
||||
BetterEnd.LOGGER.warning("Error loading model: {}", modelId);
|
||||
modelCache.put(modelId, modelCache.get(MISSING_MODEL_LOCATION));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package ru.betterend.client.models;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ItemModelProvider {
|
||||
default BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createItemModel(resourceLocation.getPath());
|
||||
}
|
||||
}
|
148
src/main/java/ru/betterend/client/models/ModelsHelper.java
Normal file
148
src/main/java/ru/betterend/client/models/ModelsHelper.java
Normal file
|
@ -0,0 +1,148 @@
|
|||
package ru.betterend.client.models;
|
||||
|
||||
import com.google.common.collect.*;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
||||
import net.minecraft.client.renderer.block.model.Variant;
|
||||
import net.minecraft.client.renderer.block.model.multipart.Condition;
|
||||
import net.minecraft.client.renderer.block.model.multipart.MultiPart;
|
||||
import net.minecraft.client.renderer.block.model.multipart.Selector;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ModelsHelper {
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
public static BlockModel fromPattern(Optional<String> pattern) {
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
|
||||
public static BlockModel createItemModel(String name) {
|
||||
Optional<String> pattern = Patterns.createItemGenerated("item/" + name);
|
||||
return fromPattern(pattern);
|
||||
}
|
||||
|
||||
public static BlockModel createHandheldItem(String name) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_HANDHELD, "item/" + name);
|
||||
return fromPattern(pattern);
|
||||
}
|
||||
|
||||
public static BlockModel createBlockItem(ResourceLocation resourceLocation) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_BLOCK, resourceLocation.getPath());
|
||||
return fromPattern(pattern);
|
||||
}
|
||||
|
||||
public static BlockModel createBlockEmpty(ResourceLocation resourceLocation) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_EMPTY, resourceLocation.getPath());
|
||||
return fromPattern(pattern);
|
||||
}
|
||||
|
||||
public static MultiVariant createMultiVariant(ResourceLocation resourceLocation, Transformation transform, boolean uvLock) {
|
||||
Variant variant = new Variant(resourceLocation, transform, uvLock, 1);
|
||||
return new MultiVariant(Lists.newArrayList(variant));
|
||||
}
|
||||
|
||||
public static MultiVariant createBlockSimple(ResourceLocation resourceLocation) {
|
||||
return createMultiVariant(resourceLocation, Transformation.identity(), false);
|
||||
}
|
||||
|
||||
public static MultiVariant createFacingModel(ResourceLocation resourceLocation, Direction facing, boolean uvLock, boolean inverted) {
|
||||
if (inverted) {
|
||||
facing = facing.getOpposite();
|
||||
}
|
||||
BlockModelRotation rotation = BlockModelRotation.by(0, (int) facing.toYRot());
|
||||
return createMultiVariant(resourceLocation, rotation.getRotation(), uvLock);
|
||||
}
|
||||
|
||||
public static MultiVariant createRotatedModel(ResourceLocation resourceLocation, Direction.Axis axis) {
|
||||
BlockModelRotation rotation = BlockModelRotation.X0_Y0;
|
||||
switch (axis) {
|
||||
case X: rotation = BlockModelRotation.X90_Y90; break;
|
||||
case Z: rotation = BlockModelRotation.X90_Y0; break;
|
||||
}
|
||||
return createMultiVariant(resourceLocation, rotation.getRotation(), false);
|
||||
}
|
||||
|
||||
public static MultiVariant createRandomTopModel(ResourceLocation resourceLocation) {
|
||||
return new MultiVariant(Lists.newArrayList(
|
||||
new Variant(resourceLocation, Transformation.identity(), false, 1),
|
||||
new Variant(resourceLocation, BlockModelRotation.X0_Y90.getRotation(), false, 1),
|
||||
new Variant(resourceLocation, BlockModelRotation.X0_Y180.getRotation(), false, 1),
|
||||
new Variant(resourceLocation, BlockModelRotation.X0_Y270.getRotation(), false, 1)
|
||||
));
|
||||
}
|
||||
|
||||
public static class MultiPartBuilder {
|
||||
|
||||
private final static MultiPartBuilder BUILDER = new MultiPartBuilder();
|
||||
|
||||
public static MultiPartBuilder create(StateDefinition<Block, BlockState> stateDefinition) {
|
||||
BUILDER.stateDefinition = stateDefinition;
|
||||
BUILDER.modelParts.clear();
|
||||
return BUILDER;
|
||||
}
|
||||
|
||||
private final List<ModelPart> modelParts = Lists.newArrayList();
|
||||
private StateDefinition<Block, BlockState> stateDefinition;
|
||||
|
||||
private MultiPartBuilder() {}
|
||||
|
||||
public ModelPart part(ResourceLocation modelId) {
|
||||
return new ModelPart(modelId);
|
||||
}
|
||||
|
||||
public MultiPart build() {
|
||||
if (modelParts.size() > 0) {
|
||||
List<Selector> selectors = Lists.newArrayList();
|
||||
modelParts.forEach(modelPart -> {
|
||||
MultiVariant variant = createMultiVariant(modelPart.modelId, modelPart.transform, modelPart.uvLock);
|
||||
selectors.add(new Selector(modelPart.condition, variant));
|
||||
});
|
||||
modelParts.clear();
|
||||
return new MultiPart(stateDefinition, selectors);
|
||||
}
|
||||
throw new IllegalStateException("At least one model part need to be created.");
|
||||
}
|
||||
|
||||
public class ModelPart {
|
||||
private final ResourceLocation modelId;
|
||||
private Transformation transform = Transformation.identity();
|
||||
private Condition condition = Condition.TRUE;
|
||||
private boolean uvLock = false;
|
||||
|
||||
private ModelPart(ResourceLocation modelId) {
|
||||
this.modelId = modelId;
|
||||
}
|
||||
|
||||
public ModelPart setCondition(Function<BlockState, Boolean> condition) {
|
||||
this.condition = stateDefinition -> condition::apply;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModelPart setTransformation(Transformation transform) {
|
||||
this.transform = transform;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModelPart setUVLock(boolean value) {
|
||||
this.uvLock = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void add() {
|
||||
modelParts.add(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,162 +1,139 @@
|
|||
package ru.betterend.patterns;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import ru.betterend.BetterEnd;
|
||||
|
||||
public class Patterns {
|
||||
|
||||
//Blockstates
|
||||
public final static ResourceLocation STATE_SIMPLE = BetterEnd.makeID("patterns/blockstate/block.json");
|
||||
public final static ResourceLocation STATE_SLAB = BetterEnd.makeID("patterns/blockstate/slab.json");
|
||||
public final static ResourceLocation STATE_STAIRS = BetterEnd.makeID("patterns/blockstate/stairs.json");
|
||||
public final static ResourceLocation STATE_WALL = BetterEnd.makeID("patterns/blockstate/wall.json");
|
||||
public final static ResourceLocation STATE_FENCE = BetterEnd.makeID("patterns/blockstate/fence.json");
|
||||
public final static ResourceLocation STATE_BUTTON = BetterEnd.makeID("patterns/blockstate/button.json");
|
||||
public final static ResourceLocation STATE_PILLAR = BetterEnd.makeID("patterns/blockstate/pillar.json");
|
||||
public final static ResourceLocation STATE_PLATE = BetterEnd.makeID("patterns/blockstate/pressure_plate.json");
|
||||
public final static ResourceLocation STATE_PLATE_ROTATED = BetterEnd.makeID("patterns/blockstate/pressure_plate_rotated.json");
|
||||
public final static ResourceLocation STATE_DOOR = BetterEnd.makeID("patterns/blockstate/door.json");
|
||||
public final static ResourceLocation STATE_SAPLING = BetterEnd.makeID("patterns/blockstate/sapling.json");
|
||||
public final static ResourceLocation STATE_GATE = BetterEnd.makeID("patterns/blockstate/fence_gate.json");
|
||||
public final static ResourceLocation STATE_TRAPDOOR = BetterEnd.makeID("patterns/blockstate/trapdoor.json");
|
||||
public final static ResourceLocation STATE_LADDER = BetterEnd.makeID("patterns/blockstate/ladder.json");
|
||||
public final static ResourceLocation STATE_BARREL = BetterEnd.makeID("patterns/blockstate/barrel.json");
|
||||
public final static ResourceLocation STATE_PEDESTAL = BetterEnd.makeID("patterns/blockstate/pedestal.json");
|
||||
public final static ResourceLocation STATE_STONE_LANTERN = BetterEnd.makeID("patterns/blockstate/stone_lantern.json");
|
||||
public final static ResourceLocation STATE_DIRECT = BetterEnd.makeID("patterns/blockstate/direct.json");
|
||||
public final static ResourceLocation STATE_BULB_LANTERN = BetterEnd.makeID("patterns/blockstate/bulb_lantern.json");
|
||||
public final static ResourceLocation STATE_COMPOSTER = BetterEnd.makeID("patterns/blockstate/composter.json");
|
||||
public final static ResourceLocation STATE_BARS = BetterEnd.makeID("patterns/blockstate/bars.json");
|
||||
public final static ResourceLocation STATE_ANVIL = BetterEnd.makeID("patterns/blockstate/anvil.json");
|
||||
public final static ResourceLocation STATE_ANVIL_LONG = BetterEnd.makeID("patterns/blockstate/anvil_long.json");
|
||||
public final static ResourceLocation STATE_CHAIN = BetterEnd.makeID("patterns/blockstate/chain.json");
|
||||
public final static ResourceLocation STATE_CHANDELIER = BetterEnd.makeID("patterns/blockstate/chandelier.json");
|
||||
public final static ResourceLocation STATE_FURNACE = BetterEnd.makeID("patterns/blockstate/furnace.json");
|
||||
public final static ResourceLocation STATE_ROTATED_TOP = BetterEnd.makeID("patterns/blockstate/rotated_top.json");
|
||||
public final static ResourceLocation STATE_TRIPLE_ROTATED_TOP = BetterEnd.makeID("patterns/blockstate/triple_rotated_top.json");
|
||||
public final static ResourceLocation STATE_STALACTITE = BetterEnd.makeID("patterns/blockstate/stalactite.json");
|
||||
|
||||
//Models Block
|
||||
public final static ResourceLocation BLOCK_EMPTY = BetterEnd.makeID("patterns/block/empty.json");
|
||||
public final static ResourceLocation BLOCK_BASE = BetterEnd.makeID("patterns/block/block.json");
|
||||
public final static ResourceLocation BLOCK_SIDED = BetterEnd.makeID("patterns/block/block_sided.json");
|
||||
public final static ResourceLocation BLOCK_BOTTOM_TOP = BetterEnd.makeID("patterns/block/block_bottom_top.json");
|
||||
public final static ResourceLocation BLOCK_SLAB = BetterEnd.makeID("patterns/block/slab.json");
|
||||
public final static ResourceLocation BLOCK_STAIR = BetterEnd.makeID("patterns/block/stairs.json");
|
||||
public final static ResourceLocation BLOCK_STAIR_INNER = BetterEnd.makeID("patterns/block/inner_stairs.json");
|
||||
public final static ResourceLocation BLOCK_STAIR_OUTER = BetterEnd.makeID("patterns/block/outer_stairs.json");
|
||||
public final static ResourceLocation BLOCK_WALL_POST = BetterEnd.makeID("patterns/block/wall_post.json");
|
||||
public final static ResourceLocation BLOCK_WALL_SIDE = BetterEnd.makeID("patterns/block/wall_side.json");
|
||||
public final static ResourceLocation BLOCK_WALL_SIDE_TALL = BetterEnd.makeID("patterns/block/wall_side_tall.json");
|
||||
public final static ResourceLocation BLOCK_FENCE_POST = BetterEnd.makeID("patterns/block/fence_post.json");
|
||||
public final static ResourceLocation BLOCK_FENCE_SIDE = BetterEnd.makeID("patterns/block/fence_side.json");
|
||||
public final static ResourceLocation BLOCK_BUTTON = BetterEnd.makeID("patterns/block/button.json");
|
||||
public final static ResourceLocation BLOCK_BUTTON_PRESSED = BetterEnd.makeID("patterns/block/button_pressed.json");
|
||||
public final static ResourceLocation BLOCK_PILLAR = BetterEnd.makeID("patterns/block/pillar.json");
|
||||
public final static ResourceLocation BLOCK_PLATE_UP = BetterEnd.makeID("patterns/block/pressure_plate_up.json");
|
||||
public final static ResourceLocation BLOCK_PLATE_DOWN = BetterEnd.makeID("patterns/block/pressure_plate_down.json");
|
||||
public final static ResourceLocation BLOCK_DOOR_TOP = BetterEnd.makeID("patterns/block/door_top.json");
|
||||
public final static ResourceLocation BLOCK_DOOR_TOP_HINGE = BetterEnd.makeID("patterns/block/door_top_hinge.json");
|
||||
public final static ResourceLocation BLOCK_DOOR_BOTTOM = BetterEnd.makeID("patterns/block/door_bottom.json");
|
||||
public final static ResourceLocation BLOCK_DOOR_BOTTOM_HINGE = BetterEnd.makeID("patterns/block/door_bottom_hinge.json");
|
||||
public final static ResourceLocation BLOCK_CROSS = BetterEnd.makeID("patterns/block/cross.json");
|
||||
public final static ResourceLocation BLOCK_CROSS_SHADED = BetterEnd.makeID("patterns/block/cross_shaded.json");
|
||||
public final static ResourceLocation BLOCK_GATE_CLOSED = BetterEnd.makeID("patterns/block/fence_gate_closed.json");
|
||||
public final static ResourceLocation BLOCK_GATE_CLOSED_WALL = BetterEnd.makeID("patterns/block/wall_gate_closed.json");
|
||||
public final static ResourceLocation BLOCK_GATE_OPEN = BetterEnd.makeID("patterns/block/fence_gate_open.json");
|
||||
public final static ResourceLocation BLOCK_GATE_OPEN_WALL = BetterEnd.makeID("patterns/block/wall_gate_open.json");
|
||||
public final static ResourceLocation BLOCK_TRAPDOOR = BetterEnd.makeID("patterns/block/trapdoor.json");
|
||||
public final static ResourceLocation BLOCK_LADDER = BetterEnd.makeID("patterns/block/ladder.json");
|
||||
public final static ResourceLocation BLOCK_BARREL_OPEN = BetterEnd.makeID("patterns/block/barrel_open.json");
|
||||
public final static ResourceLocation BLOCK_PEDESTAL_DEFAULT = BetterEnd.makeID("patterns/block/pedestal_default.json");
|
||||
public final static ResourceLocation BLOKC_PEDESTAL_COLUMN = BetterEnd.makeID("patterns/block/pedestal_column.json");
|
||||
public final static ResourceLocation BLOCK_PEDESTAL_COLUMN_TOP = BetterEnd.makeID("patterns/block/pedestal_column_top.json");
|
||||
public final static ResourceLocation BLOCK_PEDESTAL_TOP = BetterEnd.makeID("patterns/block/pedestal_top.json");
|
||||
public final static ResourceLocation BLOCK_PEDESTAL_BOTTOM = BetterEnd.makeID("patterns/block/pedestal_bottom.json");
|
||||
public final static ResourceLocation BLOCK_PEDESTAL_PILLAR = BetterEnd.makeID("patterns/block/pedestal_pillar.json");
|
||||
public final static ResourceLocation BLOCK_BOOKSHELF = BetterEnd.makeID("patterns/block/bookshelf.json");
|
||||
public final static ResourceLocation BLOCK_STONE_LANTERN_CEIL = BetterEnd.makeID("patterns/block/stone_lantern_ceil.json");
|
||||
public final static ResourceLocation BLOCK_STONE_LANTERN_FLOOR = BetterEnd.makeID("patterns/block/stone_lantern_floor.json");
|
||||
public final static ResourceLocation BLOCK_BULB_LANTERN_FLOOR = BetterEnd.makeID("patterns/block/bulb_lantern_floor.json");
|
||||
public final static ResourceLocation BLOCK_BULB_LANTERN_CEIL = BetterEnd.makeID("patterns/block/bulb_lantern_ceil.json");
|
||||
public final static ResourceLocation BLOCK_PETAL_COLORED = BetterEnd.makeID("models/block/block_petal_colored.json");
|
||||
public final static ResourceLocation BLOCK_COMPOSTER = BetterEnd.makeID("patterns/block/composter.json");
|
||||
public final static ResourceLocation BLOCK_COLORED = BetterEnd.makeID("patterns/block/block_colored.json");
|
||||
public final static ResourceLocation BLOCK_BARS_POST = BetterEnd.makeID("patterns/block/bars_post.json");
|
||||
public final static ResourceLocation BLOCK_BARS_SIDE = BetterEnd.makeID("patterns/block/bars_side.json");
|
||||
public final static ResourceLocation BLOCK_ANVIL = BetterEnd.makeID("patterns/block/anvil.json");
|
||||
public final static ResourceLocation BLOCK_CHAIN = BetterEnd.makeID("patterns/block/chain.json");
|
||||
public final static ResourceLocation BLOCK_CHANDELIER_FLOOR = BetterEnd.makeID("patterns/block/chandelier_floor.json");
|
||||
public final static ResourceLocation BLOCK_CHANDELIER_WALL = BetterEnd.makeID("patterns/block/chandelier_wall.json");
|
||||
public final static ResourceLocation BLOCK_CHANDELIER_CEIL = BetterEnd.makeID("patterns/block/chandelier_ceil.json");
|
||||
public final static ResourceLocation BLOCK_FURNACE = BetterEnd.makeID("patterns/block/furnace.json");
|
||||
public final static ResourceLocation BLOCK_FURNACE_GLOW = BetterEnd.makeID("patterns/block/furnace_glow.json");
|
||||
public final static ResourceLocation BLOCK_TOP_SIDE_BOTTOM = BetterEnd.makeID("patterns/block/top_side_bottom.json");
|
||||
public final static ResourceLocation BLOCK_PATH = BetterEnd.makeID("patterns/block/path.json");
|
||||
|
||||
//Models Item
|
||||
public final static ResourceLocation ITEM_WALL = BetterEnd.makeID("patterns/item/pattern_wall.json");
|
||||
public final static ResourceLocation ITEM_FENCE = BetterEnd.makeID("patterns/item/pattern_fence.json");
|
||||
public final static ResourceLocation ITEM_BUTTON = BetterEnd.makeID("patterns/item/pattern_button.json");
|
||||
public final static ResourceLocation ITEM_CHEST = BetterEnd.makeID("patterns/item/pattern_chest.json");
|
||||
public final static ResourceLocation ITEM_BLOCK = BetterEnd.makeID("patterns/item/pattern_block_item.json");
|
||||
public final static ResourceLocation ITEM_GENERATED = BetterEnd.makeID("patterns/item/pattern_item_generated.json");
|
||||
public final static ResourceLocation ITEM_HANDHELD = BetterEnd.makeID("patterns/item/pattern_item_handheld.json");
|
||||
public final static ResourceLocation ITEM_SPAWN_EGG = BetterEnd.makeID("patterns/item/pattern_item_spawn_egg.json");
|
||||
|
||||
public static String createItemGenerated(String name) {
|
||||
return createJson(ITEM_GENERATED, name);
|
||||
}
|
||||
|
||||
public static String createJson(Reader data, String parent, String block) {
|
||||
try (BufferedReader buffer = new BufferedReader(data)) {
|
||||
return buffer.lines().collect(Collectors.joining())
|
||||
.replace("%parent%", parent)
|
||||
.replace("%block%", block);
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String createJson(ResourceLocation patternId, String parent, String block) {
|
||||
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
|
||||
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
|
||||
return createJson(new InputStreamReader(input, StandardCharsets.UTF_8), parent, block);
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String createJson(ResourceLocation patternId, String texture) {
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%texture%", texture);
|
||||
return createJson(patternId, textures);
|
||||
}
|
||||
|
||||
public static String createJson(ResourceLocation patternId, Map<String, String> textures) {
|
||||
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
|
||||
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
|
||||
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))
|
||||
.lines().collect(Collectors.joining());
|
||||
for (Entry<String, String> texture : textures.entrySet()) {
|
||||
json = json.replace(texture.getKey(), texture.getValue());
|
||||
}
|
||||
return json;
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
package ru.betterend.client.models;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import ru.betterend.BetterEnd;
|
||||
|
||||
public class Patterns {
|
||||
//Block Models
|
||||
public final static ResourceLocation BLOCK_EMPTY = BetterEnd.makeID("patterns/block/empty.json");
|
||||
public final static ResourceLocation BLOCK_BASE = BetterEnd.makeID("patterns/block/block.json");
|
||||
public final static ResourceLocation BLOCK_SIDED = BetterEnd.makeID("patterns/block/block_sided.json");
|
||||
public final static ResourceLocation BLOCK_BOTTOM_TOP = BetterEnd.makeID("patterns/block/block_bottom_top.json");
|
||||
public final static ResourceLocation BLOCK_SLAB = BetterEnd.makeID("patterns/block/slab.json");
|
||||
public final static ResourceLocation BLOCK_STAIR = BetterEnd.makeID("patterns/block/stairs.json");
|
||||
public final static ResourceLocation BLOCK_STAIR_INNER = BetterEnd.makeID("patterns/block/inner_stairs.json");
|
||||
public final static ResourceLocation BLOCK_STAIR_OUTER = BetterEnd.makeID("patterns/block/outer_stairs.json");
|
||||
public final static ResourceLocation BLOCK_WALL_POST = BetterEnd.makeID("patterns/block/wall_post.json");
|
||||
public final static ResourceLocation BLOCK_WALL_SIDE = BetterEnd.makeID("patterns/block/wall_side.json");
|
||||
public final static ResourceLocation BLOCK_WALL_SIDE_TALL = BetterEnd.makeID("patterns/block/wall_side_tall.json");
|
||||
public final static ResourceLocation BLOCK_FENCE_POST = BetterEnd.makeID("patterns/block/fence_post.json");
|
||||
public final static ResourceLocation BLOCK_FENCE_SIDE = BetterEnd.makeID("patterns/block/fence_side.json");
|
||||
public final static ResourceLocation BLOCK_BUTTON = BetterEnd.makeID("patterns/block/button.json");
|
||||
public final static ResourceLocation BLOCK_BUTTON_PRESSED = BetterEnd.makeID("patterns/block/button_pressed.json");
|
||||
public final static ResourceLocation BLOCK_PILLAR = BetterEnd.makeID("patterns/block/pillar.json");
|
||||
public final static ResourceLocation BLOCK_PLATE_UP = BetterEnd.makeID("patterns/block/pressure_plate_up.json");
|
||||
public final static ResourceLocation BLOCK_PLATE_DOWN = BetterEnd.makeID("patterns/block/pressure_plate_down.json");
|
||||
public final static ResourceLocation BLOCK_DOOR_TOP = BetterEnd.makeID("patterns/block/door_top.json");
|
||||
public final static ResourceLocation BLOCK_DOOR_TOP_HINGE = BetterEnd.makeID("patterns/block/door_top_hinge.json");
|
||||
public final static ResourceLocation BLOCK_DOOR_BOTTOM = BetterEnd.makeID("patterns/block/door_bottom.json");
|
||||
public final static ResourceLocation BLOCK_DOOR_BOTTOM_HINGE = BetterEnd.makeID("patterns/block/door_bottom_hinge.json");
|
||||
public final static ResourceLocation BLOCK_CROSS = BetterEnd.makeID("patterns/block/cross.json");
|
||||
public final static ResourceLocation BLOCK_CROSS_SHADED = BetterEnd.makeID("patterns/block/cross_shaded.json");
|
||||
public final static ResourceLocation BLOCK_GATE_CLOSED = BetterEnd.makeID("patterns/block/fence_gate_closed.json");
|
||||
public final static ResourceLocation BLOCK_GATE_CLOSED_WALL = BetterEnd.makeID("patterns/block/wall_gate_closed.json");
|
||||
public final static ResourceLocation BLOCK_GATE_OPEN = BetterEnd.makeID("patterns/block/fence_gate_open.json");
|
||||
public final static ResourceLocation BLOCK_GATE_OPEN_WALL = BetterEnd.makeID("patterns/block/wall_gate_open.json");
|
||||
public final static ResourceLocation BLOCK_TRAPDOOR = BetterEnd.makeID("patterns/block/trapdoor.json");
|
||||
public final static ResourceLocation BLOCK_LADDER = BetterEnd.makeID("patterns/block/ladder.json");
|
||||
public final static ResourceLocation BLOCK_BARREL_OPEN = BetterEnd.makeID("patterns/block/barrel_open.json");
|
||||
public final static ResourceLocation BLOCK_PEDESTAL_DEFAULT = BetterEnd.makeID("patterns/block/pedestal_default.json");
|
||||
public final static ResourceLocation BLOKC_PEDESTAL_COLUMN = BetterEnd.makeID("patterns/block/pedestal_column.json");
|
||||
public final static ResourceLocation BLOCK_PEDESTAL_COLUMN_TOP = BetterEnd.makeID("patterns/block/pedestal_column_top.json");
|
||||
public final static ResourceLocation BLOCK_PEDESTAL_TOP = BetterEnd.makeID("patterns/block/pedestal_top.json");
|
||||
public final static ResourceLocation BLOCK_PEDESTAL_BOTTOM = BetterEnd.makeID("patterns/block/pedestal_bottom.json");
|
||||
public final static ResourceLocation BLOCK_PEDESTAL_PILLAR = BetterEnd.makeID("patterns/block/pedestal_pillar.json");
|
||||
public final static ResourceLocation BLOCK_BOOKSHELF = BetterEnd.makeID("patterns/block/bookshelf.json");
|
||||
public final static ResourceLocation BLOCK_STONE_LANTERN_CEIL = BetterEnd.makeID("patterns/block/stone_lantern_ceil.json");
|
||||
public final static ResourceLocation BLOCK_STONE_LANTERN_FLOOR = BetterEnd.makeID("patterns/block/stone_lantern_floor.json");
|
||||
public final static ResourceLocation BLOCK_BULB_LANTERN_FLOOR = BetterEnd.makeID("patterns/block/bulb_lantern_floor.json");
|
||||
public final static ResourceLocation BLOCK_BULB_LANTERN_CEIL = BetterEnd.makeID("patterns/block/bulb_lantern_ceil.json");
|
||||
public final static ResourceLocation BLOCK_PETAL_COLORED = BetterEnd.makeID("models/block/block_petal_colored.json");
|
||||
public final static ResourceLocation BLOCK_COMPOSTER = BetterEnd.makeID("patterns/block/composter.json");
|
||||
public final static ResourceLocation BLOCK_COLORED = BetterEnd.makeID("patterns/block/block_colored.json");
|
||||
public final static ResourceLocation BLOCK_BARS_POST = BetterEnd.makeID("patterns/block/bars_post.json");
|
||||
public final static ResourceLocation BLOCK_BARS_SIDE = BetterEnd.makeID("patterns/block/bars_side.json");
|
||||
public final static ResourceLocation BLOCK_ANVIL = BetterEnd.makeID("patterns/block/anvil.json");
|
||||
public final static ResourceLocation BLOCK_CHAIN = BetterEnd.makeID("patterns/block/chain.json");
|
||||
public final static ResourceLocation BLOCK_CHANDELIER_FLOOR = BetterEnd.makeID("patterns/block/chandelier_floor.json");
|
||||
public final static ResourceLocation BLOCK_CHANDELIER_WALL = BetterEnd.makeID("patterns/block/chandelier_wall.json");
|
||||
public final static ResourceLocation BLOCK_CHANDELIER_CEIL = BetterEnd.makeID("patterns/block/chandelier_ceil.json");
|
||||
public final static ResourceLocation BLOCK_FURNACE = BetterEnd.makeID("patterns/block/furnace.json");
|
||||
public final static ResourceLocation BLOCK_FURNACE_LIT = BetterEnd.makeID("patterns/block/furnace_glow.json");
|
||||
public final static ResourceLocation BLOCK_TOP_SIDE_BOTTOM = BetterEnd.makeID("patterns/block/top_side_bottom.json");
|
||||
public final static ResourceLocation BLOCK_PATH = BetterEnd.makeID("patterns/block/path.json");
|
||||
|
||||
//Item Models
|
||||
public final static ResourceLocation ITEM_WALL = BetterEnd.makeID("patterns/item/pattern_wall.json");
|
||||
public final static ResourceLocation ITEM_FENCE = BetterEnd.makeID("patterns/item/pattern_fence.json");
|
||||
public final static ResourceLocation ITEM_BUTTON = BetterEnd.makeID("patterns/item/pattern_button.json");
|
||||
public final static ResourceLocation ITEM_CHEST = BetterEnd.makeID("patterns/item/pattern_chest.json");
|
||||
public final static ResourceLocation ITEM_BLOCK = BetterEnd.makeID("patterns/item/pattern_block_item.json");
|
||||
public final static ResourceLocation ITEM_GENERATED = BetterEnd.makeID("patterns/item/pattern_item_generated.json");
|
||||
public final static ResourceLocation ITEM_HANDHELD = BetterEnd.makeID("patterns/item/pattern_item_handheld.json");
|
||||
public final static ResourceLocation ITEM_SPAWN_EGG = BetterEnd.makeID("patterns/item/pattern_item_spawn_egg.json");
|
||||
|
||||
public static Optional<String> createItemGenerated(String name) {
|
||||
return createJson(ITEM_GENERATED, name);
|
||||
}
|
||||
|
||||
public static Optional<String> createBlockSimple(String name) {
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, name, name);
|
||||
}
|
||||
public static Optional<String> createBlockPillar(String name) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PILLAR, name, name);
|
||||
}
|
||||
|
||||
public static String createJson(Reader data, String parent, String block) {
|
||||
try (BufferedReader buffer = new BufferedReader(data)) {
|
||||
return buffer.lines().collect(Collectors.joining())
|
||||
.replace("%parent%", parent)
|
||||
.replace("%block%", block);
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<String> createJson(ResourceLocation patternId, String parent, String block) {
|
||||
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
|
||||
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
|
||||
return Optional.ofNullable(createJson(new InputStreamReader(input, StandardCharsets.UTF_8), parent, block));
|
||||
} catch (Exception ex) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<String> createJson(ResourceLocation patternId, String texture) {
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%texture%", texture);
|
||||
return createJson(patternId, textures);
|
||||
}
|
||||
|
||||
public static Optional<String> createJson(ResourceLocation patternId, Map<String, String> textures) {
|
||||
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
|
||||
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
|
||||
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))
|
||||
.lines().collect(Collectors.joining());
|
||||
for (Entry<String, String> texture : textures.entrySet()) {
|
||||
json = json.replace(texture.getKey(), texture.getValue());
|
||||
}
|
||||
return Optional.of(json);
|
||||
} catch (Exception ex) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package ru.betterend.events;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public interface PlayerAdvancementsCallback {
|
||||
|
||||
Event<PlayerAdvancementsCallback> PLAYER_ADVANCEMENT_COMPLETE = EventFactory.createArrayBacked(PlayerAdvancementsCallback.class, callbacks -> (player, advancement, criterionName) -> {
|
||||
for (PlayerAdvancementsCallback event : callbacks) {
|
||||
event.onAdvancementComplete(player, advancement, criterionName);
|
||||
}
|
||||
});
|
||||
|
||||
void onAdvancementComplete(ServerPlayer player, Advancement advancement, String criterionName);
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package ru.betterend.events;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public final class PlayerAdvancementsEvents {
|
||||
|
||||
public static Event<AdvancementComplete> PLAYER_ADVENCEMENT_COMPLETE = EventFactory.createArrayBacked(AdvancementComplete.class, callbacks -> (player, advancement, criterionName) -> {
|
||||
for (AdvancementComplete event : callbacks) {
|
||||
event.onAdvancementComplete(player, advancement, criterionName);
|
||||
}
|
||||
});
|
||||
|
||||
public interface AdvancementComplete {
|
||||
void onAdvancementComplete(ServerPlayer player, Advancement advancement, String criterionName);
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ import net.minecraft.world.item.Items;
|
|||
import net.minecraft.world.item.UseAnim;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class DrinkItem extends PatternedItem {
|
||||
public class DrinkItem extends ModelProviderItem {
|
||||
public DrinkItem(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
public class EnchantedPetalItem extends PatternedItem {
|
||||
import java.util.Optional;
|
||||
|
||||
public class EnchantedPetalItem extends ModelProviderItem {
|
||||
public EnchantedPetalItem() {
|
||||
super(EndItems.makeItemSettings().rarity(Rarity.RARE).stacksTo(16));
|
||||
}
|
||||
|
@ -16,7 +21,7 @@ public class EnchantedPetalItem extends PatternedItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String name) {
|
||||
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/hydralux_petal");
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createItemModel("hydralux_petal");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
|
@ -11,10 +9,13 @@ import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
|||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.ArmorMaterial;
|
||||
import ru.betterend.patterns.Patterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.ItemModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndArmorItem extends ArmorItem implements Patterned {
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EndArmorItem extends ArmorItem implements ItemModelProvider {
|
||||
|
||||
protected static final UUID[] ARMOR_MODIFIER_UUID_PER_SLOT = new UUID[] {
|
||||
UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"),
|
||||
|
@ -47,9 +48,4 @@ public class EndArmorItem extends ArmorItem implements Patterned {
|
|||
}
|
||||
defaultModifiers.put(attribute, modifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String name) {
|
||||
return Patterns.createItemGenerated(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,17 +3,14 @@ package ru.betterend.item;
|
|||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.FishBucketItem;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import ru.betterend.patterns.Patterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.ItemModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
public class EndBucketItem extends FishBucketItem implements Patterned {
|
||||
import java.util.Optional;
|
||||
|
||||
public class EndBucketItem extends FishBucketItem implements ItemModelProvider {
|
||||
public EndBucketItem(EntityType<?> type) {
|
||||
super(type, Fluids.WATER, EndItems.makeItemSettings().stacksTo(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String name) {
|
||||
return Patterns.createJson(Patterns.ITEM_GENERATED, name);
|
||||
}
|
||||
}
|
||||
|
|
14
src/main/java/ru/betterend/item/EndDiscItem.java
Normal file
14
src/main/java/ru/betterend/item/EndDiscItem.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.item.RecordItem;
|
||||
import ru.betterend.client.models.ItemModelProvider;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class EndDiscItem extends RecordItem implements ItemModelProvider {
|
||||
public EndDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) {
|
||||
super(comparatorOutput, sound, settings);
|
||||
}
|
||||
}
|
|
@ -1,17 +1,23 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.SpawnEggItem;
|
||||
import ru.betterend.patterns.Patterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.ItemModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndSpawnEggItem extends SpawnEggItem implements Patterned {
|
||||
import java.util.Optional;
|
||||
|
||||
public class EndSpawnEggItem extends SpawnEggItem implements ItemModelProvider {
|
||||
public EndSpawnEggItem(EntityType<?> type, int primaryColor, int secondaryColor, Properties settings) {
|
||||
super(type, primaryColor, secondaryColor, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String name) {
|
||||
return Patterns.createJson(Patterns.ITEM_SPAWN_EGG, name);
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_SPAWN_EGG, resourceLocation.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package ru.betterend.item;
|
|||
import net.minecraft.world.item.Rarity;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
public class EternalCrystalItem extends PatternedItem {
|
||||
public class EternalCrystalItem extends ModelProviderItem {
|
||||
public EternalCrystalItem() {
|
||||
super(EndItems.makeItemSettings().stacksTo(16).rarity(Rarity.EPIC));
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import ru.betterend.registry.EndItems;
|
|||
import ru.betterend.util.LangUtil;
|
||||
import vazkii.patchouli.api.PatchouliAPI;
|
||||
|
||||
public class GuideBookItem extends PatternedItem {
|
||||
public class GuideBookItem extends ModelProviderItem {
|
||||
public final static ResourceLocation BOOK_ID = BetterEnd.makeID("guidebook");
|
||||
public static final Item GUIDE_BOOK = EndItems.registerItem(BOOK_ID, new GuideBookItem());
|
||||
|
||||
|
|
21
src/main/java/ru/betterend/item/ModelProviderItem.java
Normal file
21
src/main/java/ru/betterend/item/ModelProviderItem.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import ru.betterend.client.models.ItemModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class ModelProviderItem extends Item implements ItemModelProvider {
|
||||
public ModelProviderItem(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createItemModel(resourceLocation.getPath());
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.item.RecordItem;
|
||||
import ru.betterend.patterns.Patterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
|
||||
public class PatternedDiscItem extends RecordItem implements Patterned {
|
||||
public PatternedDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) {
|
||||
super(comparatorOutput, sound, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String name) {
|
||||
return Patterns.createJson(Patterns.ITEM_GENERATED, name);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import ru.betterend.patterns.Patterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
|
||||
public class PatternedItem extends Item implements Patterned {
|
||||
public PatternedItem(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String name) {
|
||||
return Patterns.createItemGenerated(name);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,8 @@ package ru.betterend.item.tool;
|
|||
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.AxeItem;
|
||||
|
@ -9,10 +11,13 @@ import net.minecraft.world.item.Item;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.betterend.patterns.Patterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.ItemModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndAxeItem extends AxeItem implements DynamicAttributeTool, Patterned {
|
||||
import java.util.Optional;
|
||||
|
||||
public class EndAxeItem extends AxeItem implements DynamicAttributeTool, ItemModelProvider {
|
||||
public EndAxeItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
@ -26,7 +31,7 @@ public class EndAxeItem extends AxeItem implements DynamicAttributeTool, Pattern
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String name) {
|
||||
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createHandheldItem(resourceLocation.getPath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ru.betterend.item.tool;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
@ -9,7 +10,9 @@ import com.google.common.collect.Sets;
|
|||
|
||||
import io.netty.util.internal.ThreadLocalRandom;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
|
@ -26,11 +29,12 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import ru.betterend.patterns.Patterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.ItemModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.registry.EndTags;
|
||||
|
||||
public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, Patterned {
|
||||
public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, ItemModelProvider {
|
||||
public final static UUID ATTACK_KNOCKBACK_MODIFIER_ID = Mth.createInsecureUUID(ThreadLocalRandom.current());
|
||||
|
||||
private final Multimap<Attribute, AttributeModifier> attributeModifiers;
|
||||
|
@ -57,9 +61,7 @@ public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, P
|
|||
|
||||
@Override
|
||||
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
|
||||
stack.hurtAndBreak(1, attacker, ((entity) -> {
|
||||
entity.broadcastBreakEvent(EquipmentSlot.MAINHAND);
|
||||
}));
|
||||
stack.hurtAndBreak(1, attacker, ((entity) -> entity.broadcastBreakEvent(EquipmentSlot.MAINHAND)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -67,9 +69,7 @@ public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, P
|
|||
@Override
|
||||
public boolean mineBlock(ItemStack stack, Level world, BlockState state, BlockPos pos, LivingEntity miner) {
|
||||
if (state.getDestroySpeed(world, pos) != 0.0F) {
|
||||
stack.hurtAndBreak(1, miner, ((entity) -> {
|
||||
entity.broadcastBreakEvent(EquipmentSlot.MAINHAND);
|
||||
}));
|
||||
stack.hurtAndBreak(1, miner, ((entity) -> entity.broadcastBreakEvent(EquipmentSlot.MAINHAND)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -81,13 +81,13 @@ public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, P
|
|||
return this.getTier().getSpeed() * 2.0F;
|
||||
}
|
||||
if (isCorrectToolForDrops(state)) {
|
||||
float mult = 1.0F;
|
||||
float mult;
|
||||
if (state.is(Blocks.DIAMOND_BLOCK) || state.is(Blocks.EMERALD_BLOCK) || state.is(Blocks.LAPIS_BLOCK) || state.is(Blocks.REDSTONE_BLOCK)) {
|
||||
mult = this.getTier().getSpeed();
|
||||
} else {
|
||||
mult = this.getTier().getSpeed() / 2.0F;
|
||||
}
|
||||
return mult > 1.0F ? mult : 1.0F;
|
||||
return Math.max(mult, 1.0F);
|
||||
}
|
||||
return 1.0F;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, P
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String name) {
|
||||
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createHandheldItem(resourceLocation.getPath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
package ru.betterend.item.tool;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.HoeItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import ru.betterend.patterns.Patterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.ItemModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndHoeItem extends HoeItem implements Patterned {
|
||||
import java.util.Optional;
|
||||
|
||||
public class EndHoeItem extends HoeItem implements ItemModelProvider {
|
||||
public EndHoeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String name) {
|
||||
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createHandheldItem(resourceLocation.getPath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
|||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl;
|
||||
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl.Entry;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -12,10 +14,13 @@ import net.minecraft.world.item.PickaxeItem;
|
|||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.betterend.patterns.Patterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.ItemModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool, Patterned {
|
||||
import java.util.Optional;
|
||||
|
||||
public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool, ItemModelProvider {
|
||||
public EndPickaxeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
@ -23,22 +28,22 @@ public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool,
|
|||
@Override
|
||||
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
|
||||
if (tag.equals(FabricToolTags.PICKAXES)) {
|
||||
return this.getTier().getLevel();
|
||||
return getTier().getLevel();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
if (this.getTier().getLevel() > 2 && state.getMaterial().equals(Blocks.END_STONE.defaultBlockState().getMaterial())) {
|
||||
return this.speed * 3;
|
||||
if (getTier().getLevel() > 2 && state.getMaterial().equals(Blocks.END_STONE.defaultBlockState().getMaterial())) {
|
||||
return speed * 3;
|
||||
}
|
||||
Entry entry = ToolManagerImpl.entryNullable(state.getBlock());
|
||||
return (entry != null && entry.getMiningLevel(FabricToolTags.PICKAXES) >= 0) ? this.speed : super.getDestroySpeed(stack, state);
|
||||
return (entry != null && entry.getMiningLevel(FabricToolTags.PICKAXES) >= 0) ? speed : super.getDestroySpeed(stack, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String name) {
|
||||
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createHandheldItem(resourceLocation.getPath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
|||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl;
|
||||
import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl.Entry;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -11,10 +13,13 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.item.ShovelItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.betterend.patterns.Patterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.ItemModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, Patterned {
|
||||
import java.util.Optional;
|
||||
|
||||
public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, ItemModelProvider {
|
||||
public EndShovelItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
@ -30,11 +35,11 @@ public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, P
|
|||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
Entry entry = ToolManagerImpl.entryNullable(state.getBlock());
|
||||
return (entry != null && entry.getMiningLevel(FabricToolTags.SHOVELS) >= 0) ? this.speed : super.getDestroySpeed(stack, state);
|
||||
return (entry != null && entry.getMiningLevel(FabricToolTags.SHOVELS) >= 0) ? speed : super.getDestroySpeed(stack, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String name) {
|
||||
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createHandheldItem(resourceLocation.getPath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
package ru.betterend.item.tool;
|
||||
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.SwordItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import ru.betterend.patterns.Patterned;
|
||||
import ru.betterend.patterns.Patterns;
|
||||
import ru.betterend.client.models.ItemModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndSwordItem extends SwordItem implements DynamicAttributeTool, Patterned {
|
||||
import java.util.Optional;
|
||||
|
||||
public class EndSwordItem extends SwordItem implements DynamicAttributeTool, ItemModelProvider {
|
||||
public EndSwordItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String name) {
|
||||
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createHandheldItem(resourceLocation.getPath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,63 +1,103 @@
|
|||
package ru.betterend.mixin.client;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.renderer.block.BlockModelShaper;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.multipart.MultiPart;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.patterns.Patterned;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ItemModelProvider;
|
||||
import ru.betterend.world.generator.GeneratorOptions;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(ModelBakery.class)
|
||||
public class ModelLoaderMixin {
|
||||
public abstract class ModelLoaderMixin {
|
||||
@Final
|
||||
@Shadow
|
||||
private ResourceManager resourceManager;
|
||||
|
||||
@Inject(method = "loadBlockModel", at = @At("HEAD"), cancellable = true)
|
||||
private void be_loadModelPattern(ResourceLocation id, CallbackInfoReturnable<BlockModel> info) {
|
||||
if (id.getNamespace().equals(BetterEnd.MOD_ID)) {
|
||||
ResourceLocation modelId = new ResourceLocation(id.getNamespace(), "models/" + id.getPath() + ".json");
|
||||
BlockModel model;
|
||||
try (Resource resource = this.resourceManager.getResource(modelId)) {
|
||||
Reader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8);
|
||||
model = BlockModel.fromStream(reader);
|
||||
model.name = id.toString();
|
||||
info.setReturnValue(model);
|
||||
} catch (Exception ex) {
|
||||
String[] data = id.getPath().split("/");
|
||||
if (data.length > 1) {
|
||||
ResourceLocation itemId = new ResourceLocation(id.getNamespace(), data[1]);
|
||||
Optional<Block> block = Registry.BLOCK.getOptional(itemId);
|
||||
if (block.isPresent()) {
|
||||
if (block.get() instanceof Patterned) {
|
||||
Patterned patterned = (Patterned) block.get();
|
||||
model = this.be_getModel(data, id, patterned);
|
||||
info.setReturnValue(model);
|
||||
@Final
|
||||
@Shadow
|
||||
private Map<ResourceLocation, UnbakedModel> unbakedCache;
|
||||
|
||||
@Shadow
|
||||
protected abstract void cacheAndQueueDependencies(ResourceLocation resourceLocation, UnbakedModel unbakedModel);
|
||||
|
||||
@Inject(method = "loadModel", at = @At("HEAD"), cancellable = true)
|
||||
private void be_loadModels(ResourceLocation resourceLocation, CallbackInfo info) {
|
||||
if (resourceLocation instanceof ModelResourceLocation) {
|
||||
String modId = resourceLocation.getNamespace();
|
||||
String path = resourceLocation.getPath();
|
||||
ResourceLocation clearLoc = new ResourceLocation(modId, path);
|
||||
ModelResourceLocation modelId = (ModelResourceLocation) resourceLocation;
|
||||
if ("inventory".equals(modelId.getVariant())) {
|
||||
ResourceLocation itemLoc = new ResourceLocation(modId, "item/" + path);
|
||||
ResourceLocation itemModelLoc = new ResourceLocation(modId, "models/" + itemLoc.getPath() + ".json");
|
||||
if (!resourceManager.hasResource(itemModelLoc)) {
|
||||
Item item = Registry.ITEM.get(clearLoc);
|
||||
ItemModelProvider modelProvider = null;
|
||||
if (item instanceof ItemModelProvider) {
|
||||
modelProvider = (ItemModelProvider) item;
|
||||
} else if (item instanceof BlockItem) {
|
||||
Block block = Registry.BLOCK.get(clearLoc);
|
||||
if (block instanceof ItemModelProvider) {
|
||||
modelProvider = (ItemModelProvider) block;
|
||||
}
|
||||
} else {
|
||||
Optional<Item> item = Registry.ITEM.getOptional(itemId);
|
||||
if (item.isPresent() && item.get() instanceof Patterned) {
|
||||
Patterned patterned = (Patterned) item.get();
|
||||
model = this.be_getModel(data, id, patterned);
|
||||
info.setReturnValue(model);
|
||||
}
|
||||
if (modelProvider != null) {
|
||||
BlockModel model = modelProvider.getItemModel(clearLoc);
|
||||
if (model != null) {
|
||||
model.name = itemLoc.toString();
|
||||
cacheAndQueueDependencies(modelId, model);
|
||||
unbakedCache.put(itemLoc, model);
|
||||
} else {
|
||||
BetterEnd.LOGGER.warning("Error loading model: {}", itemLoc);
|
||||
}
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ResourceLocation stateLoc = new ResourceLocation(modId, "blockstates/" + path + ".json");
|
||||
if (!resourceManager.hasResource(stateLoc)) {
|
||||
Block block = Registry.BLOCK.get(clearLoc);
|
||||
if (block instanceof BlockModelProvider) {
|
||||
List<BlockState> possibleStates = block.getStateDefinition().getPossibleStates();
|
||||
Optional<BlockState> possibleState = possibleStates.stream()
|
||||
.filter(state -> modelId.equals(BlockModelShaper.stateToModelLocation(clearLoc, state)))
|
||||
.findFirst();
|
||||
if (possibleState.isPresent()) {
|
||||
UnbakedModel modelVariant = ((BlockModelProvider) block).getModelVariant(modelId, possibleState.get(), unbakedCache);
|
||||
if (modelVariant != null) {
|
||||
if (modelVariant instanceof MultiPart) {
|
||||
possibleStates.forEach(state -> {
|
||||
ResourceLocation stateId = BlockModelShaper.stateToModelLocation(clearLoc, state);
|
||||
cacheAndQueueDependencies(stateId, modelVariant);
|
||||
});
|
||||
} else {
|
||||
cacheAndQueueDependencies(modelId, modelVariant);
|
||||
}
|
||||
} else {
|
||||
BetterEnd.LOGGER.warning("Error loading variant: {}", modelId);
|
||||
}
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,23 +105,6 @@ public class ModelLoaderMixin {
|
|||
}
|
||||
}
|
||||
|
||||
private BlockModel be_getModel(String[] data, ResourceLocation id, Patterned patterned) {
|
||||
String pattern;
|
||||
if (id.getPath().contains("item")) {
|
||||
pattern = patterned.getModelPattern(id.getPath());
|
||||
} else {
|
||||
if (data.length > 2) {
|
||||
pattern = patterned.getModelPattern(data[2]);
|
||||
} else {
|
||||
pattern = patterned.getModelPattern(data[1]);
|
||||
}
|
||||
}
|
||||
BlockModel model = BlockModel.fromString(pattern);
|
||||
model.name = id.toString();
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "loadModel", ordinal = 2, at = @At(value = "INVOKE"))
|
||||
public ResourceLocation be_switchModel(ResourceLocation id) {
|
||||
if (GeneratorOptions.changeChorusPlant() && id.getNamespace().equals("minecraft") && id.getPath().startsWith("blockstates/") && id.getPath().contains("chorus") && !id.getPath().contains("custom_")) {
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
package ru.betterend.mixin.client;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
|
||||
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 com.google.gson.Gson;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModelDefinition;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
|
||||
@Mixin(BlockModelDefinition.class)
|
||||
public abstract class ModelVariantMapMixin {
|
||||
|
||||
@Inject(method = "fromStream", at = @At("HEAD"), cancellable = true)
|
||||
private static void be_deserializeBlockState(BlockModelDefinition.Context context, Reader reader, CallbackInfoReturnable<BlockModelDefinition> info) {
|
||||
Block block = context.getDefinition().any().getBlock();
|
||||
if (block instanceof BlockPatterned) {
|
||||
String pattern = ((BlockPatterned) block).getStatesPattern(reader);
|
||||
Gson gson = ContextGsonAccessor.class.cast(context).getGson();
|
||||
BlockModelDefinition map = GsonHelper.fromJson(gson, new StringReader(pattern), BlockModelDefinition.class);
|
||||
info.setReturnValue(map);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package ru.betterend.mixin.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.At.Shift;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.FallbackResourceManager;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.patterns.BlockPatterned;
|
||||
|
||||
@Mixin(FallbackResourceManager.class)
|
||||
public abstract class NamespaceResourceManagerMixin {
|
||||
|
||||
@Shadow
|
||||
public abstract Resource getResource(ResourceLocation id);
|
||||
|
||||
@Inject(method = "getResources", cancellable = true, at = @At(
|
||||
value = "NEW",
|
||||
target = "java/io/FileNotFoundException",
|
||||
shift = Shift.BEFORE))
|
||||
public void be_getStatesPattern(ResourceLocation id, CallbackInfoReturnable<List<Resource>> info) {
|
||||
if (id.getNamespace().equals(BetterEnd.MOD_ID)) {
|
||||
String[] data = id.getPath().split("/");
|
||||
if (data.length > 1) {
|
||||
ResourceLocation blockId = BetterEnd.makeID(data[1].replace(".json", ""));
|
||||
Block block = Registry.BLOCK.get(blockId);
|
||||
if (block instanceof BlockPatterned) {
|
||||
ResourceLocation stateId = ((BlockPatterned) block).statePatternId();
|
||||
try {
|
||||
List<Resource> resources = Lists.newArrayList();
|
||||
Resource stateRes = this.getResource(stateId);
|
||||
resources.add(stateRes);
|
||||
info.setReturnValue(resources);
|
||||
} catch (Exception ex) {
|
||||
BetterEnd.LOGGER.catching(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.server.PlayerAdvancements;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import ru.betterend.events.PlayerAdvancementsEvents;
|
||||
import ru.betterend.events.PlayerAdvancementsCallback;
|
||||
|
||||
@Mixin(PlayerAdvancements.class)
|
||||
public abstract class PlayerAdvancementsMixin {
|
||||
|
@ -22,6 +22,6 @@ public abstract class PlayerAdvancementsMixin {
|
|||
target = "Lnet/minecraft/advancements/AdvancementRewards;grant(Lnet/minecraft/server/level/ServerPlayer;)V",
|
||||
shift = Shift.AFTER))
|
||||
public void be_award(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> info) {
|
||||
PlayerAdvancementsEvents.PLAYER_ADVENCEMENT_COMPLETE.invoker().onAdvancementComplete(player, advancement, criterionName);
|
||||
PlayerAdvancementsCallback.PLAYER_ADVANCEMENT_COMPLETE.invoker().onAdvancementComplete(player, advancement, criterionName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package ru.betterend.patterns;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public interface BlockPatterned extends Patterned {
|
||||
default String getStatesPattern(Reader data) {
|
||||
return null;
|
||||
}
|
||||
default ResourceLocation statePatternId() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package ru.betterend.patterns;
|
||||
|
||||
public interface Patterned {
|
||||
default String getModelPattern(String name) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -11,23 +11,7 @@ import net.minecraft.world.level.block.Blocks;
|
|||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.*;
|
||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||
import ru.betterend.blocks.basis.EndCropBlock;
|
||||
import ru.betterend.blocks.basis.EndFurnaceBlock;
|
||||
import ru.betterend.blocks.basis.EndLeavesBlock;
|
||||
import ru.betterend.blocks.basis.EndOreBlock;
|
||||
import ru.betterend.blocks.basis.EndPillarBlock;
|
||||
import ru.betterend.blocks.basis.EndSlabBlock;
|
||||
import ru.betterend.blocks.basis.EndStairsBlock;
|
||||
import ru.betterend.blocks.basis.EndUnderwaterWallPlantBlock;
|
||||
import ru.betterend.blocks.basis.EndWallPlantBlock;
|
||||
import ru.betterend.blocks.basis.FurBlock;
|
||||
import ru.betterend.blocks.basis.SimpleLeavesBlock;
|
||||
import ru.betterend.blocks.basis.StalactiteBlock;
|
||||
import ru.betterend.blocks.basis.StoneLanternBlock;
|
||||
import ru.betterend.blocks.basis.TripleTerrainBlock;
|
||||
import ru.betterend.blocks.basis.VineBlock;
|
||||
import ru.betterend.blocks.basis.WallMushroomBlock;
|
||||
import ru.betterend.blocks.basis.*;
|
||||
import ru.betterend.blocks.complex.ColoredMaterial;
|
||||
import ru.betterend.blocks.complex.CrystalSubblocksMaterial;
|
||||
import ru.betterend.blocks.complex.MetalMaterial;
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package ru.betterend.registry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockSource;
|
||||
|
@ -20,42 +17,19 @@ import net.minecraft.world.entity.EquipmentSlot;
|
|||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.food.Foods;
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.ShovelItem;
|
||||
import net.minecraft.world.item.SpawnEggItem;
|
||||
import net.minecraft.world.item.SwordItem;
|
||||
import net.minecraft.world.item.TieredItem;
|
||||
import net.minecraft.world.item.Tiers;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.block.DispenserBlock;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.config.Configs;
|
||||
import ru.betterend.item.ArmoredElytra;
|
||||
import ru.betterend.item.CrystaliteBoots;
|
||||
import ru.betterend.item.CrystaliteChestplate;
|
||||
import ru.betterend.item.CrystaliteHelmet;
|
||||
import ru.betterend.item.CrystaliteLeggings;
|
||||
import ru.betterend.item.DrinkItem;
|
||||
import ru.betterend.item.EnchantedPetalItem;
|
||||
import ru.betterend.item.EndArmorItem;
|
||||
import ru.betterend.item.EndBucketItem;
|
||||
import ru.betterend.item.EndSpawnEggItem;
|
||||
import ru.betterend.item.EternalCrystalItem;
|
||||
import ru.betterend.item.PatternedDiscItem;
|
||||
import ru.betterend.item.PatternedItem;
|
||||
import ru.betterend.item.*;
|
||||
import ru.betterend.item.material.EndArmorMaterial;
|
||||
import ru.betterend.item.material.EndToolMaterial;
|
||||
import ru.betterend.item.tool.EndAxeItem;
|
||||
import ru.betterend.item.tool.EndHammerItem;
|
||||
import ru.betterend.item.tool.EndHoeItem;
|
||||
import ru.betterend.item.tool.EndPickaxeItem;
|
||||
import ru.betterend.item.tool.EndShovelItem;
|
||||
import ru.betterend.item.tool.EndSwordItem;
|
||||
import ru.betterend.item.tool.*;
|
||||
import ru.betterend.tab.CreativeTabs;
|
||||
import ru.betterend.util.TagHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EndItems {
|
||||
private static final List<Item> MOD_BLOCKS = Lists.newArrayList();
|
||||
private static final List<Item> MOD_ITEMS = Lists.newArrayList();
|
||||
|
@ -143,11 +117,11 @@ public class EndItems {
|
|||
public final static Item UMBRELLA_CLUSTER_JUICE = registerDrink("umbrella_cluster_juice", 5, 0.7F);
|
||||
|
||||
public static Item registerDisc(String name, int power, SoundEvent sound) {
|
||||
return registerItem(BetterEnd.makeID(name), new PatternedDiscItem(power, sound, makeItemSettings()));
|
||||
return registerItem(BetterEnd.makeID(name), new EndDiscItem(power, sound, makeItemSettings()));
|
||||
}
|
||||
|
||||
public static Item registerItem(String name) {
|
||||
return registerItem(BetterEnd.makeID(name), new PatternedItem(makeItemSettings()));
|
||||
return registerItem(BetterEnd.makeID(name), new ModelProviderItem(makeItemSettings()));
|
||||
}
|
||||
|
||||
public static Item registerItem(String name, Item item) {
|
||||
|
@ -233,7 +207,7 @@ public class EndItems {
|
|||
}
|
||||
|
||||
public static Item registerFood(String name, FoodProperties foodComponent) {
|
||||
return registerItem(name, new PatternedItem(makeItemSettings().food(foodComponent)));
|
||||
return registerItem(name, new ModelProviderItem(makeItemSettings().food(foodComponent)));
|
||||
}
|
||||
|
||||
public static Item registerDrink(String name) {
|
||||
|
|
|
@ -27,7 +27,7 @@ import net.minecraft.world.level.block.LeavesBlock;
|
|||
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderConfiguration;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.EndTerrainBlock;
|
||||
import ru.betterend.blocks.basis.EndTerrainBlock;
|
||||
import ru.betterend.blocks.basis.PedestalBlock;
|
||||
import ru.betterend.blocks.basis.SimpleLeavesBlock;
|
||||
import ru.betterend.blocks.basis.VineBlock;
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "betterend:block/violecite"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"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 }
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"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%_0", "y": 270 },
|
||||
"destruction=1,facing=north": { "model": "betterend:pattern/%block%/%block%_0", "y": 180 },
|
||||
"destruction=1,facing=south": { "model": "betterend:pattern/%block%/%block%_0" },
|
||||
"destruction=1,facing=west": { "model": "betterend:pattern/%block%/%block%_0", "y": 90 },
|
||||
|
||||
"destruction=2,facing=east": { "model": "betterend:pattern/%block%/%block%_0", "y": 270 },
|
||||
"destruction=2,facing=north": { "model": "betterend:pattern/%block%/%block%_0", "y": 180 },
|
||||
"destruction=2,facing=south": { "model": "betterend:pattern/%block%/%block%_0" },
|
||||
"destruction=2,facing=west": { "model": "betterend:pattern/%block%/%block%_0", "y": 90 },
|
||||
|
||||
"destruction=3,facing=east": { "model": "betterend:pattern/%block%/%block%_1", "y": 270 },
|
||||
"destruction=3,facing=north": { "model": "betterend:pattern/%block%/%block%_1", "y": 180 },
|
||||
"destruction=3,facing=south": { "model": "betterend:pattern/%block%/%block%_1" },
|
||||
"destruction=3,facing=west": { "model": "betterend:pattern/%block%/%block%_1", "y": 90 },
|
||||
|
||||
"destruction=4,facing=east": { "model": "betterend:pattern/%block%/%block%_1", "y": 270 },
|
||||
"destruction=4,facing=north": { "model": "betterend:pattern/%block%/%block%_1", "y": 180 },
|
||||
"destruction=4,facing=south": { "model": "betterend:pattern/%block%/%block%_1" },
|
||||
"destruction=4,facing=west": { "model": "betterend:pattern/%block%/%block%_1", "y": 90 },
|
||||
|
||||
"destruction=5,facing=east": { "model": "betterend:pattern/%block%/%block%_1", "y": 270 },
|
||||
"destruction=5,facing=north": { "model": "betterend:pattern/%block%/%block%_1", "y": 180 },
|
||||
"destruction=5,facing=south": { "model": "betterend:pattern/%block%/%block%_1" },
|
||||
"destruction=5,facing=west": { "model": "betterend:pattern/%block%/%block%_1", "y": 90 },
|
||||
|
||||
"destruction=6,facing=east": { "model": "betterend:pattern/%block%/%block%_2", "y": 270 },
|
||||
"destruction=6,facing=north": { "model": "betterend:pattern/%block%/%block%_2", "y": 180 },
|
||||
"destruction=6,facing=south": { "model": "betterend:pattern/%block%/%block%_2" },
|
||||
"destruction=6,facing=west": { "model": "betterend:pattern/%block%/%block%_2", "y": 90 },
|
||||
|
||||
"destruction=7,facing=east": { "model": "betterend:pattern/%block%/%block%_2", "y": 270 },
|
||||
"destruction=7,facing=north": { "model": "betterend:pattern/%block%/%block%_2", "y": 180 },
|
||||
"destruction=7,facing=south": { "model": "betterend:pattern/%block%/%block%_2" },
|
||||
"destruction=7,facing=west": { "model": "betterend:pattern/%block%/%block%_2", "y": 90 },
|
||||
|
||||
"destruction=8,facing=east": { "model": "betterend:pattern/%block%/%block%_2", "y": 270 },
|
||||
"destruction=8,facing=north": { "model": "betterend:pattern/%block%/%block%_2", "y": 180 },
|
||||
"destruction=8,facing=south": { "model": "betterend:pattern/%block%/%block%_2" },
|
||||
"destruction=8,facing=west": { "model": "betterend:pattern/%block%/%block%_2", "y": 90 }
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"facing=down,open=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"x": 180
|
||||
},
|
||||
"facing=down,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_open",
|
||||
"x": 180
|
||||
},
|
||||
"facing=east,open=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"x": 90,
|
||||
"y": 90
|
||||
},
|
||||
"facing=east,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_open",
|
||||
"x": 90,
|
||||
"y": 90
|
||||
},
|
||||
"facing=north,open=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"x": 90
|
||||
},
|
||||
"facing=north,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_open",
|
||||
"x": 90
|
||||
},
|
||||
"facing=south,open=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"x": 90,
|
||||
"y": 180
|
||||
},
|
||||
"facing=south,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_open",
|
||||
"x": 90,
|
||||
"y": 180
|
||||
},
|
||||
"facing=up,open=false": {
|
||||
"model": "betterend:pattern/%block%"
|
||||
},
|
||||
"facing=up,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_open"
|
||||
},
|
||||
"facing=west,open=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"x": 90,
|
||||
"y": 270
|
||||
},
|
||||
"facing=west,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_open",
|
||||
"x": 90,
|
||||
"y": 270
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
{
|
||||
"multipart": [
|
||||
{
|
||||
"when": {
|
||||
"west": "false",
|
||||
"east": "false",
|
||||
"south": "false",
|
||||
"north": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "betterend:pattern/%block%/%block%_post"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"north": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "betterend:pattern/%block%/%block%_side"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"east": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "betterend:pattern/%block%/%block%_side",
|
||||
"uvlock": true,
|
||||
"y": 90
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"south": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "betterend:pattern/%block%/%block%_side",
|
||||
"uvlock": true,
|
||||
"y": 180
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"west": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "betterend:pattern/%block%/%block%_side",
|
||||
"uvlock": true,
|
||||
"y": 270
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "betterend:pattern/%block%"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"is_floor=false": { "model": "betterend:pattern/%block%/%block%_ceil" },
|
||||
"is_floor=true": { "model": "betterend:pattern/%block%/%block%_floor" }
|
||||
}
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"face=ceiling,facing=east,powered=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"x": 180,
|
||||
"y": 270
|
||||
},
|
||||
"face=ceiling,facing=east,powered=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_pressed",
|
||||
"x": 180,
|
||||
"y": 270
|
||||
},
|
||||
"face=ceiling,facing=north,powered=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"x": 180,
|
||||
"y": 180
|
||||
},
|
||||
"face=ceiling,facing=north,powered=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_pressed",
|
||||
"x": 180,
|
||||
"y": 180
|
||||
},
|
||||
"face=ceiling,facing=south,powered=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"x": 180
|
||||
},
|
||||
"face=ceiling,facing=south,powered=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_pressed",
|
||||
"x": 180
|
||||
},
|
||||
"face=ceiling,facing=west,powered=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"x": 180,
|
||||
"y": 90
|
||||
},
|
||||
"face=ceiling,facing=west,powered=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_pressed",
|
||||
"x": 180,
|
||||
"y": 90
|
||||
},
|
||||
"face=floor,facing=east,powered=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"y": 90
|
||||
},
|
||||
"face=floor,facing=east,powered=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_pressed",
|
||||
"y": 90
|
||||
},
|
||||
"face=floor,facing=north,powered=false": {
|
||||
"model": "betterend:pattern/%block%"
|
||||
},
|
||||
"face=floor,facing=north,powered=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_pressed"
|
||||
},
|
||||
"face=floor,facing=south,powered=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"y": 180
|
||||
},
|
||||
"face=floor,facing=south,powered=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_pressed",
|
||||
"y": 180
|
||||
},
|
||||
"face=floor,facing=west,powered=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"y": 270
|
||||
},
|
||||
"face=floor,facing=west,powered=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_pressed",
|
||||
"y": 270
|
||||
},
|
||||
"face=wall,facing=east,powered=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"uvlock": true,
|
||||
"x": 90,
|
||||
"y": 90
|
||||
},
|
||||
"face=wall,facing=east,powered=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_pressed",
|
||||
"uvlock": true,
|
||||
"x": 90,
|
||||
"y": 90
|
||||
},
|
||||
"face=wall,facing=north,powered=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"uvlock": true,
|
||||
"x": 90
|
||||
},
|
||||
"face=wall,facing=north,powered=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_pressed",
|
||||
"uvlock": true,
|
||||
"x": 90
|
||||
},
|
||||
"face=wall,facing=south,powered=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"uvlock": true,
|
||||
"x": 90,
|
||||
"y": 180
|
||||
},
|
||||
"face=wall,facing=south,powered=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_pressed",
|
||||
"uvlock": true,
|
||||
"x": 90,
|
||||
"y": 180
|
||||
},
|
||||
"face=wall,facing=west,powered=false": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"uvlock": true,
|
||||
"x": 90,
|
||||
"y": 270
|
||||
},
|
||||
"face=wall,facing=west,powered=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_pressed",
|
||||
"uvlock": true,
|
||||
"x": 90,
|
||||
"y": 270
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"axis=x": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"x": 90,
|
||||
"y": 90
|
||||
},
|
||||
"axis=y": {
|
||||
"model": "betterend:pattern/%block%"
|
||||
},
|
||||
"axis=z": {
|
||||
"model": "betterend:pattern/%block%",
|
||||
"x": 90
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"facing=up": { "model": "betterend:pattern/%block%/%block%_floor" },
|
||||
"facing=down": { "model": "betterend:pattern/%block%/%block%_ceil" },
|
||||
"facing=north": { "model": "betterend:pattern/%block%/%block%_wall", "y": 180 },
|
||||
"facing=south": { "model": "betterend:pattern/%block%/%block%_wall" },
|
||||
"facing=east": { "model": "betterend:pattern/%block%/%block%_wall", "y": 270 },
|
||||
"facing=west": { "model": "betterend:pattern/%block%/%block%_wall", "y": 90 }
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
{
|
||||
"multipart": [
|
||||
{
|
||||
"apply": {
|
||||
"model": "betterend:pattern/%block%"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"level": "1"
|
||||
},
|
||||
"apply": {
|
||||
"model": "minecraft:block/composter_contents1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"level": "2"
|
||||
},
|
||||
"apply": {
|
||||
"model": "minecraft:block/composter_contents2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"level": "3"
|
||||
},
|
||||
"apply": {
|
||||
"model": "minecraft:block/composter_contents3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"level": "4"
|
||||
},
|
||||
"apply": {
|
||||
"model": "minecraft:block/composter_contents4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"level": "5"
|
||||
},
|
||||
"apply": {
|
||||
"model": "minecraft:block/composter_contents5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"level": "6"
|
||||
},
|
||||
"apply": {
|
||||
"model": "minecraft:block/composter_contents6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"level": "7"
|
||||
},
|
||||
"apply": {
|
||||
"model": "minecraft:block/composter_contents7"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"level": "8"
|
||||
},
|
||||
"apply": {
|
||||
"model": "minecraft:block/composter_contents_ready"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "%block%"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
{
|
||||
"variants": {
|
||||
"facing=east,half=lower,hinge=left,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom"
|
||||
},
|
||||
"facing=east,half=lower,hinge=left,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom_hinge",
|
||||
"y": 90
|
||||
},
|
||||
"facing=east,half=lower,hinge=right,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom_hinge"
|
||||
},
|
||||
"facing=east,half=lower,hinge=right,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom",
|
||||
"y": 270
|
||||
},
|
||||
"facing=east,half=upper,hinge=left,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_top"
|
||||
},
|
||||
"facing=east,half=upper,hinge=left,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_top_hinge",
|
||||
"y": 90
|
||||
},
|
||||
"facing=east,half=upper,hinge=right,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_top_hinge"
|
||||
},
|
||||
"facing=east,half=upper,hinge=right,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_top",
|
||||
"y": 270
|
||||
},
|
||||
"facing=north,half=lower,hinge=left,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom",
|
||||
"y": 270
|
||||
},
|
||||
"facing=north,half=lower,hinge=left,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom_hinge"
|
||||
},
|
||||
"facing=north,half=lower,hinge=right,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom_hinge",
|
||||
"y": 270
|
||||
},
|
||||
"facing=north,half=lower,hinge=right,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom",
|
||||
"y": 180
|
||||
},
|
||||
"facing=north,half=upper,hinge=left,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_top",
|
||||
"y": 270
|
||||
},
|
||||
"facing=north,half=upper,hinge=left,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_top_hinge"
|
||||
},
|
||||
"facing=north,half=upper,hinge=right,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_top_hinge",
|
||||
"y": 270
|
||||
},
|
||||
"facing=north,half=upper,hinge=right,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_top",
|
||||
"y": 180
|
||||
},
|
||||
"facing=south,half=lower,hinge=left,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom",
|
||||
"y": 90
|
||||
},
|
||||
"facing=south,half=lower,hinge=left,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom_hinge",
|
||||
"y": 180
|
||||
},
|
||||
"facing=south,half=lower,hinge=right,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom_hinge",
|
||||
"y": 90
|
||||
},
|
||||
"facing=south,half=lower,hinge=right,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom"
|
||||
},
|
||||
"facing=south,half=upper,hinge=left,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_top",
|
||||
"y": 90
|
||||
},
|
||||
"facing=south,half=upper,hinge=left,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_top_hinge",
|
||||
"y": 180
|
||||
},
|
||||
"facing=south,half=upper,hinge=right,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_top_hinge",
|
||||
"y": 90
|
||||
},
|
||||
"facing=south,half=upper,hinge=right,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_top"
|
||||
},
|
||||
"facing=west,half=lower,hinge=left,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom",
|
||||
"y": 180
|
||||
},
|
||||
"facing=west,half=lower,hinge=left,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom_hinge",
|
||||
"y": 270
|
||||
},
|
||||
"facing=west,half=lower,hinge=right,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom_hinge",
|
||||
"y": 180
|
||||
},
|
||||
"facing=west,half=lower,hinge=right,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_bottom",
|
||||
"y": 90
|
||||
},
|
||||
"facing=west,half=upper,hinge=left,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_top",
|
||||
"y": 180
|
||||
},
|
||||
"facing=west,half=upper,hinge=left,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_top_hinge",
|
||||
"y": 270
|
||||
},
|
||||
"facing=west,half=upper,hinge=right,open=false": {
|
||||
"model": "betterend:pattern/%block%/%block%_top_hinge",
|
||||
"y": 180
|
||||
},
|
||||
"facing=west,half=upper,hinge=right,open=true": {
|
||||
"model": "betterend:pattern/%block%/%block%_top",
|
||||
"y": 90
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue