Change loading models (WIP)
This commit is contained in:
parent
8b94c91ea5
commit
87f8699dbb
64 changed files with 532 additions and 476 deletions
|
@ -7,7 +7,7 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||||
import ru.betterend.item.material.EndToolMaterial;
|
import ru.betterend.item.material.EndToolMaterial;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
public class AeterniumAnvil extends EndAnvilBlock {
|
public class AeterniumAnvil extends EndAnvilBlock {
|
||||||
|
|
|
@ -21,8 +21,8 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import ru.betterend.blocks.basis.EndLanternBlock;
|
import ru.betterend.blocks.basis.EndLanternBlock;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class BulbVineLanternBlock extends EndLanternBlock implements IRenderTypeable, BlockModelProvider {
|
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_CEIL = Block.box(4, 4, 4, 12, 16, 12);
|
||||||
|
|
|
@ -19,8 +19,8 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import ru.betterend.blocks.basis.AttachedBlock;
|
import ru.betterend.blocks.basis.AttachedBlock;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, BlockModelProvider {
|
public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, BlockModelProvider {
|
||||||
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
|
||||||
|
|
|
@ -27,8 +27,8 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderTypeable, BlockModelProvider {
|
public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderTypeable, BlockModelProvider {
|
||||||
public EmeraldIceBlock() {
|
public EmeraldIceBlock() {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndPathBlock extends BlockBaseNotFull {
|
public class EndPathBlock extends BlockBaseNotFull {
|
||||||
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 15, 16);
|
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 15, 16);
|
||||||
|
|
|
@ -8,7 +8,6 @@ import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.blocks.basis.PedestalBlock;
|
import ru.betterend.blocks.basis.PedestalBlock;
|
||||||
import ru.betterend.patterns.Patterns;
|
|
||||||
|
|
||||||
public class EndPedestal extends PedestalBlock {
|
public class EndPedestal extends PedestalBlock {
|
||||||
|
|
||||||
|
@ -17,10 +16,10 @@ public class EndPedestal extends PedestalBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelString(String block) {
|
protected Map<String, String> createTexturesMap() {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
||||||
String name = blockId.getPath();
|
String name = blockId.getPath();
|
||||||
Map<String, String> textures = new HashMap<String, String>() {
|
return new HashMap<String, String>() {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
{
|
{
|
||||||
put("%mod%", BetterEnd.MOD_ID );
|
put("%mod%", BetterEnd.MOD_ID );
|
||||||
|
@ -30,17 +29,5 @@ public class EndPedestal extends PedestalBlock {
|
||||||
put("%bottom%", name + "_polished");
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import ru.betterend.blocks.basis.BlockBase;
|
import ru.betterend.blocks.basis.BlockBase;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndTerrainBlock extends BlockBase {
|
public class EndTerrainBlock extends BlockBase {
|
||||||
private Block pathBlock;
|
private Block pathBlock;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.client.color.block.BlockColor;
|
||||||
import net.minecraft.client.color.item.ItemColor;
|
import net.minecraft.client.color.item.ItemColor;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import ru.betterend.interfaces.IColorProvider;
|
import ru.betterend.interfaces.IColorProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements IColorProvider {
|
public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements IColorProvider {
|
||||||
|
|
|
@ -25,8 +25,8 @@ import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IColorProvider;
|
import ru.betterend.interfaces.IColorProvider;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.noise.OpenSimplexNoise;
|
import ru.betterend.noise.OpenSimplexNoise;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable, BlockModelProvider, IColorProvider {
|
public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable, BlockModelProvider, IColorProvider {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import ru.betterend.blocks.basis.PedestalBlock;
|
import ru.betterend.blocks.basis.PedestalBlock;
|
||||||
import ru.betterend.patterns.Patterns;
|
|
||||||
|
|
||||||
public class PedestalVanilla extends PedestalBlock {
|
public class PedestalVanilla extends PedestalBlock {
|
||||||
|
|
||||||
|
@ -16,10 +15,10 @@ public class PedestalVanilla extends PedestalBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelString(String block) {
|
protected Map<String, String> createTexturesMap() {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
||||||
String name = blockId.getPath().replace("_block", "");
|
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;
|
private static final long serialVersionUID = 1L;
|
||||||
{
|
{
|
||||||
put("%mod%", blockId.getNamespace() );
|
put("%mod%", blockId.getNamespace() );
|
||||||
|
@ -29,17 +28,5 @@ public class PedestalVanilla extends PedestalBlock {
|
||||||
put("%bottom%", "polished_" + name);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.noise.OpenSimplexNoise;
|
import ru.betterend.noise.OpenSimplexNoise;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,9 @@ package ru.betterend.blocks.basis;
|
||||||
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
|
||||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.patterns.Patterns;
|
|
||||||
|
|
||||||
public class BarkBlock extends EndPillarBlock {
|
public class BarkBlock extends EndPillarBlock {
|
||||||
public BarkBlock(Properties settings) {
|
public BarkBlock(Properties settings) {
|
||||||
|
@ -21,8 +18,8 @@ public class BarkBlock extends EndPillarBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String createBlockPattern() {
|
protected String createBlockPattern(ResourceLocation blockId) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
blockId = Registry.BLOCK.getKey(this);
|
||||||
return Patterns.createJson(Patterns.BLOCK_BASE, getName(blockId), blockId.getPath());
|
return Patterns.createJson(Patterns.BLOCK_BASE, getName(blockId), blockId.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,15 @@ import java.io.Reader;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.mojang.math.Transformation;
|
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
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.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class BlockBase extends Block implements BlockModelProvider {
|
public class BlockBase extends Block implements BlockModelProvider {
|
||||||
public BlockBase(Properties settings) {
|
public BlockBase(Properties settings) {
|
||||||
|
|
|
@ -7,12 +7,9 @@ import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import com.mojang.math.Transformation;
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
import net.minecraft.client.renderer.block.model.MultiVariant;
|
||||||
import net.minecraft.client.renderer.block.model.Variant;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
@ -25,8 +22,9 @@ import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||||
import net.minecraft.world.level.material.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.blocks.BlockProperties;
|
import ru.betterend.blocks.BlockProperties;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
|
public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
|
||||||
private static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION;
|
private static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION;
|
||||||
|
@ -94,16 +92,25 @@ public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
int destruction = blockState.getValue(DESTRUCTION);
|
IntegerProperty destructionProperty = getDestructionProperty();
|
||||||
Map<String, String> map = Maps.newHashMap();
|
int destruction = blockState.getValue(destructionProperty);
|
||||||
map.put("%anvil%", blockId.getPath());
|
String name = blockId.getPath();
|
||||||
map.put("%top%", "_top_" + destruction);
|
Map<String, String> textures = Maps.newHashMap();
|
||||||
String pattern = Patterns.createJson(Patterns.BLOCK_ANVIL, map);
|
textures.put("%anvil%", name);
|
||||||
return BlockModelProvider.createBlockModel(blockId, pattern);
|
textures.put("%top%", name + "_top_" + destruction);
|
||||||
|
String pattern = Patterns.createJson(Patterns.BLOCK_ANVIL, textures);
|
||||||
|
return BlockModel.fromString(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
return BlockModelProvider.createFacingModel(resourceLocation, blockState.getValue(FACING));
|
IntegerProperty destructionProperty = getDestructionProperty();
|
||||||
|
int destruction = blockState.getValue(destructionProperty);
|
||||||
|
String modId = resourceLocation.getNamespace();
|
||||||
|
String modelId = "block/" + resourceLocation.getPath() + "_top_" + destruction;
|
||||||
|
ResourceLocation modelLocation = new ResourceLocation(modId, modelId);
|
||||||
|
System.out.println(modelLocation);
|
||||||
|
ModelsHelper.addBlockState(blockState, modelLocation);
|
||||||
|
return ModelsHelper.createFacingModel(modelLocation, blockState.getValue(FACING).getOpposite());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
import net.minecraft.client.renderer.block.model.MultiVariant;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
@ -28,8 +29,9 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import ru.betterend.blocks.entities.EBarrelBlockEntity;
|
import ru.betterend.blocks.entities.EBarrelBlockEntity;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.registry.EndBlockEntities;
|
import ru.betterend.registry.EndBlockEntities;
|
||||||
|
|
||||||
public class EndBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
public class EndBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
||||||
|
@ -125,13 +127,17 @@ public class EndBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
||||||
pattern = Patterns.createJson(Patterns.BLOCK_BOTTOM_TOP, texture, texture);
|
pattern = Patterns.createJson(Patterns.BLOCK_BOTTOM_TOP, texture, texture);
|
||||||
}
|
}
|
||||||
if (pattern != null) {
|
if (pattern != null) {
|
||||||
return BlockModelProvider.createBlockModel(blockId, pattern);
|
return BlockModel.fromString(pattern);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
return BlockModelProvider.createFacingModel(resourceLocation, blockState.getValue(FACING));
|
String open = blockState.getValue(OPEN) ? "_open" : "";
|
||||||
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
|
"block/" + resourceLocation.getPath() + open);
|
||||||
|
ModelsHelper.addBlockState(blockState, modelId);
|
||||||
|
return ModelsHelper.createFacingModel(modelId, blockState.getValue(FACING));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndBookshelfBlock extends BlockBase {
|
public class EndBookshelfBlock extends BlockBase {
|
||||||
public EndBookshelfBlock(Block source) {
|
public EndBookshelfBlock(Block source) {
|
||||||
|
|
|
@ -16,11 +16,12 @@ import net.minecraft.world.level.block.ChainBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.material.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndChainBlock extends ChainBlock implements BlockModelProvider, IRenderTypeable {
|
public class EndChainBlock extends ChainBlock implements BlockModelProvider, IRenderTypeable {
|
||||||
public EndChainBlock(MaterialColor color) {
|
public EndChainBlock(MaterialColor color) {
|
||||||
|
@ -59,14 +60,20 @@ public class EndChainBlock extends ChainBlock implements BlockModelProvider, IRe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
String pattern = Patterns.createJson(Patterns.BLOCK_CHAIN, blockId.getPath(), blockId.getPath());
|
String name = blockId.getPath();
|
||||||
return BlockModelProvider.createBlockModel(blockId, pattern);
|
String pattern = Patterns.createJson(Patterns.BLOCK_CHAIN, name, name);
|
||||||
|
if (pattern != null) {
|
||||||
|
return BlockModel.fromString(pattern);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
Direction.Axis axis = blockState.getValue(AXIS);
|
Direction.Axis axis = blockState.getValue(AXIS);
|
||||||
return BlockModelProvider.createRotatedModel(resourceLocation, axis);
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
|
"block/" + resourceLocation.getPath());
|
||||||
|
return ModelsHelper.createRotatedModel(modelId, axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,8 +15,9 @@ import net.minecraft.world.level.block.ChestBlock;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.registry.EndBlockEntities;
|
import ru.betterend.registry.EndBlockEntities;
|
||||||
|
|
||||||
public class EndChestBlock extends ChestBlock implements BlockModelProvider {
|
public class EndChestBlock extends ChestBlock implements BlockModelProvider {
|
||||||
|
@ -75,9 +76,4 @@ public class EndChestBlock extends ChestBlock implements BlockModelProvider {
|
||||||
String pattern = Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath());
|
String pattern = Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath());
|
||||||
return BlockModel.fromString(pattern);
|
return BlockModel.fromString(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
|
||||||
return BlockModelProvider.createBlockSimple(resourceLocation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.ComposterBlock;
|
import net.minecraft.world.level.block.ComposterBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndComposterBlock extends ComposterBlock implements BlockModelProvider {
|
public class EndComposterBlock extends ComposterBlock implements BlockModelProvider {
|
||||||
public EndComposterBlock(Block source) {
|
public EndComposterBlock(Block source) {
|
||||||
|
|
|
@ -15,8 +15,9 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.CraftingTableBlock;
|
import net.minecraft.world.level.block.CraftingTableBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndCraftingTableBlock extends CraftingTableBlock implements BlockModelProvider {
|
public class EndCraftingTableBlock extends CraftingTableBlock implements BlockModelProvider {
|
||||||
public EndCraftingTableBlock(Block source) {
|
public EndCraftingTableBlock(Block source) {
|
||||||
|
@ -79,9 +80,4 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockMo
|
||||||
});
|
});
|
||||||
return BlockModel.fromString(pattern);
|
return BlockModel.fromString(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
|
||||||
return BlockModelProvider.createBlockSimple(resourceLocation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockModelProvider {
|
public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockModelProvider {
|
||||||
public EndDoorBlock(Block source) {
|
public EndDoorBlock(Block source) {
|
||||||
|
|
|
@ -12,8 +12,8 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.FenceBlock;
|
import net.minecraft.world.level.block.FenceBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndFenceBlock extends FenceBlock implements BlockModelProvider {
|
public class EndFenceBlock extends FenceBlock implements BlockModelProvider {
|
||||||
private final Block parent;
|
private final Block parent;
|
||||||
|
|
|
@ -8,7 +8,10 @@ import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
|
import net.minecraft.client.renderer.block.model.MultiVariant;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.stats.Stats;
|
import net.minecraft.stats.Stats;
|
||||||
|
@ -24,16 +27,15 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import ru.betterend.blocks.entities.EFurnaceBlockEntity;
|
import ru.betterend.blocks.entities.EFurnaceBlockEntity;
|
||||||
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider, IRenderTypeable {
|
public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider, IRenderTypeable {
|
||||||
public EndFurnaceBlock(Block source) {
|
public EndFurnaceBlock(Block source) {
|
||||||
super(FabricBlockSettings.copyOf(source).luminance((state) -> {
|
super(FabricBlockSettings.copyOf(source).luminance(state -> state.getValue(LIT) ? 13 : 0));
|
||||||
return state.getValue(LIT) ? 13 : 0;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,7 +67,7 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider,
|
||||||
if (block.contains("_on")) {
|
if (block.contains("_on")) {
|
||||||
map.put("%front%", blockId.getPath() + "_front_on");
|
map.put("%front%", blockId.getPath() + "_front_on");
|
||||||
map.put("%glow%", blockId.getPath() + "_glow");
|
map.put("%glow%", blockId.getPath() + "_glow");
|
||||||
return Patterns.createJson(Patterns.BLOCK_FURNACE_GLOW, map);
|
return Patterns.createJson(Patterns.BLOCK_FURNACE_LIT, map);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
map.put("%front%", blockId.getPath() + "_front");
|
map.put("%front%", blockId.getPath() + "_front");
|
||||||
|
@ -78,6 +80,38 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider,
|
||||||
return Patterns.STATE_FURNACE;
|
return Patterns.STATE_FURNACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public 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");
|
||||||
|
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 BlockModel.fromString(pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockModel getModel(ResourceLocation resourceLocation) {
|
||||||
|
return getBlockModel(resourceLocation, defaultBlockState());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
|
String lit = blockState.getValue(LIT) ? "_lit" : "";
|
||||||
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
|
"block/" + resourceLocation.getPath() + lit);
|
||||||
|
ModelsHelper.addBlockState(blockState, modelId);
|
||||||
|
return ModelsHelper.createFacingModel(modelId, blockState.getValue(FACING));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ERenderLayer getRenderLayer() {
|
public ERenderLayer getRenderLayer() {
|
||||||
return ERenderLayer.CUTOUT;
|
return ERenderLayer.CUTOUT;
|
||||||
|
|
|
@ -12,8 +12,8 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.FenceGateBlock;
|
import net.minecraft.world.level.block.FenceGateBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndGateBlock extends FenceGateBlock implements BlockModelProvider {
|
public class EndGateBlock extends FenceGateBlock implements BlockModelProvider {
|
||||||
private final Block parent;
|
private final Block parent;
|
||||||
|
|
|
@ -27,8 +27,8 @@ import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable, BlockModelProvider {
|
public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable, BlockModelProvider {
|
||||||
|
|
|
@ -22,8 +22,8 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class EndLeavesBlock extends LeavesBlock implements BlockModelProvider, IRenderTypeable {
|
public class EndLeavesBlock extends LeavesBlock implements BlockModelProvider, IRenderTypeable {
|
||||||
|
|
|
@ -17,8 +17,8 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndMetalPaneBlock extends IronBarsBlock implements BlockModelProvider, IRenderTypeable {
|
public class EndMetalPaneBlock extends IronBarsBlock implements BlockModelProvider, IRenderTypeable {
|
||||||
public EndMetalPaneBlock(Block source) {
|
public EndMetalPaneBlock(Block source) {
|
||||||
|
|
|
@ -12,8 +12,8 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.WeightedPressurePlateBlock;
|
import net.minecraft.world.level.block.WeightedPressurePlateBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndMetalPlateBlock extends WeightedPressurePlateBlock implements BlockModelProvider {
|
public class EndMetalPlateBlock extends WeightedPressurePlateBlock implements BlockModelProvider {
|
||||||
private final Block parent;
|
private final Block parent;
|
||||||
|
|
|
@ -6,7 +6,6 @@ import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
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.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -21,8 +20,8 @@ import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.world.level.material.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class EndOreBlock extends OreBlock implements BlockModelProvider {
|
public class EndOreBlock extends OreBlock implements BlockModelProvider {
|
||||||
|
|
|
@ -4,12 +4,9 @@ import java.io.Reader;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.mojang.math.Transformation;
|
|
||||||
import com.mojang.math.Vector3f;
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
import net.minecraft.client.renderer.block.model.MultiVariant;
|
||||||
import net.minecraft.client.renderer.block.model.Variant;
|
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -18,8 +15,9 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.RotatedPillarBlock;
|
import net.minecraft.world.level.block.RotatedPillarBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndPillarBlock extends RotatedPillarBlock implements BlockModelProvider {
|
public class EndPillarBlock extends RotatedPillarBlock implements BlockModelProvider {
|
||||||
public EndPillarBlock(Properties settings) {
|
public EndPillarBlock(Properties settings) {
|
||||||
|
@ -48,7 +46,8 @@ public class EndPillarBlock extends RotatedPillarBlock implements BlockModelProv
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelString(String block) {
|
public String getModelString(String block) {
|
||||||
return createBlockPattern();
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||||
|
return createBlockPattern(blockId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,19 +57,18 @@ public class EndPillarBlock extends RotatedPillarBlock implements BlockModelProv
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
BlockModel model = BlockModel.fromString(createBlockPattern());
|
return BlockModel.fromString(createBlockPattern(blockId));
|
||||||
ResourceLocation modelLoc = new ResourceLocation(blockId.getNamespace(), "blocks/" + blockId.getPath());
|
|
||||||
model.name = modelLoc.toString();
|
|
||||||
return model;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
return BlockModelProvider.createRotatedModel(resourceLocation, blockState.getValue(AXIS));
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
|
"block/" + resourceLocation.getPath());
|
||||||
|
ModelsHelper.addBlockState(blockState, modelId);
|
||||||
|
return ModelsHelper.createRotatedModel(modelId, blockState.getValue(AXIS));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String createBlockPattern() {
|
protected String createBlockPattern(ResourceLocation blockId) {
|
||||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
return Patterns.createBlockPillar(blockId.getPath());
|
||||||
return Patterns.createBlockPillar(texture);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.PressurePlateBlock;
|
import net.minecraft.world.level.block.PressurePlateBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndPlateBlock extends PressurePlateBlock implements BlockModelProvider {
|
public class EndPlateBlock extends PressurePlateBlock implements BlockModelProvider {
|
||||||
private final Block parent;
|
private final Block parent;
|
||||||
|
|
|
@ -40,8 +40,8 @@ import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import ru.betterend.blocks.entities.ESignBlockEntity;
|
import ru.betterend.blocks.entities.ESignBlockEntity;
|
||||||
import ru.betterend.interfaces.ISpetialItem;
|
import ru.betterend.interfaces.ISpetialItem;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
|
||||||
public class EndSignBlock extends SignBlock implements BlockModelProvider, ISpetialItem {
|
public class EndSignBlock extends SignBlock implements BlockModelProvider, ISpetialItem {
|
||||||
|
|
|
@ -12,8 +12,8 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.SlabBlock;
|
import net.minecraft.world.level.block.SlabBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndSlabBlock extends SlabBlock implements BlockModelProvider {
|
public class EndSlabBlock extends SlabBlock implements BlockModelProvider {
|
||||||
private final Block parent;
|
private final Block parent;
|
||||||
|
|
|
@ -12,8 +12,8 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.StairBlock;
|
import net.minecraft.world.level.block.StairBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndStairsBlock extends StairBlock implements BlockModelProvider {
|
public class EndStairsBlock extends StairBlock implements BlockModelProvider {
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.StoneButtonBlock;
|
import net.minecraft.world.level.block.StoneButtonBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndStoneButtonBlock extends StoneButtonBlock implements BlockModelProvider {
|
public class EndStoneButtonBlock extends StoneButtonBlock implements BlockModelProvider {
|
||||||
private final Block parent;
|
private final Block parent;
|
||||||
|
|
|
@ -15,8 +15,8 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndTrapdoorBlock extends TrapDoorBlock implements IRenderTypeable, BlockModelProvider {
|
public class EndTrapdoorBlock extends TrapDoorBlock implements IRenderTypeable, BlockModelProvider {
|
||||||
public EndTrapdoorBlock(Block source) {
|
public EndTrapdoorBlock(Block source) {
|
||||||
|
|
|
@ -12,8 +12,8 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.WallBlock;
|
import net.minecraft.world.level.block.WallBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndWallBlock extends WallBlock implements BlockModelProvider {
|
public class EndWallBlock extends WallBlock implements BlockModelProvider {
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.WoodButtonBlock;
|
import net.minecraft.world.level.block.WoodButtonBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndWoodenButtonBlock extends WoodButtonBlock implements BlockModelProvider {
|
public class EndWoodenButtonBlock extends WoodButtonBlock implements BlockModelProvider {
|
||||||
private final Block parent;
|
private final Block parent;
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
|
@ -28,10 +27,11 @@ import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.registry.EndTags;
|
import ru.betterend.registry.EndTags;
|
||||||
|
|
||||||
public abstract class FeatureSaplingBlock extends SaplingBlock implements IRenderTypeable, BlockModelProvider {
|
public abstract class FeatureSaplingBlock extends SaplingBlock implements IRenderTypeable, BlockModelProvider {
|
||||||
|
@ -131,7 +131,7 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements IRende
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getModel(ResourceLocation resourceLocation) {
|
public BlockModel getModel(ResourceLocation resourceLocation) {
|
||||||
return BlockModelProvider.createBlockItem(resourceLocation);
|
return ModelsHelper.createBlockItem(resourceLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
|
import net.minecraft.client.renderer.block.model.MultiVariant;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
@ -43,8 +44,8 @@ import ru.betterend.blocks.BlockProperties;
|
||||||
import ru.betterend.blocks.BlockProperties.PedestalState;
|
import ru.betterend.blocks.BlockProperties.PedestalState;
|
||||||
import ru.betterend.blocks.InfusionPedestal;
|
import ru.betterend.blocks.InfusionPedestal;
|
||||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.rituals.InfusionRitual;
|
import ru.betterend.rituals.InfusionRitual;
|
||||||
|
|
||||||
|
@ -344,18 +345,7 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelString(String block) {
|
public String getModelString(String block) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
Map<String, String> textures = createTexturesMap();
|
||||||
String name = blockId.getPath();
|
|
||||||
Map<String, String> textures = new HashMap<String, String>() {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
{
|
|
||||||
put("%mod%", blockId.getNamespace() );
|
|
||||||
put("%top%", name + "_top");
|
|
||||||
put("%base%", name + "_base");
|
|
||||||
put("%pillar%", name + "_pillar");
|
|
||||||
put("%bottom%", name + "_bottom");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (block.contains("column_top")) {
|
if (block.contains("column_top")) {
|
||||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
|
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
|
||||||
} else if (block.contains("column")) {
|
} else if (block.contains("column")) {
|
||||||
|
@ -377,18 +367,7 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
Map<String, String> textures = createTexturesMap();
|
||||||
String name = blockId.getPath();
|
|
||||||
Map<String, String> textures = new HashMap<String, String>() {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
{
|
|
||||||
put("%mod%", blockId.getNamespace() );
|
|
||||||
put("%top%", name + "_top");
|
|
||||||
put("%base%", name + "_base");
|
|
||||||
put("%pillar%", name + "_pillar");
|
|
||||||
put("%bottom%", name + "_bottom");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
PedestalState state = blockState.getValue(STATE);
|
PedestalState state = blockState.getValue(STATE);
|
||||||
String pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
|
String pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -413,7 +392,15 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BlockModelProvider.createBlockModel(resourceLocation, pattern);
|
return BlockModel.fromString(pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
|
PedestalState state = blockState.getValue(STATE);
|
||||||
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
|
"block/" + resourceLocation.getPath() + "_" + state);
|
||||||
|
return super.getModelVariant(modelId, blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -421,6 +408,21 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
|
||||||
return Patterns.STATE_PEDESTAL;
|
return Patterns.STATE_PEDESTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Map<String, String> createTexturesMap() {
|
||||||
|
ResourceLocation blockId = Registry.BLOCK.getKey(parent);
|
||||||
|
String name = blockId.getPath();
|
||||||
|
return new HashMap<String, String>() {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
{
|
||||||
|
put("%mod%", blockId.getNamespace() );
|
||||||
|
put("%top%", name + "_top");
|
||||||
|
put("%base%", name + "_base");
|
||||||
|
put("%pillar%", name + "_pillar");
|
||||||
|
put("%bottom%", name + "_bottom");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
VoxelShape basinUp = Block.box(2, 3, 2, 14, 4, 14);
|
VoxelShape basinUp = Block.box(2, 3, 2, 14, 4, 14);
|
||||||
VoxelShape basinDown = Block.box(0, 0, 0, 16, 3, 16);
|
VoxelShape basinDown = Block.box(0, 0, 0, 16, 3, 16);
|
||||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.world.level.material.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class SimpleLeavesBlock extends BlockBaseNotFull implements IRenderTypeable {
|
public class SimpleLeavesBlock extends BlockBaseNotFull implements IRenderTypeable {
|
||||||
public SimpleLeavesBlock(MaterialColor color) {
|
public SimpleLeavesBlock(MaterialColor color) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import ru.betterend.blocks.BlockProperties;
|
import ru.betterend.blocks.BlockProperties;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class StalactiteBlock extends BlockBaseNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, IRenderTypeable {
|
public class StalactiteBlock extends BlockBaseNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, IRenderTypeable {
|
||||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import ru.betterend.blocks.AuroraCrystalBlock;
|
import ru.betterend.blocks.AuroraCrystalBlock;
|
||||||
import ru.betterend.interfaces.IColorProvider;
|
import ru.betterend.interfaces.IColorProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class StoneLanternBlock extends EndLanternBlock implements IColorProvider {
|
public class StoneLanternBlock extends EndLanternBlock implements IColorProvider {
|
||||||
|
|
|
@ -26,7 +26,7 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||||
import ru.betterend.blocks.BlockProperties;
|
import ru.betterend.blocks.BlockProperties;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.EndTerrainBlock;
|
import ru.betterend.blocks.EndTerrainBlock;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class TripleTerrainBlock extends EndTerrainBlock {
|
public class TripleTerrainBlock extends EndTerrainBlock {
|
||||||
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package ru.betterend.client.models;
|
||||||
|
|
||||||
|
import java.io.Reader;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
|
import net.minecraft.client.renderer.block.model.MultiVariant;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
public interface BlockModelProvider extends ModelProvider {
|
||||||
|
String getStatesPattern(Reader data);
|
||||||
|
ResourceLocation statePatternId();
|
||||||
|
|
||||||
|
default BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
|
String pattern = Patterns.createBlockSimple(resourceLocation.getPath());
|
||||||
|
return BlockModel.fromString(pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
default MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
|
"block/" + resourceLocation.getPath());
|
||||||
|
ModelsHelper.addBlockState(blockState, modelId);
|
||||||
|
return ModelsHelper.createBlockSimple(modelId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package ru.betterend.patterns;
|
package ru.betterend.client.models;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
68
src/main/java/ru/betterend/client/models/ModelsHelper.java
Normal file
68
src/main/java/ru/betterend/client/models/ModelsHelper.java
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
package ru.betterend.client.models;
|
||||||
|
|
||||||
|
import com.google.common.collect.*;
|
||||||
|
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.core.Direction;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ModelsHelper {
|
||||||
|
|
||||||
|
private final static BiMap<BlockState, ResourceLocation> STATES_MAP;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static BlockState getBlockState(ResourceLocation resourceLocation) {
|
||||||
|
BlockState blockState = STATES_MAP.inverse().get(resourceLocation);
|
||||||
|
if (blockState != null) {
|
||||||
|
STATES_MAP.remove(blockState);
|
||||||
|
}
|
||||||
|
return blockState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addBlockState(BlockState blockState, ResourceLocation resourceLocation) {
|
||||||
|
STATES_MAP.put(blockState, resourceLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockModel createBlockItem(ResourceLocation resourceLocation) {
|
||||||
|
String pattern = Patterns.createJson(Patterns.ITEM_BLOCK, resourceLocation.getPath());
|
||||||
|
return BlockModel.fromString(pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MultiVariant createBlockSimple(ResourceLocation resourceLocation) {
|
||||||
|
Variant variant = new Variant(resourceLocation, Transformation.identity(), false, 1);
|
||||||
|
return new MultiVariant(Lists.newArrayList(variant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MultiVariant createFacingModel(ResourceLocation resourceLocation, Direction facing) {
|
||||||
|
BlockModelRotation rotation = BlockModelRotation.by(0, (int) facing.toYRot());
|
||||||
|
Variant variant = new Variant(resourceLocation, rotation.getRotation(), false, 1);
|
||||||
|
return new MultiVariant(Lists.newArrayList(variant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MultiVariant createRotatedModel(ResourceLocation resourceLocation, Direction.Axis axis) {
|
||||||
|
BlockModelRotation rotation = BlockModelRotation.X0_Y0;
|
||||||
|
switch (axis) {
|
||||||
|
case X: {
|
||||||
|
rotation = BlockModelRotation.by(90, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Z: {
|
||||||
|
rotation = BlockModelRotation.by(90, 90);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Variant variant = new Variant(resourceLocation, rotation.getRotation(), false, 1);
|
||||||
|
return new MultiVariant(Lists.newArrayList(variant));
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
STATES_MAP = HashBiMap.create();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package ru.betterend.patterns;
|
package ru.betterend.client.models;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -12,10 +12,8 @@ import java.util.stream.Collectors;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
|
|
||||||
public class Patterns {
|
public class Patterns {
|
||||||
|
@ -105,7 +103,7 @@ public class Patterns {
|
||||||
public final static ResourceLocation BLOCK_CHANDELIER_WALL = BetterEnd.makeID("patterns/block/chandelier_wall.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_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 = 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_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_TOP_SIDE_BOTTOM = BetterEnd.makeID("patterns/block/top_side_bottom.json");
|
||||||
public final static ResourceLocation BLOCK_PATH = BetterEnd.makeID("patterns/block/path.json");
|
public final static ResourceLocation BLOCK_PATH = BetterEnd.makeID("patterns/block/path.json");
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package ru.betterend.item;
|
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.ItemStack;
|
||||||
import net.minecraft.world.item.Rarity;
|
import net.minecraft.world.item.Rarity;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.registry.EndItems;
|
import ru.betterend.registry.EndItems;
|
||||||
|
|
||||||
public class EnchantedPetalItem extends ModelProviderItem {
|
public class EnchantedPetalItem extends ModelProviderItem {
|
||||||
|
@ -19,4 +22,9 @@ public class EnchantedPetalItem extends ModelProviderItem {
|
||||||
public String getModelString(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/hydralux_petal");
|
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/hydralux_petal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockModel getModel(ResourceLocation resourceLocation) {
|
||||||
|
return ModelProvider.createItemModel("hydralux_petal");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.item.ArmorItem;
|
import net.minecraft.world.item.ArmorItem;
|
||||||
import net.minecraft.world.item.ArmorMaterial;
|
import net.minecraft.world.item.ArmorMaterial;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ package ru.betterend.item;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.item.FishBucketItem;
|
import net.minecraft.world.item.FishBucketItem;
|
||||||
import net.minecraft.world.level.material.Fluids;
|
import net.minecraft.world.level.material.Fluids;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.registry.EndItems;
|
import ru.betterend.registry.EndItems;
|
||||||
|
|
||||||
public class EndBucketItem extends FishBucketItem implements ModelProvider {
|
public class EndBucketItem extends FishBucketItem implements ModelProvider {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package ru.betterend.item;
|
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.entity.EntityType;
|
||||||
import net.minecraft.world.item.SpawnEggItem;
|
import net.minecraft.world.item.SpawnEggItem;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndSpawnEggItem extends SpawnEggItem implements ModelProvider {
|
public class EndSpawnEggItem extends SpawnEggItem implements ModelProvider {
|
||||||
public EndSpawnEggItem(EntityType<?> type, int primaryColor, int secondaryColor, Properties settings) {
|
public EndSpawnEggItem(EntityType<?> type, int primaryColor, int secondaryColor, Properties settings) {
|
||||||
|
@ -14,4 +16,10 @@ public class EndSpawnEggItem extends SpawnEggItem implements ModelProvider {
|
||||||
public String getModelString(String name) {
|
public String getModelString(String name) {
|
||||||
return Patterns.createJson(Patterns.ITEM_SPAWN_EGG, name);
|
return Patterns.createJson(Patterns.ITEM_SPAWN_EGG, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockModel getModel(ResourceLocation resourceLocation) {
|
||||||
|
String pattern = Patterns.createJson(Patterns.ITEM_SPAWN_EGG, resourceLocation.getPath());
|
||||||
|
return BlockModel.fromString(pattern);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package ru.betterend.item;
|
package ru.betterend.item;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.item.RecordItem;
|
import net.minecraft.world.item.RecordItem;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class ModelProviderDiscItem extends RecordItem implements ModelProvider {
|
public class ModelProviderDiscItem extends RecordItem implements ModelProvider {
|
||||||
public ModelProviderDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) {
|
public ModelProviderDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) {
|
||||||
|
|
|
@ -3,8 +3,8 @@ package ru.betterend.item;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class ModelProviderItem extends Item implements ModelProvider {
|
public class ModelProviderItem extends Item implements ModelProvider {
|
||||||
public ModelProviderItem(Properties settings) {
|
public ModelProviderItem(Properties settings) {
|
||||||
|
|
|
@ -9,8 +9,8 @@ import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndAxeItem extends AxeItem implements DynamicAttributeTool, ModelProvider {
|
public class EndAxeItem extends AxeItem implements DynamicAttributeTool, ModelProvider {
|
||||||
public EndAxeItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
|
public EndAxeItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
|
||||||
|
|
|
@ -26,8 +26,8 @@ import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.material.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
import ru.betterend.registry.EndTags;
|
import ru.betterend.registry.EndTags;
|
||||||
|
|
||||||
public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, ModelProvider {
|
public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, ModelProvider {
|
||||||
|
|
|
@ -2,8 +2,8 @@ package ru.betterend.item.tool;
|
||||||
|
|
||||||
import net.minecraft.world.item.HoeItem;
|
import net.minecraft.world.item.HoeItem;
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndHoeItem extends HoeItem implements ModelProvider {
|
public class EndHoeItem extends HoeItem implements ModelProvider {
|
||||||
public EndHoeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
public EndHoeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
||||||
|
|
|
@ -12,8 +12,8 @@ import net.minecraft.world.item.PickaxeItem;
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool, ModelProvider {
|
public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool, ModelProvider {
|
||||||
public EndPickaxeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
public EndPickaxeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
||||||
|
|
|
@ -11,8 +11,8 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.ShovelItem;
|
import net.minecraft.world.item.ShovelItem;
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, ModelProvider {
|
public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, ModelProvider {
|
||||||
public EndShovelItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
|
public EndShovelItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
|
||||||
|
|
|
@ -3,8 +3,8 @@ package ru.betterend.item.tool;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
||||||
import net.minecraft.world.item.SwordItem;
|
import net.minecraft.world.item.SwordItem;
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
import ru.betterend.patterns.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndSwordItem extends SwordItem implements DynamicAttributeTool, ModelProvider {
|
public class EndSwordItem extends SwordItem implements DynamicAttributeTool, ModelProvider {
|
||||||
public EndSwordItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
public EndSwordItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
|
||||||
|
|
|
@ -8,12 +8,10 @@ import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
import net.minecraft.client.resources.model.UnbakedModel;
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.packs.resources.Resource;
|
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import org.apache.commons.lang3.tuple.Triple;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
@ -23,13 +21,12 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.patterns.ModelProvider;
|
import ru.betterend.client.models.ModelProvider;
|
||||||
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
import ru.betterend.world.generator.GeneratorOptions;
|
import ru.betterend.world.generator.GeneratorOptions;
|
||||||
|
|
||||||
import java.io.InputStreamReader;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -69,7 +66,7 @@ public abstract class ModelLoaderMixin {
|
||||||
model = loadBlockModel(itemLoc);
|
model = loadBlockModel(itemLoc);
|
||||||
}
|
}
|
||||||
cacheAndQueueDependencies(modelLoc, model);
|
cacheAndQueueDependencies(modelLoc, model);
|
||||||
unbakedCache.put(modelLoc, model);
|
unbakedCache.put(itemLoc, model);
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,14 +76,13 @@ public abstract class ModelLoaderMixin {
|
||||||
Block block = Registry.BLOCK.get(clearLoc);
|
Block block = Registry.BLOCK.get(clearLoc);
|
||||||
if (block instanceof BlockModelProvider) {
|
if (block instanceof BlockModelProvider) {
|
||||||
block.getStateDefinition().getPossibleStates().forEach(blockState -> {
|
block.getStateDefinition().getPossibleStates().forEach(blockState -> {
|
||||||
|
System.out.println(blockState);
|
||||||
ModelResourceLocation stateLoc = BlockModelShaper.stateToModelLocation(clearLoc, blockState);
|
ModelResourceLocation stateLoc = BlockModelShaper.stateToModelLocation(clearLoc, blockState);
|
||||||
MultiVariant modelVariant = ((BlockModelProvider) block).getModelVariant(stateLoc, blockState);
|
MultiVariant modelVariant = ((BlockModelProvider) block).getModelVariant(stateLoc, blockState);
|
||||||
BlockModel blockModel = ((BlockModelProvider) block).getBlockModel(clearLoc, blockState);
|
if (modelVariant != null) {
|
||||||
if (modelVariant != null && blockModel != null) {
|
|
||||||
cacheAndQueueDependencies(stateLoc, modelVariant);
|
cacheAndQueueDependencies(stateLoc, modelVariant);
|
||||||
unbakedCache.put(stateLoc, blockModel);
|
|
||||||
} else {
|
} else {
|
||||||
BetterEnd.LOGGER.warning("Error loading models for {}", clearLoc);
|
BetterEnd.LOGGER.warning("Error loading variant: {}", stateLoc);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
info.cancel();
|
info.cancel();
|
||||||
|
@ -97,31 +93,38 @@ public abstract class ModelLoaderMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "loadBlockModel", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "loadBlockModel", at = @At("HEAD"), cancellable = true)
|
||||||
private void be_loadModelPattern(ResourceLocation id, CallbackInfoReturnable<BlockModel> info) {
|
private void be_loadModelPattern(ResourceLocation modelId, CallbackInfoReturnable<BlockModel> info) {
|
||||||
if (BetterEnd.isModId(id)) {
|
ResourceLocation modelLocation = new ResourceLocation(modelId.getNamespace(), "models/" + modelId.getPath() + ".json");
|
||||||
ResourceLocation modelId = new ResourceLocation(id.getNamespace(), "models/" + id.getPath() + ".json");
|
if (!resourceManager.hasResource(modelLocation)) {
|
||||||
BlockModel model;
|
BlockState blockState = ModelsHelper.getBlockState(modelId);
|
||||||
try (Resource resource = resourceManager.getResource(modelId)) {
|
if (blockState != null) {
|
||||||
Reader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8);
|
Block block = blockState.getBlock();
|
||||||
model = BlockModel.fromStream(reader);
|
if (block instanceof BlockModelProvider) {
|
||||||
model.name = id.toString();
|
ResourceLocation blockId = Registry.BLOCK.getKey(block);
|
||||||
info.setReturnValue(model);
|
BlockModel model = ((BlockModelProvider) block).getBlockModel(blockId, blockState);
|
||||||
} catch (Exception ex) {
|
if (model != null) {
|
||||||
String[] data = id.getPath().split("/");
|
model.name = modelId.toString();
|
||||||
|
info.setReturnValue(model);
|
||||||
|
} else {
|
||||||
|
BetterEnd.LOGGER.warning("Error loading model: {}", modelId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] data = modelId.getPath().split("/");
|
||||||
if (data.length > 1) {
|
if (data.length > 1) {
|
||||||
ResourceLocation itemId = new ResourceLocation(id.getNamespace(), data[1]);
|
ResourceLocation itemId = new ResourceLocation(modelId.getNamespace(), data[1]);
|
||||||
Optional<Block> block = Registry.BLOCK.getOptional(itemId);
|
Optional<Block> block = Registry.BLOCK.getOptional(itemId);
|
||||||
if (block.isPresent()) {
|
if (block.isPresent()) {
|
||||||
if (block.get() instanceof ModelProvider) {
|
if (block.get() instanceof ModelProvider) {
|
||||||
ModelProvider modelProvider = (ModelProvider) block.get();
|
ModelProvider modelProvider = (ModelProvider) block.get();
|
||||||
model = be_getModel(data, id, modelProvider);
|
BlockModel model = be_getModel(data, modelId, modelProvider);
|
||||||
info.setReturnValue(model);
|
info.setReturnValue(model);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Optional<Item> item = Registry.ITEM.getOptional(itemId);
|
Optional<Item> item = Registry.ITEM.getOptional(itemId);
|
||||||
if (item.isPresent() && item.get() instanceof ModelProvider) {
|
if (item.isPresent() && item.get() instanceof ModelProvider) {
|
||||||
ModelProvider modelProvider = (ModelProvider) item.get();
|
ModelProvider modelProvider = (ModelProvider) item.get();
|
||||||
model = be_getModel(data, id, modelProvider);
|
BlockModel model = be_getModel(data, modelId, modelProvider);
|
||||||
info.setReturnValue(model);
|
info.setReturnValue(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import com.google.gson.Gson;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModelDefinition;
|
import net.minecraft.client.renderer.block.model.BlockModelDefinition;
|
||||||
import net.minecraft.util.GsonHelper;
|
import net.minecraft.util.GsonHelper;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
|
|
||||||
@Mixin(BlockModelDefinition.class)
|
@Mixin(BlockModelDefinition.class)
|
||||||
public abstract class ModelVariantMapMixin {
|
public abstract class ModelVariantMapMixin {
|
||||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.server.packs.resources.FallbackResourceManager;
|
||||||
import net.minecraft.server.packs.resources.Resource;
|
import net.minecraft.server.packs.resources.Resource;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.patterns.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
|
|
||||||
@Mixin(FallbackResourceManager.class)
|
@Mixin(FallbackResourceManager.class)
|
||||||
public abstract class NamespaceResourceManagerMixin {
|
public abstract class NamespaceResourceManagerMixin {
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
package ru.betterend.patterns;
|
|
||||||
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import com.mojang.math.Transformation;
|
|
||||||
import com.mojang.math.Vector3f;
|
|
||||||
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.core.Direction;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
|
|
||||||
public interface BlockModelProvider extends ModelProvider {
|
|
||||||
String getStatesPattern(Reader data);
|
|
||||||
ResourceLocation statePatternId();
|
|
||||||
|
|
||||||
default BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
|
||||||
String pattern = Patterns.createBlockSimple(resourceLocation.getPath());
|
|
||||||
return createBlockModel(resourceLocation, pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
default MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
|
||||||
return createBlockSimple(resourceLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
static BlockModel createBlockItem(ResourceLocation resourceLocation) {
|
|
||||||
String pattern = Patterns.createJson(Patterns.ITEM_BLOCK, resourceLocation.getPath());
|
|
||||||
return BlockModel.fromString(pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
static BlockModel createBlockModel(ResourceLocation blockId, String pattern) {
|
|
||||||
BlockModel model = BlockModel.fromString(pattern);
|
|
||||||
ResourceLocation modelLoc = new ResourceLocation(blockId.getNamespace(), "blocks/" + blockId.getPath());
|
|
||||||
model.name = modelLoc.toString();
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
static MultiVariant createBlockSimple(ResourceLocation resourceLocation) {
|
|
||||||
Variant variant = new Variant(resourceLocation, Transformation.identity(), false, 1);
|
|
||||||
return new MultiVariant(Collections.singletonList(variant));
|
|
||||||
}
|
|
||||||
|
|
||||||
static MultiVariant createFacingModel(ResourceLocation resourceLocation, Direction facing) {
|
|
||||||
Transformation transform = new Transformation(null, facing.getRotation(), null, null);
|
|
||||||
Variant variant = new Variant(resourceLocation, transform, false, 1);
|
|
||||||
return new MultiVariant(Collections.singletonList(variant));
|
|
||||||
}
|
|
||||||
|
|
||||||
static MultiVariant createRotatedModel(ResourceLocation resourceLocation, Direction.Axis rotation) {
|
|
||||||
Transformation transform = Transformation.identity();
|
|
||||||
switch (rotation) {
|
|
||||||
case X: {
|
|
||||||
transform = new Transformation(null, Vector3f.ZP.rotationDegrees(90), null, null);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Z: {
|
|
||||||
transform = new Transformation(null, Vector3f.XP.rotationDegrees(90), null, null);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Variant variant = new Variant(resourceLocation, transform, false, 1);
|
|
||||||
return new MultiVariant(Collections.singletonList(variant));
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue