Change models loading (still WIP)

This commit is contained in:
Aleksey 2021-05-18 16:51:41 +03:00
parent 2d23ca72ea
commit 744fe40a00
64 changed files with 437 additions and 269 deletions

View file

@ -9,7 +9,7 @@ import ru.betterend.api.BetterEndPlugin;
import ru.betterend.config.Configs;
import ru.betterend.effects.EndEnchantments;
import ru.betterend.effects.EndPotions;
import ru.betterend.events.PlayerAdvancementsEvents;
import ru.betterend.events.PlayerAdvancementsCallback;
import ru.betterend.integration.Integrations;
import ru.betterend.item.GuideBookItem;
import ru.betterend.recipe.AlloyingRecipes;
@ -78,7 +78,7 @@ public class BetterEnd implements ModInitializer {
Configs.saveConfigs();
if (hasGuideBook()) {
PlayerAdvancementsEvents.PLAYER_ADVENCEMENT_COMPLETE.register((player, advancement, criterionName) -> {
PlayerAdvancementsCallback.PLAYER_ADVANCEMENT_COMPLETE.register((player, advancement, criterionName) -> {
ResourceLocation advId = new ResourceLocation("minecraft:end/enter_end_gateway");
if (advId.equals(advancement.getId())) {
player.addItem(new ItemStack(GuideBookItem.GUIDE_BOOK));

View file

@ -11,21 +11,15 @@ import ru.betterend.client.models.Patterns;
import ru.betterend.registry.EndBlocks;
public class AeterniumAnvil extends EndAnvilBlock {
private static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION_LONG;
private static final IntegerProperty DESTRUCTION_LONG = BlockProperties.DESTRUCTION_LONG;
public AeterniumAnvil() {
super(EndBlocks.AETERNIUM_BLOCK.defaultMaterialColor(), EndToolMaterial.AETERNIUM.getLevel());
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(DESTRUCTION);
builder.add(FACING);
}
@Override
public IntegerProperty getDestructionProperty() {
return DESTRUCTION;
return DESTRUCTION_LONG;
}
@Override

View file

@ -2,6 +2,7 @@ package ru.betterend.blocks;
import java.io.Reader;
import java.util.Map;
import java.util.Optional;
import com.google.common.collect.Maps;
@ -60,7 +61,7 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
Map<String, String> map = Maps.newHashMap();
map.put("%glow%", getGlowTexture());

View file

@ -2,6 +2,7 @@ package ru.betterend.blocks;
import java.io.Reader;
import java.util.EnumMap;
import java.util.Optional;
import com.google.common.collect.Maps;
@ -46,7 +47,7 @@ public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, B
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
@ -93,7 +94,7 @@ public class EmeraldIceBlock extends HalfTransparentBlock implements IRenderType
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
}

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import com.google.common.collect.Maps;
@ -55,7 +56,7 @@ public class EndPathBlock extends BlockBaseNotFull {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
String name = Registry.BLOCK.getKey(this).getPath();
Map<String, String> map = Maps.newHashMap();
map.put("%top%", name + "_top");

View file

@ -1,9 +1,6 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.*;
import com.google.common.collect.Maps;
@ -95,7 +92,7 @@ public class EndTerrainBlock extends BlockBase {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
String name = Registry.BLOCK.getKey(this).getPath();
Map<String, String> map = Maps.newHashMap();
map.put("%top%", "betterend:block/" + name + "_top");

View file

@ -1,6 +1,7 @@
package ru.betterend.blocks;
import java.io.Reader;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.color.block.BlockColor;
@ -36,7 +37,7 @@ public class HydraluxPetalColoredBlock extends HydraluxPetalBlock implements ICo
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
String path = "betterend:block/block_petal_colored";
return Patterns.createJson(Patterns.BLOCK_PETAL_COLORED, path, path);
}

View file

@ -2,6 +2,7 @@ package ru.betterend.blocks;
import java.io.Reader;
import java.util.List;
import java.util.Optional;
import com.google.common.collect.Lists;
@ -73,7 +74,7 @@ public class JellyshroomCapBlock extends SlimeBlock implements IRenderTypeable,
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
return Patterns.createJson(Patterns.BLOCK_COLORED, "jellyshroom_cap");
}

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import com.google.common.collect.Lists;
@ -74,7 +75,7 @@ public class UmbrellaTreeMembraneBlock extends SlimeBlock implements IRenderType
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
}

View file

@ -1,6 +1,7 @@
package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Optional;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
@ -18,7 +19,7 @@ public class BarkBlock extends EndPillarBlock {
}
@Override
protected String createBlockPattern(ResourceLocation blockId) {
protected Optional<String> createBlockPattern(ResourceLocation blockId) {
blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BASE, getName(blockId), blockId.getPath());
}

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.core.Registry;
@ -31,7 +32,7 @@ public class BlockBase extends Block implements BlockModelProvider {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createBlockSimple(blockId.getPath());
}

View file

@ -4,12 +4,14 @@ import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
@ -38,7 +40,7 @@ public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder);
builder.add(DESTRUCTION);
builder.add(getDestructionProperty());
}
public IntegerProperty getDestructionProperty() {
@ -64,7 +66,7 @@ public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
Map<String, String> map = Maps.newHashMap();
map.put("%anvil%", blockId.getPath());
@ -98,19 +100,18 @@ public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
Map<String, String> textures = Maps.newHashMap();
textures.put("%anvil%", name);
textures.put("%top%", name + "_top_" + destruction);
String pattern = Patterns.createJson(Patterns.BLOCK_ANVIL, textures);
return BlockModel.fromString(pattern);
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_ANVIL, textures);
return pattern.map(BlockModel::fromString).orElse(null);
}
@Override
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
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);
registerBlockModel(resourceLocation, modelLocation, blockState, modelCache);
return ModelsHelper.createFacingModel(modelLocation, blockState.getValue(FACING).getOpposite());
}
}

View file

@ -2,13 +2,15 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
@ -99,7 +101,7 @@ public class EndBarrelBlock extends BarrelBlock implements BlockModelProvider {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
String texture = Registry.BLOCK.getKey(this).getPath();
if (block.contains("open")) {
return Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture);
@ -120,24 +122,21 @@ public class EndBarrelBlock extends BarrelBlock implements BlockModelProvider {
@Override
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
String texture = blockId.getPath();
String pattern;
Optional<String> pattern;
if (blockState.getValue(OPEN)) {
pattern = Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture);
} else {
pattern = Patterns.createJson(Patterns.BLOCK_BOTTOM_TOP, texture, texture);
}
if (pattern != null) {
return BlockModel.fromString(pattern);
}
return null;
return pattern.map(BlockModel::fromString).orElse(null);
}
@Override
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
String open = blockState.getValue(OPEN) ? "_open" : "";
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
"block/" + resourceLocation.getPath() + open);
ModelsHelper.addBlockState(blockState, modelId);
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
return ModelsHelper.createFacingModel(modelId, blockState.getValue(FACING));
}
}

View file

@ -3,8 +3,10 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
@ -40,7 +42,7 @@ public class EndBookshelfBlock extends BlockBase {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BOOKSHELF, getName(blockId), blockId.getPath());
}
@ -51,6 +53,13 @@ public class EndBookshelfBlock extends BlockBase {
return Patterns.createJson(data, getName(blockId), blockId.getPath());
}
@Override
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_BOOKSHELF,
getName(blockId), blockId.getPath());
return pattern.map(BlockModel::fromString).orElse(null);
}
private String getName(ResourceLocation blockId) {
String name = blockId.getPath();
return name.replace("_bookshelf", "");

View file

@ -3,10 +3,13 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
@ -40,7 +43,7 @@ public class EndChainBlock extends ChainBlock implements BlockModelProvider, IRe
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createItemGenerated(block);
@ -61,18 +64,16 @@ public class EndChainBlock extends ChainBlock implements BlockModelProvider, IRe
@Override
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
String name = blockId.getPath();
String pattern = Patterns.createJson(Patterns.BLOCK_CHAIN, name, name);
if (pattern != null) {
return BlockModel.fromString(pattern);
}
return null;
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_CHAIN, name, name);
return pattern.map(BlockModel::fromString).orElse(null);
}
@Override
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
Direction.Axis axis = blockState.getValue(AXIS);
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
"block/" + resourceLocation.getPath());
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
return ModelsHelper.createRotatedModel(modelId, axis);
}

View file

@ -2,10 +2,10 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
@ -16,7 +16,6 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext;
import ru.betterend.client.models.BlockModelProvider;
import ru.betterend.client.models.ModelsHelper;
import ru.betterend.client.models.Patterns;
import ru.betterend.registry.EndBlockEntities;
@ -50,7 +49,7 @@ public class EndChestBlock extends ChestBlock implements BlockModelProvider {
}
@Override
public String getModelString(String path) {
public Optional<String> getModelString(String path) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (path.contains("item")) {
@ -61,8 +60,8 @@ public class EndChestBlock extends ChestBlock implements BlockModelProvider {
@Override
public BlockModel getModel(ResourceLocation blockId) {
String pattern = Patterns.createJson(Patterns.ITEM_CHEST, blockId.getPath());
return BlockModel.fromString(pattern);
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_CHEST, blockId.getPath());
return pattern.map(BlockModel::fromString).orElse(null);
}
@Override
@ -73,7 +72,7 @@ public class EndChestBlock extends ChestBlock implements BlockModelProvider {
@Override
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
String pattern = Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath());
return BlockModel.fromString(pattern);
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath());
return pattern.map(BlockModel::fromString).orElse(null);
}
}

View file

@ -3,10 +3,13 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
@ -34,7 +37,7 @@ public class EndComposterBlock extends ComposterBlock implements BlockModelProvi
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
String blockName = blockId.getPath();
return Patterns.createJson(Patterns.BLOCK_COMPOSTER, blockName);
@ -56,7 +59,7 @@ public class EndComposterBlock extends ComposterBlock implements BlockModelProvi
}
@Override
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
return null;
}
}

View file

@ -4,10 +4,10 @@ import java.io.Reader;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
@ -16,7 +16,6 @@ import net.minecraft.world.level.block.CraftingTableBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext;
import ru.betterend.client.models.BlockModelProvider;
import ru.betterend.client.models.ModelsHelper;
import ru.betterend.client.models.Patterns;
public class EndCraftingTableBlock extends CraftingTableBlock implements BlockModelProvider {
@ -36,7 +35,7 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockMo
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
String blockName = blockId.getPath();
return Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {
@ -66,7 +65,7 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockMo
@Override
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
String blockName = blockId.getPath();
String pattern = Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
{
put("%particle%", blockName + "_front");
@ -78,6 +77,6 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockMo
put("%east%", blockName + "_side");
}
});
return BlockModel.fromString(pattern);
return pattern.map(BlockModel::fromString).orElse(null);
}
}

View file

@ -3,14 +3,25 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import com.google.common.collect.Lists;
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.client.renderer.block.model.Variant;
import net.minecraft.client.resources.model.BlockModelRotation;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.StringRepresentable;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.DoorBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.DoorHingeSide;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.storage.loot.LootContext;
import ru.betterend.client.render.ERenderLayer;
@ -43,7 +54,7 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockMod
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
String blockId = Registry.BLOCK.getKey(this).getPath();
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, block);
@ -60,8 +71,126 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockMod
return Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM, blockId, blockId);
}
@Override
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
String blockName = resourceLocation.getPath();
DoorType doorType = getDoorType(blockState);
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM, blockName, blockName);
switch (doorType) {
case TOP_HINGE: {
pattern = Patterns.createJson(Patterns.BLOCK_DOOR_TOP_HINGE, blockName, blockName);
break;
}
case BOTTOM_HINGE: {
pattern = Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM_HINGE, blockName, blockName);
break;
}
case TOP: {
pattern = Patterns.createJson(Patterns.BLOCK_DOOR_TOP, blockName, blockName);
break;
}
}
return pattern.map(BlockModel::fromString).orElse(null);
}
@Override
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
Direction facing = blockState.getValue(FACING);
DoorType doorType = getDoorType(blockState);
boolean open = blockState.getValue(OPEN);
boolean hinge = doorType.isHinge();
BlockModelRotation rotation = BlockModelRotation.X0_Y0;
switch (facing) {
case EAST: {
if (hinge && open) {
rotation = BlockModelRotation.by(0, 90);
} else if (open) {
rotation = BlockModelRotation.by(0, 270);
}
break;
}
case SOUTH: {
if (!hinge && !open || hinge && !open) {
rotation = BlockModelRotation.by(0, 90);
} else if (hinge) {
rotation = BlockModelRotation.by(0, 180);
}
break;
}
case WEST: {
if (!hinge && !open || hinge && !open) {
rotation = BlockModelRotation.by(0, 180);
} else if (hinge) {
rotation = BlockModelRotation.by(0, 270);
} else {
rotation = BlockModelRotation.by(0, 90);
}
break;
}
case NORTH: {
if (!hinge && !open || hinge && !open) {
rotation = BlockModelRotation.by(0, 270);
} else if (!hinge) {
rotation = BlockModelRotation.by(0, 180);
}
break;
}
}
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
"block/" + resourceLocation.getPath() + "_" + doorType);
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
Variant variant = new Variant(modelId, rotation.getRotation(), false, 1);
return new MultiVariant(Lists.newArrayList(variant));
}
@Override
public ResourceLocation statePatternId() {
return Patterns.STATE_DOOR;
}
protected DoorType getDoorType(BlockState blockState) {
boolean isHinge = isHinge(blockState.getValue(HINGE), blockState.getValue(OPEN));
switch (blockState.getValue(HALF)) {
case UPPER: {
return isHinge ? DoorType.TOP_HINGE : DoorType.TOP;
}
case LOWER: {
return isHinge ? DoorType.BOTTOM_HINGE : DoorType.BOTTOM;
}
}
return DoorType.BOTTOM;
}
private boolean isHinge(DoorHingeSide hingeSide, boolean open) {
boolean isHinge = hingeSide == DoorHingeSide.RIGHT;
return isHinge && !open || !isHinge && open;
}
protected enum DoorType implements StringRepresentable {
BOTTOM_HINGE("bottom_hinge"),
TOP_HINGE("top_hinge"),
BOTTOM("bottom"),
TOP("top");
private final String name;
DoorType(String name) {
this.name = name;
}
public boolean isHinge() {
return this == BOTTOM_HINGE ||
this == TOP_HINGE;
}
@Override
public String toString() {
return getSerializedName();
}
@Override
public String getSerializedName() {
return name;
}
}
}

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry;
@ -36,7 +37,7 @@ public class EndFenceBlock extends FenceBlock implements BlockModelProvider {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("item")) {

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@ -10,8 +11,8 @@ import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.stats.Stats;
@ -59,7 +60,7 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider,
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
Map<String, String> map = Maps.newHashMap();
map.put("%top%", blockId.getPath() + "_top");
@ -86,7 +87,7 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider,
Map<String, String> textures = Maps.newHashMap();
textures.put("%top%", blockName + "_top");
textures.put("%side%", blockName + "_side");
String pattern;
Optional<String> pattern;
if (blockState.getValue(LIT)) {
textures.put("%front%", blockName + "_front_on");
textures.put("%glow%", blockName + "_glow");
@ -95,7 +96,7 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider,
textures.put("%front%", blockName + "_front");
pattern = Patterns.createJson(Patterns.BLOCK_FURNACE, textures);
}
return BlockModel.fromString(pattern);
return pattern.map(BlockModel::fromString).orElse(null);
}
@Override
@ -104,11 +105,11 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider,
}
@Override
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
String lit = blockState.getValue(LIT) ? "_lit" : "";
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
"block/" + resourceLocation.getPath() + lit);
ModelsHelper.addBlockState(blockState, modelId);
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
return ModelsHelper.createFacingModel(modelId, blockState.getValue(FACING));
}

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry;
@ -36,7 +37,7 @@ public class EndGateBlock extends FenceGateBlock implements BlockModelProvider {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("wall")) {

View file

@ -1,6 +1,7 @@
package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
@ -144,7 +145,7 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import com.google.common.collect.Lists;
@ -60,7 +61,7 @@ public class EndLeavesBlock extends LeavesBlock implements BlockModelProvider, I
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
String blockId = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(Patterns.BLOCK_BASE, blockId, blockId);
}

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@ -37,7 +38,7 @@ public class EndMetalPaneBlock extends IronBarsBlock implements BlockModelProvid
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry;
@ -36,7 +37,7 @@ public class EndMetalPlateBlock extends WeightedPressurePlateBlock implements Bl
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("down")) {

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -78,7 +79,7 @@ public class EndOreBlock extends OreBlock implements BlockModelProvider {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
}

View file

@ -3,11 +3,13 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.core.Direction;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
@ -45,7 +47,7 @@ public class EndPillarBlock extends RotatedPillarBlock implements BlockModelProv
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
return createBlockPattern(blockId);
}
@ -57,18 +59,19 @@ public class EndPillarBlock extends RotatedPillarBlock implements BlockModelProv
@Override
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
return BlockModel.fromString(createBlockPattern(blockId));
Optional<String> pattern = createBlockPattern(blockId);
return pattern.map(BlockModel::fromString).orElse(null);
}
@Override
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
"block/" + resourceLocation.getPath());
ModelsHelper.addBlockState(blockState, modelId);
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
return ModelsHelper.createRotatedModel(modelId, blockState.getValue(AXIS));
}
protected String createBlockPattern(ResourceLocation blockId) {
protected Optional<String> createBlockPattern(ResourceLocation blockId) {
return Patterns.createBlockPillar(blockId.getPath());
}
}

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry;
@ -36,7 +37,7 @@ public class EndPlateBlock extends PressurePlateBlock implements BlockModelProvi
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("down")) {

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
@ -152,7 +153,7 @@ public class EndSignBlock extends SignBlock implements BlockModelProvider, ISpet
}
@Override
public String getModelString(String path) {
public Optional<String> getModelString(String path) {
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (path.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, path);

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry;
@ -36,7 +37,7 @@ public class EndSlabBlock extends SlabBlock implements BlockModelProvider {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
return Patterns.createJson(Patterns.BLOCK_SLAB, parentId.getPath(), blockId.getPath());

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry;
@ -37,16 +38,17 @@ public class EndStairsBlock extends StairBlock implements BlockModelProvider {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_STAIR, parentId.getPath(), blockId.getPath());
if (block.contains("inner")) {
return Patterns.createJson(Patterns.BLOCK_STAIR_INNER, parentId.getPath(), blockId.getPath());
pattern = Patterns.createJson(Patterns.BLOCK_STAIR_INNER, parentId.getPath(), blockId.getPath());
}
if (block.contains("outer")) {
return Patterns.createJson(Patterns.BLOCK_STAIR_OUTER, parentId.getPath(), blockId.getPath());
pattern = Patterns.createJson(Patterns.BLOCK_STAIR_OUTER, parentId.getPath(), blockId.getPath());
}
return Patterns.createJson(Patterns.BLOCK_STAIR, parentId.getPath(), blockId.getPath());
return pattern;
}
@Override

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry;
@ -36,7 +37,7 @@ public class EndStoneButtonBlock extends StoneButtonBlock implements BlockModelP
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("item")) {

View file

@ -4,6 +4,7 @@ import java.io.Reader;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry;
@ -40,7 +41,7 @@ public class EndTrapdoorBlock extends TrapDoorBlock implements IRenderTypeable,
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
String name = blockId.getPath();
return Patterns.createJson(Patterns.BLOCK_TRAPDOOR, new HashMap<String, String>() {

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry;
@ -37,7 +38,7 @@ public class EndWallBlock extends WallBlock implements BlockModelProvider {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("item")) {

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry;
@ -36,7 +37,7 @@ public class EndWoodenButtonBlock extends WoodButtonBlock implements BlockModelP
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
if (block.contains("item")) {

View file

@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
@ -116,7 +117,7 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements IRende
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
if (block.contains("item")) {
block = block.split("/")[1];
return Patterns.createJson(Patterns.ITEM_BLOCK, block);
@ -136,7 +137,7 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements IRende
@Override
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
String pattern = Patterns.createJson(Patterns.BLOCK_CROSS, resourceLocation.getPath());
return BlockModel.fromString(pattern);
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_CROSS, resourceLocation.getPath());
return pattern.map(BlockModel::fromString).orElse(null);
}
}

View file

@ -5,9 +5,11 @@ import java.io.Reader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.client.resources.model.UnbakedModel;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Lists;
@ -344,7 +346,7 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
Map<String, String> textures = createTexturesMap();
if (block.contains("column_top")) {
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
@ -369,7 +371,7 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
Map<String, String> textures = createTexturesMap();
PedestalState state = blockState.getValue(STATE);
String pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
switch (state) {
case COLUMN_TOP: {
pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
@ -392,15 +394,16 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
break;
}
}
return BlockModel.fromString(pattern);
return pattern.map(BlockModel::fromString).orElse(null);
}
@Override
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
PedestalState state = blockState.getValue(STATE);
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
"block/" + resourceLocation.getPath() + "_" + state);
return super.getModelVariant(modelId, blockState);
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
return ModelsHelper.createBlockSimple(modelId);
}
@Override

View file

@ -1,6 +1,7 @@
package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry;
@ -43,7 +44,7 @@ public class SimpleLeavesBlock extends BlockBaseNotFull implements IRenderTypeab
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
String texture = Registry.BLOCK.getKey(this).getPath();
return Patterns.createJson(Patterns.BLOCK_BASE, texture, texture);
}

View file

@ -33,6 +33,8 @@ import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class StalactiteBlock extends BlockBaseNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, IRenderTypeable {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR;
@ -192,7 +194,7 @@ public class StalactiteBlock extends BlockBaseNotFull implements SimpleWaterlogg
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
ResourceLocation blockId = Registry.BLOCK.getKey(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());

View file

@ -1,6 +1,7 @@
package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Optional;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.color.block.BlockColor;
@ -68,7 +69,7 @@ public class StoneLanternBlock extends EndLanternBlock implements IColorProvider
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
String texture = Registry.BLOCK.getKey(this).getPath();
if (block.contains("ceil")) {
return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_CEIL, texture, texture);

View file

@ -1,6 +1,7 @@
package ru.betterend.blocks.basis;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import com.google.common.collect.Maps;
@ -49,7 +50,7 @@ public class TripleTerrainBlock extends EndTerrainBlock {
}
@Override
public String getModelString(String block) {
public Optional<String> getModelString(String block) {
String name = Registry.BLOCK.getKey(this).getPath();
if (block.endsWith("_middle")) {
return Patterns.createJson(Patterns.BLOCK_BASE, name + "_top", name + "_top");

View file

@ -1,25 +1,45 @@
package ru.betterend.client.models;
import java.io.Reader;
import java.util.Map;
import java.util.Optional;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
import ru.betterend.BetterEnd;
import static net.minecraft.client.resources.model.ModelBakery.MISSING_MODEL_LOCATION;
public interface BlockModelProvider extends ModelProvider {
String getStatesPattern(Reader data);
ResourceLocation statePatternId();
@Nullable
default BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
String pattern = Patterns.createBlockSimple(resourceLocation.getPath());
return BlockModel.fromString(pattern);
Optional<String> pattern = Patterns.createBlockSimple(resourceLocation.getPath());
return pattern.map(BlockModel::fromString).orElse(null);
}
default MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
default MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
"block/" + resourceLocation.getPath());
ModelsHelper.addBlockState(blockState, modelId);
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
return ModelsHelper.createBlockSimple(modelId);
}
default void registerBlockModel(ResourceLocation stateId, ResourceLocation modelId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
if (!modelCache.containsKey(modelId)) {
BlockModel model = getBlockModel(stateId, blockState);
if (model != null) {
modelCache.put(modelId, model);
} else {
BetterEnd.LOGGER.warning("Error loading model: {}", modelId);
modelCache.put(modelId, modelCache.get(MISSING_MODEL_LOCATION));
}
}
}
}

View file

@ -3,15 +3,17 @@ package ru.betterend.client.models;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation;
import java.util.Optional;
public interface ModelProvider {
String getModelString(String name);
Optional<String> getModelString(String name);
default BlockModel getModel(ResourceLocation resourceLocation) {
return createItemModel(resourceLocation.getPath());
}
static BlockModel createItemModel(String name) {
String pattern = Patterns.createItemGenerated("item/" + name);
return BlockModel.fromString(pattern);
Optional<String> pattern = Patterns.createItemGenerated("item/" + name);
return pattern.map(BlockModel::fromString).orElse(null);
}
}

View file

@ -2,6 +2,9 @@ package ru.betterend.client.models;
import com.google.common.collect.*;
import com.mojang.math.Transformation;
import javafx.print.Collation;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.MultiVariant;
import net.minecraft.client.renderer.block.model.Variant;
@ -11,28 +14,15 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
@Environment(EnvType.CLIENT)
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);
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_BLOCK, resourceLocation.getPath());
return pattern.map(BlockModel::fromString).orElse(null);
}
public static MultiVariant createBlockSimple(ResourceLocation resourceLocation) {
@ -41,7 +31,7 @@ public class ModelsHelper {
}
public static MultiVariant createFacingModel(ResourceLocation resourceLocation, Direction facing) {
BlockModelRotation rotation = BlockModelRotation.by(0, (int) facing.toYRot());
BlockModelRotation rotation = BlockModelRotation.by(0, (int) facing.getOpposite().toYRot());
Variant variant = new Variant(resourceLocation, rotation.getRotation(), false, 1);
return new MultiVariant(Lists.newArrayList(variant));
}
@ -50,19 +40,15 @@ public class ModelsHelper {
BlockModelRotation rotation = BlockModelRotation.X0_Y0;
switch (axis) {
case X: {
rotation = BlockModelRotation.by(90, 0);
rotation = BlockModelRotation.by(90, 90);
break;
}
case Z: {
rotation = BlockModelRotation.by(90, 90);
rotation = BlockModelRotation.by(90, 0);
break;
}
}
Variant variant = new Variant(resourceLocation, rotation.getRotation(), false, 1);
return new MultiVariant(Lists.newArrayList(variant));
}
static {
STATES_MAP = HashBiMap.create();
}
}

View file

@ -7,6 +7,7 @@ import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.stream.Collectors;
import com.google.common.collect.Maps;
@ -117,14 +118,14 @@ public class Patterns {
public final static ResourceLocation ITEM_HANDHELD = BetterEnd.makeID("patterns/item/pattern_item_handheld.json");
public final static ResourceLocation ITEM_SPAWN_EGG = BetterEnd.makeID("patterns/item/pattern_item_spawn_egg.json");
public static String createItemGenerated(String name) {
public static Optional<String> createItemGenerated(String name) {
return createJson(ITEM_GENERATED, name);
}
public static String createBlockSimple(String name) {
public static Optional<String> createBlockSimple(String name) {
return Patterns.createJson(Patterns.BLOCK_BASE, name, name);
}
public static String createBlockPillar(String name) {
public static Optional<String> createBlockPillar(String name) {
return Patterns.createJson(Patterns.BLOCK_PILLAR, name, name);
}
@ -138,22 +139,22 @@ public class Patterns {
}
}
public static String createJson(ResourceLocation patternId, String parent, String block) {
public static Optional<String> createJson(ResourceLocation patternId, String parent, String block) {
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
return createJson(new InputStreamReader(input, StandardCharsets.UTF_8), parent, block);
return Optional.ofNullable(createJson(new InputStreamReader(input, StandardCharsets.UTF_8), parent, block));
} catch (Exception ex) {
return null;
return Optional.empty();
}
}
public static String createJson(ResourceLocation patternId, String texture) {
public static Optional<String> createJson(ResourceLocation patternId, String texture) {
Map<String, String> textures = Maps.newHashMap();
textures.put("%texture%", texture);
return createJson(patternId, textures);
}
public static String createJson(ResourceLocation patternId, Map<String, String> textures) {
public static Optional<String> createJson(ResourceLocation patternId, Map<String, String> textures) {
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))
@ -161,9 +162,9 @@ public class Patterns {
for (Entry<String, String> texture : textures.entrySet()) {
json = json.replace(texture.getKey(), texture.getValue());
}
return json;
return Optional.of(json);
} catch (Exception ex) {
return "";
return Optional.empty();
}
}

View file

@ -0,0 +1,17 @@
package ru.betterend.events;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.advancements.Advancement;
import net.minecraft.server.level.ServerPlayer;
public interface PlayerAdvancementsCallback {
Event<PlayerAdvancementsCallback> PLAYER_ADVANCEMENT_COMPLETE = EventFactory.createArrayBacked(PlayerAdvancementsCallback.class, callbacks -> (player, advancement, criterionName) -> {
for (PlayerAdvancementsCallback event : callbacks) {
event.onAdvancementComplete(player, advancement, criterionName);
}
});
void onAdvancementComplete(ServerPlayer player, Advancement advancement, String criterionName);
}

View file

@ -1,19 +0,0 @@
package ru.betterend.events;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.advancements.Advancement;
import net.minecraft.server.level.ServerPlayer;
public final class PlayerAdvancementsEvents {
public static Event<AdvancementComplete> PLAYER_ADVENCEMENT_COMPLETE = EventFactory.createArrayBacked(AdvancementComplete.class, callbacks -> (player, advancement, criterionName) -> {
for (AdvancementComplete event : callbacks) {
event.onAdvancementComplete(player, advancement, criterionName);
}
});
public interface AdvancementComplete {
void onAdvancementComplete(ServerPlayer player, Advancement advancement, String criterionName);
}
}

View file

@ -8,6 +8,8 @@ import ru.betterend.client.models.ModelProvider;
import ru.betterend.client.models.Patterns;
import ru.betterend.registry.EndItems;
import java.util.Optional;
public class EnchantedPetalItem extends ModelProviderItem {
public EnchantedPetalItem() {
super(EndItems.makeItemSettings().rarity(Rarity.RARE).stacksTo(16));
@ -19,7 +21,7 @@ public class EnchantedPetalItem extends ModelProviderItem {
}
@Override
public String getModelString(String name) {
public Optional<String> getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/hydralux_petal");
}

View file

@ -12,6 +12,7 @@ import net.minecraft.world.item.ArmorMaterial;
import ru.betterend.client.models.ModelProvider;
import ru.betterend.client.models.Patterns;
import java.util.Optional;
import java.util.UUID;
public class EndArmorItem extends ArmorItem implements ModelProvider {
@ -49,7 +50,7 @@ public class EndArmorItem extends ArmorItem implements ModelProvider {
}
@Override
public String getModelString(String name) {
public Optional<String> getModelString(String name) {
return Patterns.createItemGenerated(name);
}
}

View file

@ -7,13 +7,15 @@ import ru.betterend.client.models.ModelProvider;
import ru.betterend.client.models.Patterns;
import ru.betterend.registry.EndItems;
import java.util.Optional;
public class EndBucketItem extends FishBucketItem implements ModelProvider {
public EndBucketItem(EntityType<?> type) {
super(type, Fluids.WATER, EndItems.makeItemSettings().stacksTo(1));
}
@Override
public String getModelString(String name) {
public Optional<String> getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_GENERATED, name);
}
}

View file

@ -7,19 +7,21 @@ import net.minecraft.world.item.SpawnEggItem;
import ru.betterend.client.models.ModelProvider;
import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class EndSpawnEggItem extends SpawnEggItem implements ModelProvider {
public EndSpawnEggItem(EntityType<?> type, int primaryColor, int secondaryColor, Properties settings) {
super(type, primaryColor, secondaryColor, settings);
}
@Override
public String getModelString(String name) {
public Optional<String> getModelString(String 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);
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_SPAWN_EGG, resourceLocation.getPath());
return pattern.map(BlockModel::fromString).orElse(null);
}
}

View file

@ -5,13 +5,15 @@ import net.minecraft.world.item.RecordItem;
import ru.betterend.client.models.ModelProvider;
import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class ModelProviderDiscItem extends RecordItem implements ModelProvider {
public ModelProviderDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) {
super(comparatorOutput, sound, settings);
}
@Override
public String getModelString(String name) {
public Optional<String> getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_GENERATED, name);
}
}

View file

@ -6,13 +6,15 @@ import net.minecraft.world.item.Item;
import ru.betterend.client.models.ModelProvider;
import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class ModelProviderItem extends Item implements ModelProvider {
public ModelProviderItem(Properties settings) {
super(settings);
}
@Override
public String getModelString(String name) {
public Optional<String> getModelString(String name) {
return Patterns.createItemGenerated(name);
}

View file

@ -12,6 +12,8 @@ import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.client.models.ModelProvider;
import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class EndAxeItem extends AxeItem implements DynamicAttributeTool, ModelProvider {
public EndAxeItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings);
@ -26,7 +28,7 @@ public class EndAxeItem extends AxeItem implements DynamicAttributeTool, ModelPr
}
@Override
public String getModelString(String name) {
public Optional<String> getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
}
}

View file

@ -1,5 +1,6 @@
package ru.betterend.item.tool;
import java.util.Optional;
import java.util.UUID;
import com.google.common.collect.ImmutableMultimap;
@ -135,7 +136,7 @@ public class EndHammerItem extends DiggerItem implements DynamicAttributeTool, M
}
@Override
public String getModelString(String name) {
public Optional<String> getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
}
}

View file

@ -5,13 +5,15 @@ import net.minecraft.world.item.Tier;
import ru.betterend.client.models.ModelProvider;
import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class EndHoeItem extends HoeItem implements ModelProvider {
public EndHoeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings);
}
@Override
public String getModelString(String name) {
public Optional<String> getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
}
}

View file

@ -15,6 +15,8 @@ import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.client.models.ModelProvider;
import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool, ModelProvider {
public EndPickaxeItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings);
@ -38,7 +40,7 @@ public class EndPickaxeItem extends PickaxeItem implements DynamicAttributeTool,
}
@Override
public String getModelString(String name) {
public Optional<String> getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
}
}

View file

@ -14,6 +14,8 @@ import net.minecraft.world.level.block.state.BlockState;
import ru.betterend.client.models.ModelProvider;
import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, ModelProvider {
public EndShovelItem(Tier material, float attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings);
@ -34,7 +36,7 @@ public class EndShovelItem extends ShovelItem implements DynamicAttributeTool, M
}
@Override
public String getModelString(String name) {
public Optional<String> getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
}
}

View file

@ -6,13 +6,15 @@ import net.minecraft.world.item.Tier;
import ru.betterend.client.models.ModelProvider;
import ru.betterend.client.models.Patterns;
import java.util.Optional;
public class EndSwordItem extends SwordItem implements DynamicAttributeTool, ModelProvider {
public EndSwordItem(Tier material, int attackDamage, float attackSpeed, Properties settings) {
super(material, attackDamage, attackSpeed, settings);
}
@Override
public String getModelString(String name) {
public Optional<String> getModelString(String name) {
return Patterns.createJson(Patterns.ITEM_HANDHELD, name);
}
}

View file

@ -23,9 +23,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.betterend.BetterEnd;
import ru.betterend.client.models.BlockModelProvider;
import ru.betterend.client.models.ModelProvider;
import ru.betterend.client.models.ModelsHelper;
import ru.betterend.world.generator.GeneratorOptions;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;
import java.util.Objects;
@ -47,13 +47,13 @@ public abstract class ModelLoaderMixin {
protected abstract BlockModel loadBlockModel(ResourceLocation resourceLocation);
@Inject(method = "loadModel", at = @At("HEAD"), cancellable = true)
private void be_loadModels(ResourceLocation resourceLocation, CallbackInfo info) {
private void be_loadModels(ResourceLocation resourceLocation, CallbackInfo info) throws IOException {
if (resourceLocation instanceof ModelResourceLocation) {
String modId = resourceLocation.getNamespace();
String path = resourceLocation.getPath();
ResourceLocation clearLoc = new ResourceLocation(modId, path);
ModelResourceLocation modelLoc = (ModelResourceLocation) resourceLocation;
if (Objects.equals(modelLoc.getVariant(), "inventory")) {
ModelResourceLocation modelId = (ModelResourceLocation) resourceLocation;
if (Objects.equals(modelId.getVariant(), "inventory")) {
ResourceLocation itemLoc = new ResourceLocation(modId, "item/" + path);
ResourceLocation itemModelLoc = new ResourceLocation(modId, "models/" + itemLoc.getPath() + ".json");
if (!resourceManager.hasResource(itemModelLoc)) {
@ -62,54 +62,41 @@ public abstract class ModelLoaderMixin {
BlockModel model = ((ModelProvider) item).getModel(clearLoc);
if (model != null) {
model.name = itemLoc.toString();
} else {
model = loadBlockModel(itemLoc);
}
cacheAndQueueDependencies(modelLoc, model);
cacheAndQueueDependencies(modelId, model);
unbakedCache.put(itemLoc, model);
} else {
BetterEnd.LOGGER.warning("Error loading model: {}", itemLoc);
}
info.cancel();
}
}
} else {
ResourceLocation blockstateId = new ResourceLocation(modId, "blockstates/" + path + ".json");
if (!resourceManager.hasResource(blockstateId)) {
ResourceLocation stateLoc = new ResourceLocation(modId, "blockstates/" + path + ".json");
if (!resourceManager.hasResource(stateLoc)) {
Block block = Registry.BLOCK.get(clearLoc);
if (block instanceof BlockModelProvider) {
block.getStateDefinition().getPossibleStates().forEach(blockState -> {
System.out.println(blockState);
ModelResourceLocation stateLoc = BlockModelShaper.stateToModelLocation(clearLoc, blockState);
MultiVariant modelVariant = ((BlockModelProvider) block).getModelVariant(stateLoc, blockState);
Optional<BlockState> stateOptional = block.getStateDefinition().getPossibleStates().stream()
.filter(state -> modelId.equals(BlockModelShaper.stateToModelLocation(clearLoc, state)))
.findFirst();
if (stateOptional.isPresent()) {
MultiVariant modelVariant = ((BlockModelProvider) block).getModelVariant(modelId, stateOptional.get(), unbakedCache);
if (modelVariant != null) {
cacheAndQueueDependencies(stateLoc, modelVariant);
cacheAndQueueDependencies(modelId, modelVariant);
} else {
BetterEnd.LOGGER.warning("Error loading variant: {}", stateLoc);
BetterEnd.LOGGER.warning("Error loading variant: {}", modelId);
}
});
info.cancel();
}
}
}
}
}
}
@Inject(method = "loadBlockModel", at = @At("HEAD"), cancellable = true)
private void be_loadModelPattern(ResourceLocation modelId, CallbackInfoReturnable<BlockModel> info) {
private void be_loadModelPattern(ResourceLocation modelId, CallbackInfoReturnable<BlockModel> info) throws IOException {
ResourceLocation modelLocation = new ResourceLocation(modelId.getNamespace(), "models/" + modelId.getPath() + ".json");
if (!resourceManager.hasResource(modelLocation)) {
BlockState blockState = ModelsHelper.getBlockState(modelId);
if (blockState != null) {
Block block = blockState.getBlock();
if (block instanceof BlockModelProvider) {
ResourceLocation blockId = Registry.BLOCK.getKey(block);
BlockModel model = ((BlockModelProvider) block).getBlockModel(blockId, blockState);
if (model != null) {
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) {
ResourceLocation itemId = new ResourceLocation(modelId.getNamespace(), data[1]);
@ -117,15 +104,22 @@ public abstract class ModelLoaderMixin {
if (block.isPresent()) {
if (block.get() instanceof ModelProvider) {
ModelProvider modelProvider = (ModelProvider) block.get();
BlockModel model = be_getModel(data, modelId, modelProvider);
info.setReturnValue(model);
Optional<BlockModel> model = be_getModel(data, modelId, modelProvider);
if (model.isPresent()) {
info.setReturnValue(model.get());
} else {
throw new FileNotFoundException("Error loading model: " + modelId);
}
}
} else {
Optional<Item> item = Registry.ITEM.getOptional(itemId);
if (item.isPresent() && item.get() instanceof ModelProvider) {
ModelProvider modelProvider = (ModelProvider) item.get();
BlockModel model = be_getModel(data, modelId, modelProvider);
info.setReturnValue(model);
Optional<BlockModel> model = be_getModel(data, modelId, modelProvider);
if (model.isPresent()) {
info.setReturnValue(model.get());
} else {
throw new FileNotFoundException("Error loading model: " + modelId);
}
}
}
@ -133,8 +127,8 @@ public abstract class ModelLoaderMixin {
}
}
private BlockModel be_getModel(String[] data, ResourceLocation id, ModelProvider modelProvider) {
String pattern;
private Optional<BlockModel> be_getModel(String[] data, ResourceLocation id, ModelProvider modelProvider) {
Optional<String> pattern;
if (id.getPath().contains("item")) {
pattern = modelProvider.getModelString(id.getPath());
} else {
@ -144,10 +138,12 @@ public abstract class ModelLoaderMixin {
pattern = modelProvider.getModelString(data[1]);
}
}
BlockModel model = BlockModel.fromString(pattern);
if (pattern.isPresent()) {
BlockModel model = BlockModel.fromString(pattern.get());
model.name = id.toString();
return model;
return Optional.of(model);
}
return Optional.empty();
}
@ModifyVariable(method = "loadModel", ordinal = 2, at = @At(value = "INVOKE"))

View file

@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.advancements.Advancement;
import net.minecraft.server.PlayerAdvancements;
import net.minecraft.server.level.ServerPlayer;
import ru.betterend.events.PlayerAdvancementsEvents;
import ru.betterend.events.PlayerAdvancementsCallback;
@Mixin(PlayerAdvancements.class)
public abstract class PlayerAdvancementsMixin {
@ -22,6 +22,6 @@ public abstract class PlayerAdvancementsMixin {
target = "Lnet/minecraft/advancements/AdvancementRewards;grant(Lnet/minecraft/server/level/ServerPlayer;)V",
shift = Shift.AFTER))
public void be_award(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> info) {
PlayerAdvancementsEvents.PLAYER_ADVENCEMENT_COMPLETE.invoker().onAdvancementComplete(player, advancement, criterionName);
PlayerAdvancementsCallback.PLAYER_ADVANCEMENT_COMPLETE.invoker().onAdvancementComplete(player, advancement, criterionName);
}
}

View file

@ -1,9 +1,6 @@
package ru.betterend.registry;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.core.BlockSource;
@ -20,42 +17,19 @@ import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.food.Foods;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.ShovelItem;
import net.minecraft.world.item.SpawnEggItem;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.TieredItem;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.item.*;
import net.minecraft.world.level.block.DispenserBlock;
import ru.betterend.BetterEnd;
import ru.betterend.config.Configs;
import ru.betterend.item.ArmoredElytra;
import ru.betterend.item.CrystaliteBoots;
import ru.betterend.item.CrystaliteChestplate;
import ru.betterend.item.CrystaliteHelmet;
import ru.betterend.item.CrystaliteLeggings;
import ru.betterend.item.DrinkItem;
import ru.betterend.item.EnchantedPetalItem;
import ru.betterend.item.EndArmorItem;
import ru.betterend.item.EndBucketItem;
import ru.betterend.item.EndSpawnEggItem;
import ru.betterend.item.EternalCrystalItem;
import ru.betterend.item.PatternedDiscItem;
import ru.betterend.item.PatternedItem;
import ru.betterend.item.*;
import ru.betterend.item.material.EndArmorMaterial;
import ru.betterend.item.material.EndToolMaterial;
import ru.betterend.item.tool.EndAxeItem;
import ru.betterend.item.tool.EndHammerItem;
import ru.betterend.item.tool.EndHoeItem;
import ru.betterend.item.tool.EndPickaxeItem;
import ru.betterend.item.tool.EndShovelItem;
import ru.betterend.item.tool.EndSwordItem;
import ru.betterend.item.tool.*;
import ru.betterend.tab.CreativeTabs;
import ru.betterend.util.TagHelper;
import java.util.List;
public class EndItems {
private static final List<Item> MOD_BLOCKS = Lists.newArrayList();
private static final List<Item> MOD_ITEMS = Lists.newArrayList();