Items and Blocks registries (WIP)
This commit is contained in:
parent
41df84404b
commit
a3e781b401
34 changed files with 313 additions and 1771 deletions
|
@ -45,8 +45,6 @@ public class BetterEnd implements ModInitializer {
|
|||
public void onInitialize() {
|
||||
EndPortals.loadPortals();
|
||||
EndSounds.register();
|
||||
EndItems.register();
|
||||
EndBlocks.register();
|
||||
EndBlockEntities.register();
|
||||
EndFeatures.register();
|
||||
EndEntities.register();
|
||||
|
|
|
@ -1,132 +1,10 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.monster.piglin.PiglinAi;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BarrelBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import ru.betterend.blocks.entities.EBarrelBlockEntity;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
import ru.bclib.blocks.BaseBarrelBlock;
|
||||
|
||||
public class EndBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
||||
public class EndBarrelBlock extends BaseBarrelBlock {
|
||||
public EndBarrelBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).noOcclusion());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockGetter world) {
|
||||
return EndBlockEntities.BARREL.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> drop = super.getDrops(state, builder);
|
||||
drop.add(new ItemStack(this.asItem()));
|
||||
return drop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand,
|
||||
BlockHitResult hit) {
|
||||
if (world.isClientSide) {
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof EBarrelBlockEntity) {
|
||||
player.openMenu((EBarrelBlockEntity) blockEntity);
|
||||
player.awardStat(Stats.OPEN_BARREL);
|
||||
PiglinAi.angerNearbyPiglins(player, true);
|
||||
}
|
||||
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof EBarrelBlockEntity) {
|
||||
((EBarrelBlockEntity) blockEntity).tick();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state) {
|
||||
return RenderShape.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer,
|
||||
ItemStack itemStack) {
|
||||
if (itemStack.hasCustomHoverName()) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof EBarrelBlockEntity) {
|
||||
((EBarrelBlockEntity) blockEntity).setCustomName(itemStack.getHoverName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return getBlockModel(blockId, defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
String texture = blockId.getPath();
|
||||
Optional<String> pattern;
|
||||
if (blockState.getValue(OPEN)) {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture);
|
||||
} else {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_BOTTOM_TOP, texture, texture);
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String open = blockState.getValue(OPEN) ? "_open" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + open);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
Direction facing = blockState.getValue(FACING);
|
||||
BlockModelRotation rotation = BlockModelRotation.X0_Y0;
|
||||
switch (facing) {
|
||||
case NORTH: rotation = BlockModelRotation.X90_Y0; break;
|
||||
case EAST: rotation = BlockModelRotation.X90_Y90; break;
|
||||
case SOUTH: rotation = BlockModelRotation.X90_Y180; break;
|
||||
case WEST: rotation = BlockModelRotation.X90_Y270; break;
|
||||
case DOWN: rotation = BlockModelRotation.X180_Y0; break;
|
||||
default: break;
|
||||
}
|
||||
return ModelsHelper.createMultiVariant(modelId, rotation.getRotation(), false);
|
||||
super(source);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,42 +16,14 @@ import net.minecraft.world.level.block.ChestBlock;
|
|||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.bclib.blocks.BaseChestBlock;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
public class EndChestBlock extends ChestBlock implements BlockModelProvider {
|
||||
private final Block parent;
|
||||
|
||||
public class EndChestBlock extends BaseChestBlock {
|
||||
public EndChestBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).noOcclusion(), () -> EndBlockEntities.CHEST);
|
||||
this.parent = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockGetter world)
|
||||
{
|
||||
return EndBlockEntities.CHEST.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder)
|
||||
{
|
||||
List<ItemStack> drop = super.getDrops(state, builder);
|
||||
drop.add(new ItemStack(this.asItem()));
|
||||
return drop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_CHEST, blockId.getPath());
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return ModelsHelper.createBlockEmpty(parentId);
|
||||
super(source);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,104 +1,10 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.FurnaceBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import ru.betterend.blocks.entities.EFurnaceBlockEntity;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.bclib.blocks.BaseFurnaceBlock;
|
||||
|
||||
public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider, IRenderTypeable {
|
||||
public class EndFurnaceBlock extends BaseFurnaceBlock {
|
||||
public EndFurnaceBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).luminance(state -> state.getValue(LIT) ? 13 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockGetter world) {
|
||||
return new EFurnaceBlockEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void openContainer(Level world, BlockPos pos, Player player) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof EFurnaceBlockEntity) {
|
||||
player.openMenu((MenuProvider) blockEntity);
|
||||
player.awardStat(Stats.INTERACT_WITH_FURNACE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
String blockName = blockId.getPath();
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%top%", blockName + "_top");
|
||||
textures.put("%side%", blockName + "_side");
|
||||
Optional<String> pattern;
|
||||
if (blockState.getValue(LIT)) {
|
||||
textures.put("%front%", blockName + "_front_on");
|
||||
textures.put("%glow%", blockName + "_glow");
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_FURNACE_LIT, textures);
|
||||
} else {
|
||||
textures.put("%front%", blockName + "_front");
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_FURNACE, textures);
|
||||
}
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return getBlockModel(resourceLocation, defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String lit = blockState.getValue(LIT) ? "_lit" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(),
|
||||
"block/" + stateId.getPath() + lit);
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createFacingModel(modelId, blockState.getValue(FACING), false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
|
||||
BlockEntity blockEntity = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
|
||||
if (blockEntity instanceof EFurnaceBlockEntity) {
|
||||
EFurnaceBlockEntity entity = (EFurnaceBlockEntity) blockEntity;
|
||||
for (int i = 0; i < entity.getContainerSize(); i++) {
|
||||
drop.add(entity.getItem(i));
|
||||
}
|
||||
}
|
||||
return drop;
|
||||
super(source);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndPathBlock extends BlockBaseNotFull {
|
||||
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 15, 16);
|
||||
|
||||
public EndPathBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).isValidSpawn((state, world, pos, type) -> { return false; }));
|
||||
if (source instanceof EndTerrainBlock) {
|
||||
EndTerrainBlock terrain = (EndTerrainBlock) source;
|
||||
terrain.setPathBlock(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||
if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
return Collections.singletonList(new ItemStack(Blocks.END_STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return getBlockModel(blockId, defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
String name = resourceLocation.getPath();
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%top%", name + "_top");
|
||||
textures.put("%side%", name.replace("_path", "") + "_side");
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_PATH, textures);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createRandomTopModel(modelId);
|
||||
}
|
||||
}
|
|
@ -1,197 +1,10 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.protocol.game.ClientboundOpenSignEditorPacket;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.SignBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.block.state.properties.WoodType;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import ru.betterend.blocks.entities.ESignBlockEntity;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.interfaces.ISpetialItem;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.bclib.blocks.BaseSignBlock;
|
||||
|
||||
public class EndSignBlock extends SignBlock implements BlockModelProvider, ISpetialItem {
|
||||
public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16;
|
||||
public static final BooleanProperty FLOOR = BooleanProperty.create("floor");
|
||||
private static final VoxelShape[] WALL_SHAPES = new VoxelShape[] {
|
||||
Block.box(0.0D, 4.5D, 14.0D, 16.0D, 12.5D, 16.0D),
|
||||
Block.box(0.0D, 4.5D, 0.0D, 2.0D, 12.5D, 16.0D),
|
||||
Block.box(0.0D, 4.5D, 0.0D, 16.0D, 12.5D, 2.0D),
|
||||
Block.box(14.0D, 4.5D, 0.0D, 16.0D, 12.5D, 16.0D)
|
||||
};
|
||||
|
||||
private final Block parent;
|
||||
|
||||
public class EndSignBlock extends BaseSignBlock {
|
||||
public EndSignBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).strength(1.0F, 1.0F).noCollission().noOcclusion(), WoodType.OAK);
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(ROTATION, 0).setValue(FLOOR, false).setValue(WATERLOGGED, false));
|
||||
this.parent = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(ROTATION, FLOOR, WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
return state.getValue(FLOOR) ? SHAPE : WALL_SHAPES[state.getValue(ROTATION) >> 2];
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockGetter world) {
|
||||
return new ESignBlockEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
|
||||
if (placer instanceof Player) {
|
||||
ESignBlockEntity sign = (ESignBlockEntity) world.getBlockEntity(pos);
|
||||
if (sign != null) {
|
||||
if (!world.isClientSide) {
|
||||
sign.setAllowedPlayerEditor((Player) placer);
|
||||
((ServerPlayer) placer).connection.send(new ClientboundOpenSignEditorPacket(pos));
|
||||
} else {
|
||||
sign.setEditable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
|
||||
if ((Boolean) state.getValue(WATERLOGGED)) {
|
||||
world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
||||
}
|
||||
if (!canSurvive(state, world, pos)) {
|
||||
return state.getValue(WATERLOGGED) ? state.getFluidState().createLegacyBlock() : Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
return super.updateShape(state, facing, neighborState, world, pos, neighborPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
if (!state.getValue(FLOOR)) {
|
||||
int index = (((state.getValue(ROTATION) >> 2) + 2)) & 3;
|
||||
return world.getBlockState(pos.relative(BlocksHelper.HORIZONTAL[index])).getMaterial().isSolid();
|
||||
}
|
||||
else {
|
||||
return world.getBlockState(pos.below()).getMaterial().isSolid();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
|
||||
if (ctx.getClickedFace() == Direction.UP) {
|
||||
FluidState fluidState = ctx.getLevel().getFluidState(ctx.getClickedPos());
|
||||
return this.defaultBlockState().setValue(FLOOR, true)
|
||||
.setValue(ROTATION, Mth.floor((180.0 + ctx.getRotation() * 16.0 / 360.0) + 0.5 - 12) & 15)
|
||||
.setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER);
|
||||
}
|
||||
else if (ctx.getClickedFace() != Direction.DOWN) {
|
||||
BlockState blockState = this.defaultBlockState();
|
||||
FluidState fluidState = ctx.getLevel().getFluidState(ctx.getClickedPos());
|
||||
LevelReader worldView = ctx.getLevel();
|
||||
BlockPos blockPos = ctx.getClickedPos();
|
||||
Direction[] directions = ctx.getNearestLookingDirections();
|
||||
|
||||
for (Direction direction : directions) {
|
||||
if (direction.getAxis().isHorizontal()) {
|
||||
Direction dir = direction.getOpposite();
|
||||
int rot = Mth.floor((180.0 + dir.toYRot() * 16.0 / 360.0) + 0.5 + 4) & 15;
|
||||
blockState = blockState.setValue(ROTATION, rot);
|
||||
if (blockState.canSurvive(worldView, blockPos)) {
|
||||
return blockState.setValue(FLOOR, false).setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return ModelsHelper.createBlockEmpty(parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, Rotation rotation) {
|
||||
return (BlockState) state.setValue(ROTATION, rotation.rotate((Integer) state.getValue(ROTATION), 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState mirror(BlockState state, Mirror mirror) {
|
||||
return (BlockState) state.setValue(ROTATION, mirror.mirror((Integer) state.getValue(ROTATION), 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fluid takeLiquid(LevelAccessor world, BlockPos pos, BlockState state) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceLiquid(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeLiquid(LevelAccessor world, BlockPos pos, BlockState state, FluidState fluidState) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackSize() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOnWater() {
|
||||
return false;
|
||||
super(source);
|
||||
}
|
||||
}
|
|
@ -38,87 +38,13 @@ import net.minecraft.world.level.material.MaterialColor;
|
|||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import ru.bclib.blocks.BaseTerrainBlock;
|
||||
import ru.betterend.blocks.BlockSounds;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
public class EndTerrainBlock extends BlockBase {
|
||||
private Block pathBlock;
|
||||
|
||||
public class EndTerrainBlock extends BaseTerrainBlock {
|
||||
public EndTerrainBlock(MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sound(BlockSounds.TERRAIN_SOUND).randomTicks());
|
||||
}
|
||||
|
||||
public void setPathBlock(Block roadBlock) {
|
||||
this.pathBlock = roadBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (pathBlock != null && player.getMainHandItem().getItem().is(FabricToolTags.SHOVELS)) {
|
||||
world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
if (!world.isClientSide) {
|
||||
world.setBlockAndUpdate(pos, pathBlock.defaultBlockState());
|
||||
if (!player.isCreative()) {
|
||||
player.getMainHandItem().hurt(1, world.random, (ServerPlayer) player);
|
||||
}
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||
if (tool != null && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
return Collections.singletonList(new ItemStack(Blocks.END_STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||
if (random.nextInt(16) == 0 && !canStay(state, world, pos)) {
|
||||
world.setBlockAndUpdate(pos, Blocks.END_STONE.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canStay(BlockState state, LevelReader worldView, BlockPos pos) {
|
||||
BlockPos blockPos = pos.above();
|
||||
BlockState blockState = worldView.getBlockState(blockPos);
|
||||
if (blockState.is(Blocks.SNOW) && (Integer) blockState.getValue(SnowLayerBlock.LAYERS) == 1) {
|
||||
return true;
|
||||
}
|
||||
else if (blockState.getFluidState().getAmount() == 8) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
int i = LayerLightEngine.getLightBlockInto(worldView, state, pos, blockState, blockPos, Direction.UP, blockState.getLightBlock(worldView, blockPos));
|
||||
return i < 5;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockModel getItemModel(ResourceLocation blockId) {
|
||||
return getBlockModel(blockId, defaultBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
String name = resourceLocation.getPath();
|
||||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%top%", "betterend:block/" + name + "_top");
|
||||
textures.put("%side%", "betterend:block/" + name + "_side");
|
||||
textures.put("%bottom%", "minecraft:block/end_stone");
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_TOP_SIDE_BOTTOM, textures);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createRandomTopModel(modelId);
|
||||
super(Blocks.END_STONE, color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,19 +85,19 @@ public class MetalMaterial {
|
|||
public final Item boots;
|
||||
|
||||
public static MetalMaterial makeNormal(String name, MaterialColor color, Tier material, ArmorMaterial armor) {
|
||||
return new MetalMaterial(name, true, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color), EndItems.makeItemSettings(), material, armor);
|
||||
return new MetalMaterial(name, true, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color), EndItems.makeEndItemSettings(), material, armor);
|
||||
}
|
||||
|
||||
public static MetalMaterial makeNormal(String name, MaterialColor color, float hardness, float resistance, Tier material, ArmorMaterial armor) {
|
||||
return new MetalMaterial(name, true, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color).hardness(hardness).resistance(resistance), EndItems.makeItemSettings(), material, armor);
|
||||
return new MetalMaterial(name, true, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color).hardness(hardness).resistance(resistance), EndItems.makeEndItemSettings(), material, armor);
|
||||
}
|
||||
|
||||
public static MetalMaterial makeOreless(String name, MaterialColor color, Tier material, ArmorMaterial armor) {
|
||||
return new MetalMaterial(name, false, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color), EndItems.makeItemSettings(), material, armor);
|
||||
return new MetalMaterial(name, false, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color), EndItems.makeEndItemSettings(), material, armor);
|
||||
}
|
||||
|
||||
public static MetalMaterial makeOreless(String name, MaterialColor color, float hardness, float resistance, Tier material, ArmorMaterial armor) {
|
||||
return new MetalMaterial(name, false, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color).hardness(hardness).resistance(resistance), EndItems.makeItemSettings(), material, armor);
|
||||
return new MetalMaterial(name, false, FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).materialColor(color).hardness(hardness).resistance(resistance), EndItems.makeEndItemSettings(), material, armor);
|
||||
}
|
||||
|
||||
private MetalMaterial(String name, boolean hasOre, FabricBlockSettings settings, Properties itemSettings, Tier material, ArmorMaterial armor) {
|
||||
|
@ -120,28 +120,28 @@ public class MetalMaterial {
|
|||
bulb_lantern = EndBlocks.registerBlock(name + "_bulb_lantern", new BulbVineLanternBlock(lanternProperties));
|
||||
bulb_lantern_colored = new ColoredMaterial(BulbVineLanternColoredBlock::new, bulb_lantern, false);
|
||||
|
||||
nugget = EndItems.registerItem(name + "_nugget", new ModelProviderItem(itemSettings));
|
||||
ingot = EndItems.registerItem(name + "_ingot", new ModelProviderItem(itemSettings));
|
||||
nugget = EndItems.registerEndItem(name + "_nugget", new ModelProviderItem(itemSettings));
|
||||
ingot = EndItems.registerEndItem(name + "_ingot", new ModelProviderItem(itemSettings));
|
||||
|
||||
shovelHead = EndItems.registerItem(name + "_shovel_head");
|
||||
pickaxeHead = EndItems.registerItem(name + "_pickaxe_head");
|
||||
axeHead = EndItems.registerItem(name + "_axe_head");
|
||||
hoeHead = EndItems.registerItem(name + "_hoe_head");
|
||||
swordBlade = EndItems.registerItem(name + "_sword_blade");
|
||||
swordHandle = EndItems.registerItem(name + "_sword_handle");
|
||||
shovelHead = EndItems.registerEndItem(name + "_shovel_head");
|
||||
pickaxeHead = EndItems.registerEndItem(name + "_pickaxe_head");
|
||||
axeHead = EndItems.registerEndItem(name + "_axe_head");
|
||||
hoeHead = EndItems.registerEndItem(name + "_hoe_head");
|
||||
swordBlade = EndItems.registerEndItem(name + "_sword_blade");
|
||||
swordHandle = EndItems.registerEndItem(name + "_sword_handle");
|
||||
|
||||
shovel = EndItems.registerTool(name + "_shovel", new EndShovelItem(material, 1.5F, -3.0F, itemSettings));
|
||||
sword = EndItems.registerTool(name + "_sword", new EndSwordItem(material, 3, -2.4F, itemSettings));
|
||||
pickaxe = EndItems.registerTool(name + "_pickaxe", new EndPickaxeItem(material, 1, -2.8F, itemSettings));
|
||||
axe = EndItems.registerTool(name + "_axe", new EndAxeItem(material, 6.0F, -3.0F, itemSettings));
|
||||
hoe = EndItems.registerTool(name + "_hoe", new EndHoeItem(material, -3, 0.0F, itemSettings));
|
||||
hammer = EndItems.registerTool(name + "_hammer", new EndHammerItem(material, 5.0F, -3.2F, 0.3D, itemSettings));
|
||||
shovel = EndItems.registerEndTool(name + "_shovel", new EndShovelItem(material, 1.5F, -3.0F, itemSettings));
|
||||
sword = EndItems.registerEndTool(name + "_sword", new EndSwordItem(material, 3, -2.4F, itemSettings));
|
||||
pickaxe = EndItems.registerEndTool(name + "_pickaxe", new EndPickaxeItem(material, 1, -2.8F, itemSettings));
|
||||
axe = EndItems.registerEndTool(name + "_axe", new EndAxeItem(material, 6.0F, -3.0F, itemSettings));
|
||||
hoe = EndItems.registerEndTool(name + "_hoe", new EndHoeItem(material, -3, 0.0F, itemSettings));
|
||||
hammer = EndItems.registerEndTool(name + "_hammer", new EndHammerItem(material, 5.0F, -3.2F, 0.3D, itemSettings));
|
||||
|
||||
forgedPlate = EndItems.registerItem(name + "_forged_plate");
|
||||
helmet = EndItems.registerItem(name + "_helmet", new EndArmorItem(armor, EquipmentSlot.HEAD, itemSettings));
|
||||
chestplate = EndItems.registerItem(name + "_chestplate", new EndArmorItem(armor, EquipmentSlot.CHEST, itemSettings));
|
||||
leggings = EndItems.registerItem(name + "_leggings", new EndArmorItem(armor, EquipmentSlot.LEGS, itemSettings));
|
||||
boots = EndItems.registerItem(name + "_boots", new EndArmorItem(armor, EquipmentSlot.FEET, itemSettings));
|
||||
forgedPlate = EndItems.registerEndItem(name + "_forged_plate");
|
||||
helmet = EndItems.registerEndItem(name + "_helmet", new EndArmorItem(armor, EquipmentSlot.HEAD, itemSettings));
|
||||
chestplate = EndItems.registerEndItem(name + "_chestplate", new EndArmorItem(armor, EquipmentSlot.CHEST, itemSettings));
|
||||
leggings = EndItems.registerEndItem(name + "_leggings", new EndArmorItem(armor, EquipmentSlot.LEGS, itemSettings));
|
||||
boots = EndItems.registerEndItem(name + "_boots", new EndArmorItem(armor, EquipmentSlot.FEET, itemSettings));
|
||||
|
||||
if (hasOre) {
|
||||
FurnaceRecipe.make(name + "_ingot_furnace", ore, ingot).setGroup("end_ingot").buildWithBlasting();
|
||||
|
|
|
@ -1,138 +0,0 @@
|
|||
package ru.betterend.blocks.entities;
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.ContainerHelper;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.ChestMenu;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.BarrelBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.betterend.blocks.basis.EndBarrelBlock;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
public class EBarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||
private NonNullList<ItemStack> inventory;
|
||||
private int viewerCount;
|
||||
|
||||
private EBarrelBlockEntity(BlockEntityType<?> type) {
|
||||
super(type);
|
||||
this.inventory = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
public EBarrelBlockEntity() {
|
||||
this(EndBlockEntities.BARREL);
|
||||
}
|
||||
|
||||
public CompoundTag save(CompoundTag tag) {
|
||||
super.save(tag);
|
||||
if (!this.trySaveLootTable(tag)) {
|
||||
ContainerHelper.saveAllItems(tag, this.inventory);
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void load(BlockState state, CompoundTag tag) {
|
||||
super.load(state, tag);
|
||||
this.inventory = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||
if (!this.tryLoadLootTable(tag)) {
|
||||
ContainerHelper.loadAllItems(tag, this.inventory);
|
||||
}
|
||||
}
|
||||
|
||||
public int getContainerSize() {
|
||||
return 27;
|
||||
}
|
||||
|
||||
protected NonNullList<ItemStack> getItems() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
protected void setItems(NonNullList<ItemStack> list) {
|
||||
this.inventory = list;
|
||||
}
|
||||
|
||||
protected Component getDefaultName() {
|
||||
return new TranslatableComponent("container.barrel");
|
||||
}
|
||||
|
||||
protected AbstractContainerMenu createMenu(int syncId, Inventory playerInventory) {
|
||||
return ChestMenu.threeRows(syncId, playerInventory, this);
|
||||
}
|
||||
|
||||
public void startOpen(Player player) {
|
||||
if (!player.isSpectator()) {
|
||||
if (this.viewerCount < 0) {
|
||||
this.viewerCount = 0;
|
||||
}
|
||||
|
||||
++this.viewerCount;
|
||||
BlockState blockState = this.getBlockState();
|
||||
boolean bl = (Boolean) blockState.getValue(BarrelBlock.OPEN);
|
||||
if (!bl) {
|
||||
this.playSound(blockState, SoundEvents.BARREL_OPEN);
|
||||
this.setOpen(blockState, true);
|
||||
}
|
||||
|
||||
this.scheduleUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleUpdate() {
|
||||
this.level.getBlockTicks().scheduleTick(this.getBlockPos(), this.getBlockState().getBlock(), 5);
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
int i = this.worldPosition.getX();
|
||||
int j = this.worldPosition.getY();
|
||||
int k = this.worldPosition.getZ();
|
||||
this.viewerCount = ChestBlockEntity.getOpenCount(this.level, this, i, j, k);
|
||||
if (this.viewerCount > 0) {
|
||||
this.scheduleUpdate();
|
||||
} else {
|
||||
BlockState blockState = this.getBlockState();
|
||||
if (!(blockState.getBlock() instanceof EndBarrelBlock)) {
|
||||
this.setRemoved();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean bl = (Boolean) blockState.getValue(BarrelBlock.OPEN);
|
||||
if (bl) {
|
||||
this.playSound(blockState, SoundEvents.BARREL_CLOSE);
|
||||
this.setOpen(blockState, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopOpen(Player player) {
|
||||
if (!player.isSpectator()) {
|
||||
--this.viewerCount;
|
||||
}
|
||||
}
|
||||
|
||||
private void setOpen(BlockState state, boolean open) {
|
||||
this.level.setBlock(this.getBlockPos(), (BlockState) state.setValue(BarrelBlock.OPEN, open), 3);
|
||||
}
|
||||
|
||||
private void playSound(BlockState blockState, SoundEvent soundEvent) {
|
||||
Vec3i vec3i = ((Direction) blockState.getValue(BarrelBlock.FACING)).getNormal();
|
||||
double d = (double) this.worldPosition.getX() + 0.5D + (double) vec3i.getX() / 2.0D;
|
||||
double e = (double) this.worldPosition.getY() + 0.5D + (double) vec3i.getY() / 2.0D;
|
||||
double f = (double) this.worldPosition.getZ() + 0.5D + (double) vec3i.getZ() / 2.0D;
|
||||
this.level.playSound((Player) null, d, e, f, soundEvent, SoundSource.BLOCKS, 0.5F,
|
||||
this.level.random.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package ru.betterend.blocks.entities;
|
||||
|
||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
public class EChestBlockEntity extends ChestBlockEntity {
|
||||
public EChestBlockEntity() {
|
||||
super(EndBlockEntities.CHEST);
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package ru.betterend.blocks.entities;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.FurnaceMenu;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
public class EFurnaceBlockEntity extends AbstractFurnaceBlockEntity {
|
||||
public EFurnaceBlockEntity() {
|
||||
super(EndBlockEntities.FURNACE, RecipeType.SMELTING);
|
||||
}
|
||||
|
||||
protected Component getDefaultName() {
|
||||
return new TranslatableComponent("container.furnace");
|
||||
}
|
||||
|
||||
protected AbstractContainerMenu createMenu(int syncId, Inventory playerInventory) {
|
||||
return new FurnaceMenu(syncId, playerInventory, this, this.dataAccess);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package ru.betterend.blocks.entities;
|
||||
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.SignBlockEntity;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
public class ESignBlockEntity extends SignBlockEntity {
|
||||
public ESignBlockEntity() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityType<?> getType() {
|
||||
return EndBlockEntities.SIGN;
|
||||
}
|
||||
}
|
|
@ -1,179 +0,0 @@
|
|||
package ru.betterend.blocks.entities.render;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import it.unimi.dsi.fastutil.floats.Float2FloatFunction;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BrightnessCombiner;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.AbstractChestBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.ChestBlock;
|
||||
import net.minecraft.world.level.block.DoubleBlockCombiner;
|
||||
import net.minecraft.world.level.block.DoubleBlockCombiner.NeighborCombineResult;
|
||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.LidBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.ChestType;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.basis.EndChestBlock;
|
||||
import ru.betterend.blocks.entities.EChestBlockEntity;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
public class EndChestBlockEntityRenderer extends BlockEntityRenderer<EChestBlockEntity> {
|
||||
private static final HashMap<Block, RenderType[]> LAYERS = Maps.newHashMap();
|
||||
private static RenderType[] defaultLayer;
|
||||
|
||||
private static final int ID_NORMAL = 0;
|
||||
private static final int ID_LEFT = 1;
|
||||
private static final int ID_RIGHT = 2;
|
||||
|
||||
private final ModelPart partA;
|
||||
private final ModelPart partC;
|
||||
private final ModelPart partB;
|
||||
private final ModelPart partRightA;
|
||||
private final ModelPart partRightC;
|
||||
private final ModelPart partRightB;
|
||||
private final ModelPart partLeftA;
|
||||
private final ModelPart partLeftC;
|
||||
private final ModelPart partLeftB;
|
||||
|
||||
public EndChestBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
|
||||
super(blockEntityRenderDispatcher);
|
||||
|
||||
this.partC = new ModelPart(64, 64, 0, 19);
|
||||
this.partC.addBox(1.0F, 0.0F, 1.0F, 14.0F, 9.0F, 14.0F, 0.0F);
|
||||
this.partA = new ModelPart(64, 64, 0, 0);
|
||||
this.partA.addBox(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F);
|
||||
this.partA.y = 9.0F;
|
||||
this.partA.z = 1.0F;
|
||||
this.partB = new ModelPart(64, 64, 0, 0);
|
||||
this.partB.addBox(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F);
|
||||
this.partB.y = 8.0F;
|
||||
this.partRightC = new ModelPart(64, 64, 0, 19);
|
||||
this.partRightC.addBox(1.0F, 0.0F, 1.0F, 15.0F, 9.0F, 14.0F, 0.0F);
|
||||
this.partRightA = new ModelPart(64, 64, 0, 0);
|
||||
this.partRightA.addBox(1.0F, 0.0F, 0.0F, 15.0F, 5.0F, 14.0F, 0.0F);
|
||||
this.partRightA.y = 9.0F;
|
||||
this.partRightA.z = 1.0F;
|
||||
this.partRightB = new ModelPart(64, 64, 0, 0);
|
||||
this.partRightB.addBox(15.0F, -1.0F, 15.0F, 1.0F, 4.0F, 1.0F, 0.0F);
|
||||
this.partRightB.y = 8.0F;
|
||||
this.partLeftC = new ModelPart(64, 64, 0, 19);
|
||||
this.partLeftC.addBox(0.0F, 0.0F, 1.0F, 15.0F, 9.0F, 14.0F, 0.0F);
|
||||
this.partLeftA = new ModelPart(64, 64, 0, 0);
|
||||
this.partLeftA.addBox(0.0F, 0.0F, 0.0F, 15.0F, 5.0F, 14.0F, 0.0F);
|
||||
this.partLeftA.y = 9.0F;
|
||||
this.partLeftA.z = 1.0F;
|
||||
this.partLeftB = new ModelPart(64, 64, 0, 0);
|
||||
this.partLeftB.addBox(0.0F, -1.0F, 15.0F, 1.0F, 4.0F, 1.0F, 0.0F);
|
||||
this.partLeftB.y = 8.0F;
|
||||
}
|
||||
|
||||
public void render(EChestBlockEntity entity, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, int light, int overlay) {
|
||||
Level world = entity.getLevel();
|
||||
boolean worldExists = world != null;
|
||||
BlockState blockState = worldExists ? entity.getBlockState() : (BlockState) Blocks.CHEST.defaultBlockState().setValue(ChestBlock.FACING, Direction.SOUTH);
|
||||
ChestType chestType = blockState.hasProperty(ChestBlock.TYPE) ? (ChestType) blockState.getValue(ChestBlock.TYPE) : ChestType.SINGLE;
|
||||
Block block = blockState.getBlock();
|
||||
if (block instanceof AbstractChestBlock) {
|
||||
AbstractChestBlock<?> abstractChestBlock = (AbstractChestBlock<?>) block;
|
||||
boolean isDouble = chestType != ChestType.SINGLE;
|
||||
float f = ((Direction) blockState.getValue(ChestBlock.FACING)).toYRot();
|
||||
NeighborCombineResult<? extends ChestBlockEntity> propertySource;
|
||||
|
||||
matrices.pushPose();
|
||||
matrices.translate(0.5D, 0.5D, 0.5D);
|
||||
matrices.mulPose(Vector3f.YP.rotationDegrees(-f));
|
||||
matrices.translate(-0.5D, -0.5D, -0.5D);
|
||||
|
||||
if (worldExists) {
|
||||
propertySource = abstractChestBlock.combine(blockState, world, entity.getBlockPos(), true);
|
||||
} else {
|
||||
propertySource = DoubleBlockCombiner.Combiner::acceptNone;
|
||||
}
|
||||
|
||||
float pitch = ((Float2FloatFunction) propertySource.apply(ChestBlock.opennessCombiner((LidBlockEntity) entity))).get(tickDelta);
|
||||
pitch = 1.0F - pitch;
|
||||
pitch = 1.0F - pitch * pitch * pitch;
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
int blockLight = ((Int2IntFunction) propertySource.apply(new BrightnessCombiner())).applyAsInt(light);
|
||||
|
||||
VertexConsumer vertexConsumer = getConsumer(vertexConsumers, block, chestType);
|
||||
|
||||
if (isDouble) {
|
||||
if (chestType == ChestType.LEFT) {
|
||||
renderParts(matrices, vertexConsumer, this.partLeftA, this.partLeftB, this.partLeftC, pitch, blockLight, overlay);
|
||||
} else {
|
||||
renderParts(matrices, vertexConsumer, this.partRightA, this.partRightB, this.partRightC, pitch, blockLight, overlay);
|
||||
}
|
||||
} else {
|
||||
renderParts(matrices, vertexConsumer, this.partA, this.partB, this.partC, pitch, blockLight, overlay);
|
||||
}
|
||||
|
||||
matrices.popPose();
|
||||
}
|
||||
}
|
||||
|
||||
private void renderParts(PoseStack matrices, VertexConsumer vertices, ModelPart modelPart, ModelPart modelPart2, ModelPart modelPart3, float pitch, int light, int overlay) {
|
||||
modelPart.xRot = -(pitch * 1.5707964F);
|
||||
modelPart2.xRot = modelPart.xRot;
|
||||
modelPart.render(matrices, vertices, light, overlay);
|
||||
modelPart2.render(matrices, vertices, light, overlay);
|
||||
modelPart3.render(matrices, vertices, light, overlay);
|
||||
}
|
||||
|
||||
private static RenderType getChestTexture(ChestType type, RenderType[] layers) {
|
||||
switch (type) {
|
||||
case LEFT:
|
||||
return layers[ID_LEFT];
|
||||
case RIGHT:
|
||||
return layers[ID_RIGHT];
|
||||
case SINGLE:
|
||||
default:
|
||||
return layers[ID_NORMAL];
|
||||
}
|
||||
}
|
||||
|
||||
public static VertexConsumer getConsumer(MultiBufferSource provider, Block block, ChestType chestType) {
|
||||
RenderType[] layers = LAYERS.getOrDefault(block, defaultLayer);
|
||||
return provider.getBuffer(getChestTexture(chestType, layers));
|
||||
}
|
||||
|
||||
static {
|
||||
defaultLayer = new RenderType[] {
|
||||
RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal.png")),
|
||||
RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal_left.png")),
|
||||
RenderType.entityCutout(new ResourceLocation("textures/entity/chest/normal_right.png"))
|
||||
};
|
||||
|
||||
EndItems.getModBlocks().forEach((item) -> {
|
||||
if (item instanceof BlockItem) {
|
||||
Block block = ((BlockItem) item).getBlock();
|
||||
if (block instanceof EndChestBlock) {
|
||||
String name = Registry.BLOCK.getKey(block).getPath();
|
||||
LAYERS.put(block, new RenderType[] {
|
||||
RenderType.entityCutout(BetterEnd.makeID("textures/entity/chest/" + name + ".png")),
|
||||
RenderType.entityCutout(BetterEnd.makeID("textures/entity/chest/" + name + "_left.png")),
|
||||
RenderType.entityCutout(BetterEnd.makeID("textures/entity/chest/" + name + "_right.png"))
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
package ru.betterend.blocks.entities.render;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Sheets;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.SignRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.SignRenderer.SignModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SignBlock;
|
||||
import net.minecraft.world.level.block.StandingSignBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.WoodType;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.basis.EndSignBlock;
|
||||
import ru.betterend.blocks.entities.ESignBlockEntity;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
public class EndSignBlockEntityRenderer extends BlockEntityRenderer<ESignBlockEntity> {
|
||||
private static final HashMap<Block, RenderType> LAYERS = Maps.newHashMap();
|
||||
private static RenderType defaultLayer;
|
||||
private final SignModel model = new SignRenderer.SignModel();
|
||||
|
||||
public EndSignBlockEntityRenderer(BlockEntityRenderDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
public void render(ESignBlockEntity signBlockEntity, float tickDelta, PoseStack matrixStack,
|
||||
MultiBufferSource provider, int light, int overlay) {
|
||||
BlockState state = signBlockEntity.getBlockState();
|
||||
matrixStack.pushPose();
|
||||
|
||||
matrixStack.translate(0.5D, 0.5D, 0.5D);
|
||||
float angle = -((float) ((Integer) state.getValue(StandingSignBlock.ROTATION) * 360) / 16.0F);
|
||||
|
||||
BlockState blockState = signBlockEntity.getBlockState();
|
||||
if (blockState.getValue(EndSignBlock.FLOOR)) {
|
||||
matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle));
|
||||
this.model.stick.visible = true;
|
||||
} else {
|
||||
matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle + 180));
|
||||
matrixStack.translate(0.0D, -0.3125D, -0.4375D);
|
||||
this.model.stick.visible = false;
|
||||
}
|
||||
|
||||
matrixStack.pushPose();
|
||||
matrixStack.scale(0.6666667F, -0.6666667F, -0.6666667F);
|
||||
VertexConsumer vertexConsumer = getConsumer(provider, state.getBlock());
|
||||
model.sign.render(matrixStack, vertexConsumer, light, overlay);
|
||||
model.stick.render(matrixStack, vertexConsumer, light, overlay);
|
||||
matrixStack.popPose();
|
||||
Font textRenderer = renderer.getFont();
|
||||
matrixStack.translate(0.0D, 0.3333333432674408D, 0.046666666865348816D);
|
||||
matrixStack.scale(0.010416667F, -0.010416667F, 0.010416667F);
|
||||
int m = signBlockEntity.getColor().getTextColor();
|
||||
int n = (int) (NativeImage.getR(m) * 0.4D);
|
||||
int o = (int) (NativeImage.getG(m) * 0.4D);
|
||||
int p = (int) (NativeImage.getB(m) * 0.4D);
|
||||
int q = NativeImage.combine(0, p, o, n);
|
||||
|
||||
for (int s = 0; s < 4; ++s) {
|
||||
FormattedCharSequence orderedText = signBlockEntity.getRenderMessage(s, (text) -> {
|
||||
List<FormattedCharSequence> list = textRenderer.split(text, 90);
|
||||
return list.isEmpty() ? FormattedCharSequence.EMPTY : (FormattedCharSequence) list.get(0);
|
||||
});
|
||||
if (orderedText != null) {
|
||||
float t = (float) (-textRenderer.width(orderedText) / 2);
|
||||
textRenderer.drawInBatch((FormattedCharSequence) orderedText, t, (float) (s * 10 - 20), q, false, matrixStack.last().pose(), provider, false, 0, light);
|
||||
}
|
||||
}
|
||||
|
||||
matrixStack.popPose();
|
||||
}
|
||||
|
||||
public static Material getModelTexture(Block block) {
|
||||
WoodType signType2;
|
||||
if (block instanceof SignBlock) {
|
||||
signType2 = ((SignBlock) block).type();
|
||||
} else {
|
||||
signType2 = WoodType.OAK;
|
||||
}
|
||||
|
||||
return Sheets.signTexture(signType2);
|
||||
}
|
||||
|
||||
public static VertexConsumer getConsumer(MultiBufferSource provider, Block block) {
|
||||
return provider.getBuffer(LAYERS.getOrDefault(block, defaultLayer));
|
||||
}
|
||||
|
||||
static {
|
||||
defaultLayer = RenderType.entitySolid(new ResourceLocation("textures/entity/sign/oak.png"));
|
||||
|
||||
EndItems.getModBlocks().forEach((item) -> {
|
||||
if (item instanceof BlockItem) {
|
||||
Block block = ((BlockItem) item).getBlock();
|
||||
if (block instanceof EndSignBlock) {
|
||||
String name = Registry.BLOCK.getKey(block).getPath();
|
||||
RenderType layer = RenderType.entitySolid(BetterEnd.makeID("textures/entity/sign/" + name + ".png"));
|
||||
LAYERS.put(block, layer);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,231 +0,0 @@
|
|||
package ru.betterend.client.gui;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.platform.Lighting;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.BufferUploader;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.font.TextFieldHelper;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.blockentity.SignRenderer.SignModel;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.betterend.blocks.basis.EndSignBlock;
|
||||
import ru.betterend.blocks.entities.ESignBlockEntity;
|
||||
import ru.betterend.blocks.entities.render.EndSignBlockEntityRenderer;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class BlockSignEditScreen extends Screen {
|
||||
private final SignModel model = new SignModel();
|
||||
private final ESignBlockEntity sign;
|
||||
private int ticksSinceOpened;
|
||||
private int currentRow;
|
||||
private TextFieldHelper selectionManager;
|
||||
private final String[] text = (String[]) Util.make(new String[4], (strings) -> {
|
||||
Arrays.fill(strings, "");
|
||||
});
|
||||
|
||||
public BlockSignEditScreen(ESignBlockEntity sign) {
|
||||
super(new TranslatableComponent("sign.edit"));
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
this.minecraft.keyboardHandler.setSendRepeatsToGui(true);
|
||||
this.addButton(new Button(this.width / 2 - 100, this.height / 4 + 120, 200, 20, CommonComponents.GUI_DONE,
|
||||
(buttonWidget) -> {
|
||||
this.finishEditing();
|
||||
}));
|
||||
this.sign.setEditable(false);
|
||||
this.selectionManager = new TextFieldHelper(() -> {
|
||||
return this.text[this.currentRow];
|
||||
}, (string) -> {
|
||||
this.text[this.currentRow] = string;
|
||||
this.sign.setMessage(this.currentRow, new TextComponent(string));
|
||||
}, TextFieldHelper.createClipboardGetter(this.minecraft), TextFieldHelper.createClipboardSetter(this.minecraft),
|
||||
(string) -> {
|
||||
return this.minecraft.font.width(string) <= 90;
|
||||
});
|
||||
}
|
||||
|
||||
public void removed() {
|
||||
this.minecraft.keyboardHandler.setSendRepeatsToGui(false);
|
||||
ClientPacketListener clientPlayNetworkHandler = this.minecraft.getConnection();
|
||||
if (clientPlayNetworkHandler != null) {
|
||||
clientPlayNetworkHandler.send(new ServerboundSignUpdatePacket(this.sign.getBlockPos(), this.text[0], this.text[1],
|
||||
this.text[2], this.text[3]));
|
||||
}
|
||||
|
||||
this.sign.setEditable(true);
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
++this.ticksSinceOpened;
|
||||
if (!this.sign.getType().isValid(this.sign.getBlockState().getBlock())) {
|
||||
this.finishEditing();
|
||||
}
|
||||
}
|
||||
|
||||
private void finishEditing() {
|
||||
this.sign.setChanged();
|
||||
this.minecraft.setScreen((Screen) null);
|
||||
}
|
||||
|
||||
public boolean charTyped(char chr, int keyCode) {
|
||||
this.selectionManager.charTyped(chr);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onClose() {
|
||||
this.finishEditing();
|
||||
}
|
||||
|
||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||
if (keyCode == 265) {
|
||||
this.currentRow = this.currentRow - 1 & 3;
|
||||
this.selectionManager.setCursorToEnd();
|
||||
return true;
|
||||
} else if (keyCode != 264 && keyCode != 257 && keyCode != 335) {
|
||||
return this.selectionManager.keyPressed(keyCode) ? true
|
||||
: super.keyPressed(keyCode, scanCode, modifiers);
|
||||
} else {
|
||||
this.currentRow = this.currentRow + 1 & 3;
|
||||
this.selectionManager.setCursorToEnd();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
Lighting.setupForFlatItems();
|
||||
this.renderBackground(matrices);
|
||||
GuiComponent.drawCenteredString(matrices, this.font, this.title, this.width / 2, 40, 16777215);
|
||||
matrices.pushPose();
|
||||
matrices.translate((double) (this.width / 2), 0.0D, 50.0D);
|
||||
|
||||
matrices.scale(93.75F, -93.75F, 93.75F);
|
||||
matrices.translate(0.0D, -1.3125D, 0.0D);
|
||||
BlockState blockState = this.sign.getBlockState();
|
||||
boolean bl = blockState.getValue(EndSignBlock.FLOOR);
|
||||
|
||||
if (!bl) {
|
||||
matrices.translate(0.0D, -0.3125D, 0.0D);
|
||||
}
|
||||
|
||||
boolean bl2 = this.ticksSinceOpened / 6 % 2 == 0;
|
||||
|
||||
matrices.pushPose();
|
||||
matrices.scale(0.6666667F, -0.6666667F, -0.6666667F);
|
||||
MultiBufferSource.BufferSource immediate = this.minecraft.renderBuffers().bufferSource();
|
||||
VertexConsumer vertexConsumer = EndSignBlockEntityRenderer.getConsumer(immediate, blockState.getBlock());
|
||||
this.model.sign.render(matrices, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY);
|
||||
|
||||
if (bl) {
|
||||
this.model.stick.render(matrices, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY);
|
||||
}
|
||||
|
||||
matrices.popPose();
|
||||
|
||||
matrices.translate(0.0D, 0.3333333432674408D, 0.046666666865348816D);
|
||||
matrices.scale(0.010416667F, -0.010416667F, 0.010416667F);
|
||||
int i = this.sign.getColor().getTextColor();
|
||||
int j = this.selectionManager.getCursorPos();
|
||||
int k = this.selectionManager.getSelectionPos();
|
||||
int l = this.currentRow * 10 - this.text.length * 5;
|
||||
Matrix4f matrix4f = matrices.last().pose();
|
||||
|
||||
int m;
|
||||
String string2;
|
||||
int s;
|
||||
int t;
|
||||
for (m = 0; m < this.text.length; ++m) {
|
||||
string2 = this.text[m];
|
||||
if (string2 != null) {
|
||||
if (this.font.isBidirectional()) {
|
||||
string2 = this.font.bidirectionalShaping(string2);
|
||||
}
|
||||
|
||||
float n = (float) (-this.minecraft.font.width(string2) / 2);
|
||||
this.minecraft.font.drawInBatch(string2, n, (float) (m * 10 - this.text.length * 5), i, false, matrix4f,
|
||||
immediate, false, 0, 15728880, false);
|
||||
if (m == this.currentRow && j >= 0 && bl2) {
|
||||
s = this.minecraft.font
|
||||
.width(string2.substring(0, Math.max(Math.min(j, string2.length()), 0)));
|
||||
t = s - this.minecraft.font.width(string2) / 2;
|
||||
if (j >= string2.length()) {
|
||||
this.minecraft.font.drawInBatch("_", (float) t, (float) l, i, false, matrix4f, immediate, false,
|
||||
0, 15728880, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
immediate.endBatch();
|
||||
|
||||
for (m = 0; m < this.text.length; ++m) {
|
||||
string2 = this.text[m];
|
||||
if (string2 != null && m == this.currentRow && j >= 0) {
|
||||
int r = this.minecraft.font
|
||||
.width(string2.substring(0, Math.max(Math.min(j, string2.length()), 0)));
|
||||
s = r - this.minecraft.font.width(string2) / 2;
|
||||
if (bl2 && j < string2.length()) {
|
||||
int var31 = l - 1;
|
||||
int var10003 = s + 1;
|
||||
this.minecraft.font.getClass();
|
||||
fill(matrices, s, var31, var10003, l + 9, -16777216 | i);
|
||||
}
|
||||
|
||||
if (k != j) {
|
||||
t = Math.min(j, k);
|
||||
int u = Math.max(j, k);
|
||||
int v = this.minecraft.font.width(string2.substring(0, t))
|
||||
- this.minecraft.font.width(string2) / 2;
|
||||
int w = this.minecraft.font.width(string2.substring(0, u))
|
||||
- this.minecraft.font.width(string2) / 2;
|
||||
int x = Math.min(v, w);
|
||||
int y = Math.max(v, w);
|
||||
Tesselator tessellator = Tesselator.getInstance();
|
||||
BufferBuilder bufferBuilder = tessellator.getBuilder();
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.enableColorLogicOp();
|
||||
RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
|
||||
bufferBuilder.begin(7, DefaultVertexFormat.POSITION_COLOR);
|
||||
float var32 = (float) x;
|
||||
this.minecraft.font.getClass();
|
||||
bufferBuilder.vertex(matrix4f, var32, (float) (l + 9), 0.0F).color(0, 0, 255, 255).endVertex();
|
||||
var32 = (float) y;
|
||||
this.minecraft.font.getClass();
|
||||
bufferBuilder.vertex(matrix4f, var32, (float) (l + 9), 0.0F).color(0, 0, 255, 255).endVertex();
|
||||
bufferBuilder.vertex(matrix4f, (float) y, (float) l, 0.0F).color(0, 0, 255, 255).endVertex();
|
||||
bufferBuilder.vertex(matrix4f, (float) x, (float) l, 0.0F).color(0, 0, 255, 255).endVertex();
|
||||
bufferBuilder.end();
|
||||
BufferUploader.end(bufferBuilder);
|
||||
RenderSystem.disableColorLogicOp();
|
||||
RenderSystem.enableTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matrices.popPose();
|
||||
Lighting.setupFor3DItems();
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
|
@ -1,80 +1,80 @@
|
|||
package ru.betterend.blocks.entities.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.betterend.blocks.EternalPedestal;
|
||||
import ru.betterend.blocks.basis.PedestalBlock;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import ru.betterend.client.render.BeamRenderer;
|
||||
import ru.betterend.client.render.EndCrystalRenderer;
|
||||
import ru.betterend.client.render.EternalCrystalRenderer;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class PedestalItemRenderer<T extends PedestalBlockEntity> extends BlockEntityRenderer<T> {
|
||||
|
||||
public PedestalItemRenderer(BlockEntityRenderDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(T blockEntity, float tickDelta, PoseStack matrices,
|
||||
MultiBufferSource vertexConsumers, int light, int overlay) {
|
||||
|
||||
Level world = blockEntity.getLevel();
|
||||
if (world == null || blockEntity.isEmpty()) return;
|
||||
|
||||
BlockState state = world.getBlockState(blockEntity.getBlockPos());
|
||||
if (!(state.getBlock() instanceof PedestalBlock)) return;
|
||||
|
||||
ItemStack activeItem = blockEntity.getItem(0);
|
||||
|
||||
matrices.pushPose();
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
BakedModel model = minecraft.getItemRenderer().getModel(activeItem, world, null);
|
||||
Vector3f translate = model.getTransforms().ground.translation;
|
||||
PedestalBlock pedestal = (PedestalBlock) state.getBlock();
|
||||
matrices.translate(translate.x(), translate.y(), translate.z());
|
||||
matrices.translate(0.5, pedestal.getHeight(state), 0.5);
|
||||
if (activeItem.getItem() instanceof BlockItem) {
|
||||
matrices.scale(1.5F, 1.5F, 1.5F);
|
||||
} else {
|
||||
matrices.scale(1.25F, 1.25F, 1.25F);
|
||||
}
|
||||
int age = blockEntity.getAge();
|
||||
if (state.is(EndBlocks.ETERNAL_PEDESTAL) && state.getValue(EternalPedestal.ACTIVATED)) {
|
||||
float[] colors = EternalCrystalRenderer.colors(age);
|
||||
int y = blockEntity.getBlockPos().getY();
|
||||
|
||||
BeamRenderer.renderLightBeam(matrices, vertexConsumers, age, tickDelta, -y, 1024 - y, colors, 0.25F, 0.13F, 0.16F);
|
||||
float altitude = Mth.sin((blockEntity.getAge() + tickDelta) / 10.0F) * 0.1F + 0.1F;
|
||||
matrices.translate(0.0D, altitude, 0.0D);
|
||||
}
|
||||
if (activeItem.getItem() == Items.END_CRYSTAL) {
|
||||
EndCrystalRenderer.render(age, blockEntity.getMaxAge(), tickDelta, matrices, vertexConsumers, light);
|
||||
} else if (activeItem.getItem() == EndItems.ETERNAL_CRYSTAL) {
|
||||
EternalCrystalRenderer.render(age, tickDelta, matrices, vertexConsumers, light);
|
||||
} else {
|
||||
float rotation = (age + tickDelta) / 25.0F + 6.0F;
|
||||
matrices.mulPose(Vector3f.YP.rotation(rotation));
|
||||
minecraft.getItemRenderer().render(activeItem, ItemTransforms.TransformType.GROUND, false, matrices, vertexConsumers, light, overlay, model);
|
||||
}
|
||||
matrices.popPose();
|
||||
}
|
||||
}
|
||||
package ru.betterend.client.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.betterend.blocks.EternalPedestal;
|
||||
import ru.betterend.blocks.basis.PedestalBlock;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import ru.betterend.client.render.BeamRenderer;
|
||||
import ru.betterend.client.render.EndCrystalRenderer;
|
||||
import ru.betterend.client.render.EternalCrystalRenderer;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class PedestalItemRenderer<T extends PedestalBlockEntity> extends BlockEntityRenderer<T> {
|
||||
|
||||
public PedestalItemRenderer(BlockEntityRenderDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(T blockEntity, float tickDelta, PoseStack matrices,
|
||||
MultiBufferSource vertexConsumers, int light, int overlay) {
|
||||
|
||||
Level world = blockEntity.getLevel();
|
||||
if (world == null || blockEntity.isEmpty()) return;
|
||||
|
||||
BlockState state = world.getBlockState(blockEntity.getBlockPos());
|
||||
if (!(state.getBlock() instanceof PedestalBlock)) return;
|
||||
|
||||
ItemStack activeItem = blockEntity.getItem(0);
|
||||
|
||||
matrices.pushPose();
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
BakedModel model = minecraft.getItemRenderer().getModel(activeItem, world, null);
|
||||
Vector3f translate = model.getTransforms().ground.translation;
|
||||
PedestalBlock pedestal = (PedestalBlock) state.getBlock();
|
||||
matrices.translate(translate.x(), translate.y(), translate.z());
|
||||
matrices.translate(0.5, pedestal.getHeight(state), 0.5);
|
||||
if (activeItem.getItem() instanceof BlockItem) {
|
||||
matrices.scale(1.5F, 1.5F, 1.5F);
|
||||
} else {
|
||||
matrices.scale(1.25F, 1.25F, 1.25F);
|
||||
}
|
||||
int age = blockEntity.getAge();
|
||||
if (state.is(EndBlocks.ETERNAL_PEDESTAL) && state.getValue(EternalPedestal.ACTIVATED)) {
|
||||
float[] colors = EternalCrystalRenderer.colors(age);
|
||||
int y = blockEntity.getBlockPos().getY();
|
||||
|
||||
BeamRenderer.renderLightBeam(matrices, vertexConsumers, age, tickDelta, -y, 1024 - y, colors, 0.25F, 0.13F, 0.16F);
|
||||
float altitude = Mth.sin((blockEntity.getAge() + tickDelta) / 10.0F) * 0.1F + 0.1F;
|
||||
matrices.translate(0.0D, altitude, 0.0D);
|
||||
}
|
||||
if (activeItem.getItem() == Items.END_CRYSTAL) {
|
||||
EndCrystalRenderer.render(age, blockEntity.getMaxAge(), tickDelta, matrices, vertexConsumers, light);
|
||||
} else if (activeItem.getItem() == EndItems.ETERNAL_CRYSTAL) {
|
||||
EternalCrystalRenderer.render(age, tickDelta, matrices, vertexConsumers, light);
|
||||
} else {
|
||||
float rotation = (age + tickDelta) / 25.0F + 6.0F;
|
||||
matrices.mulPose(Vector3f.YP.rotation(rotation));
|
||||
minecraft.getItemRenderer().render(activeItem, ItemTransforms.TransformType.GROUND, false, matrices, vertexConsumers, light, overlay, model);
|
||||
}
|
||||
matrices.popPose();
|
||||
}
|
||||
}
|
|
@ -30,8 +30,8 @@ public class ArmoredElytra extends EndArmorItem implements MultiModelItem {
|
|||
|
||||
public ArmoredElytra(String name, ArmorMaterial material, Item repairItem, int durability, double movementFactor, boolean fireproof) {
|
||||
super(material, EquipmentSlot.CHEST, fireproof ?
|
||||
EndItems.makeItemSettings().durability(durability).rarity(Rarity.EPIC).fireResistant() :
|
||||
EndItems.makeItemSettings().durability(durability).rarity(Rarity.EPIC));
|
||||
EndItems.makeEndItemSettings().durability(durability).rarity(Rarity.EPIC).fireResistant() :
|
||||
EndItems.makeEndItemSettings().durability(durability).rarity(Rarity.EPIC));
|
||||
this.wingTexture = BetterEnd.makeID("textures/entity/" + name + ".png");
|
||||
this.repairItem = repairItem;
|
||||
this.movementFactor = movementFactor;
|
||||
|
|
|
@ -7,10 +7,11 @@ import net.minecraft.world.effect.MobEffectInstance;
|
|||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import ru.bclib.items.BaseArmorItem;
|
||||
import ru.betterend.effects.EndStatusEffects;
|
||||
import ru.betterend.item.material.EndArmorMaterial;
|
||||
|
||||
public class CrystaliteArmor extends EndArmorItem {
|
||||
public class CrystaliteArmor extends BaseArmorItem {
|
||||
|
||||
public final static TranslatableComponent CHEST_DESC;
|
||||
public final static TranslatableComponent BOOTS_DESC;
|
||||
|
|
|
@ -22,7 +22,7 @@ import ru.betterend.registry.EndItems;
|
|||
public class CrystaliteBoots extends CrystaliteArmor implements MobEffectApplier {
|
||||
|
||||
public CrystaliteBoots() {
|
||||
super(EquipmentSlot.FEET, EndItems.makeItemSettings().rarity(Rarity.RARE));
|
||||
super(EquipmentSlot.FEET, EndItems.makeEndItemSettings().rarity(Rarity.RARE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,7 @@ import ru.betterend.registry.EndItems;
|
|||
public class CrystaliteChestplate extends CrystaliteArmor implements MobEffectApplier {
|
||||
|
||||
public CrystaliteChestplate() {
|
||||
super(EquipmentSlot.CHEST, EndItems.makeItemSettings().rarity(Rarity.RARE));
|
||||
super(EquipmentSlot.CHEST, EndItems.makeEndItemSettings().rarity(Rarity.RARE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,7 +11,7 @@ import ru.betterend.registry.EndItems;
|
|||
public class CrystaliteHelmet extends CrystaliteArmor {
|
||||
|
||||
public CrystaliteHelmet() {
|
||||
super(EquipmentSlot.HEAD, EndItems.makeItemSettings().rarity(Rarity.RARE));
|
||||
super(EquipmentSlot.HEAD, EndItems.makeEndItemSettings().rarity(Rarity.RARE));
|
||||
UUID uuid = ARMOR_MODIFIER_UUID_PER_SLOT[EquipmentSlot.HEAD.getIndex()];
|
||||
addAttributeModifier(EndAttributes.BLINDNESS_RESISTANCE, new AttributeModifier(uuid, "Helmet blindness resistance", 1.0, AttributeModifier.Operation.ADDITION));
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import ru.betterend.registry.EndItems;
|
|||
public class CrystaliteLeggings extends CrystaliteArmor {
|
||||
|
||||
public CrystaliteLeggings() {
|
||||
super(EquipmentSlot.LEGS, EndItems.makeItemSettings().rarity(Rarity.RARE));
|
||||
super(EquipmentSlot.LEGS, EndItems.makeEndItemSettings().rarity(Rarity.RARE));
|
||||
UUID uuid = ARMOR_MODIFIER_UUID_PER_SLOT[EquipmentSlot.LEGS.getIndex()];
|
||||
addAttributeModifier(Attributes.MAX_HEALTH, new AttributeModifier(uuid, "Armor health boost", 4.0, AttributeModifier.Operation.ADDITION));
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import ru.betterend.registry.EndItems;
|
|||
|
||||
public class EnchantedPetalItem extends ModelProviderItem {
|
||||
public EnchantedPetalItem() {
|
||||
super(EndItems.makeItemSettings().rarity(Rarity.RARE).stacksTo(16));
|
||||
super(EndItems.makeEndItemSettings().rarity(Rarity.RARE).stacksTo(16));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,11 +16,11 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||
import ru.betterend.registry.EndItems;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
|
||||
public class EndAnvilItem extends BlockItem {
|
||||
public EndAnvilItem(Block block) {
|
||||
super(block, EndItems.makeBlockItemSettings());
|
||||
super(block, EndBlocks.makeBlockItemSettings());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,6 +8,6 @@ import ru.betterend.registry.EndItems;
|
|||
|
||||
public class EndBucketItem extends FishBucketItem implements ItemModelProvider {
|
||||
public EndBucketItem(EntityType<?> type) {
|
||||
super(type, Fluids.WATER, EndItems.makeItemSettings().stacksTo(1));
|
||||
super(type, Fluids.WATER, EndItems.makeEndItemSettings().stacksTo(1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,6 @@ import ru.betterend.registry.EndItems;
|
|||
|
||||
public class EternalCrystalItem extends ModelProviderItem {
|
||||
public EternalCrystalItem() {
|
||||
super(EndItems.makeItemSettings().stacksTo(16).rarity(Rarity.EPIC));
|
||||
super(EndItems.makeEndItemSettings().stacksTo(16).rarity(Rarity.EPIC));
|
||||
}
|
||||
}
|
|
@ -20,12 +20,12 @@ import vazkii.patchouli.api.PatchouliAPI;
|
|||
|
||||
public class GuideBookItem extends ModelProviderItem {
|
||||
public final static ResourceLocation BOOK_ID = BetterEnd.makeID("guidebook");
|
||||
public static final Item GUIDE_BOOK = EndItems.registerItem(BOOK_ID, new GuideBookItem());
|
||||
public static final Item GUIDE_BOOK = EndItems.registerEndItem(BOOK_ID, new GuideBookItem());
|
||||
|
||||
public static void register() {}
|
||||
|
||||
public GuideBookItem() {
|
||||
super(EndItems.makeItemSettings().stacksTo(1));
|
||||
super(EndItems.makeEndItemSettings().stacksTo(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,8 +12,8 @@ import net.minecraft.client.multiplayer.ClientPacketListener;
|
|||
import net.minecraft.network.protocol.PacketUtils;
|
||||
import net.minecraft.network.protocol.game.ClientboundOpenSignEditorPacket;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import ru.betterend.blocks.entities.ESignBlockEntity;
|
||||
import ru.betterend.client.gui.BlockSignEditScreen;
|
||||
import ru.bclib.blockentities.BaseSignBlockEntity;
|
||||
import ru.bclib.client.gui.BlockSignEditScreen;
|
||||
|
||||
@Mixin(ClientPacketListener.class)
|
||||
public class ClientPlayNetworkHandlerMixin
|
||||
|
@ -28,8 +28,8 @@ public class ClientPlayNetworkHandlerMixin
|
|||
public void be_openSignEditor(ClientboundOpenSignEditorPacket packet, CallbackInfo info) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, ClientPacketListener.class.cast(this), minecraft);
|
||||
BlockEntity blockEntity = level.getBlockEntity(packet.getPos());
|
||||
if (blockEntity instanceof ESignBlockEntity) {
|
||||
ESignBlockEntity sign = (ESignBlockEntity) blockEntity;
|
||||
if (blockEntity instanceof BaseSignBlockEntity) {
|
||||
BaseSignBlockEntity sign = (BaseSignBlockEntity) blockEntity;
|
||||
minecraft.setScreen(new BlockSignEditScreen(sign));
|
||||
info.cancel();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package ru.betterend.registry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -13,20 +10,10 @@ import ru.betterend.BetterEnd;
|
|||
import ru.betterend.blocks.EndStoneSmelter;
|
||||
import ru.betterend.blocks.EternalPedestal;
|
||||
import ru.betterend.blocks.InfusionPedestal;
|
||||
import ru.betterend.blocks.basis.EndBarrelBlock;
|
||||
import ru.betterend.blocks.basis.EndChestBlock;
|
||||
import ru.betterend.blocks.basis.EndFurnaceBlock;
|
||||
import ru.betterend.blocks.basis.EndSignBlock;
|
||||
import ru.betterend.blocks.basis.PedestalBlock;
|
||||
import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
|
||||
import ru.betterend.blocks.entities.EBarrelBlockEntity;
|
||||
import ru.betterend.blocks.entities.EChestBlockEntity;
|
||||
import ru.betterend.blocks.entities.EFurnaceBlockEntity;
|
||||
import ru.betterend.blocks.entities.ESignBlockEntity;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
import ru.betterend.blocks.entities.EternalPedestalEntity;
|
||||
import ru.betterend.blocks.entities.InfusionPedestalEntity;
|
||||
import ru.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import ru.betterend.blocks.entities.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EndBlockEntities {
|
||||
public final static BlockEntityType<EndStoneSmelterBlockEntity> END_STONE_SMELTER = registerBlockEntity(EndStoneSmelter.ID,
|
||||
|
@ -37,61 +24,14 @@ public class EndBlockEntities {
|
|||
BlockEntityType.Builder.of(EternalPedestalEntity::new, EndBlocks.ETERNAL_PEDESTAL));
|
||||
public final static BlockEntityType<InfusionPedestalEntity> INFUSION_PEDESTAL = registerBlockEntity("infusion_pedestal",
|
||||
BlockEntityType.Builder.of(InfusionPedestalEntity::new, EndBlocks.INFUSION_PEDESTAL));
|
||||
public static final BlockEntityType<EChestBlockEntity> CHEST = registerBlockEntity("chest",
|
||||
BlockEntityType.Builder.of(EChestBlockEntity::new, getChests()));
|
||||
public static final BlockEntityType<EBarrelBlockEntity> BARREL = registerBlockEntity("barrel",
|
||||
BlockEntityType.Builder.of(EBarrelBlockEntity::new, getBarrels()));
|
||||
public static final BlockEntityType<ESignBlockEntity> SIGN = registerBlockEntity("sign",
|
||||
BlockEntityType.Builder.of(ESignBlockEntity::new, getSigns()));
|
||||
public final static BlockEntityType<BlockEntityHydrothermalVent> HYDROTHERMAL_VENT = registerBlockEntity("hydrother_malvent",
|
||||
BlockEntityType.Builder.of(BlockEntityHydrothermalVent::new, EndBlocks.HYDROTHERMAL_VENT));
|
||||
public static final BlockEntityType<EFurnaceBlockEntity> FURNACE = registerBlockEntity("furnace",
|
||||
BlockEntityType.Builder.of(EFurnaceBlockEntity::new, getFurnaces()));
|
||||
|
||||
public static <T extends BlockEntity> BlockEntityType<T> registerBlockEntity(String id, BlockEntityType.Builder<T> builder) {
|
||||
return Registry.register(Registry.BLOCK_ENTITY_TYPE, BetterEnd.makeID(id), builder.build(null));
|
||||
}
|
||||
|
||||
public static void register() {}
|
||||
|
||||
static Block[] getChests() {
|
||||
List<Block> result = Lists.newArrayList();
|
||||
EndItems.getModBlocks().forEach((item) -> {
|
||||
if (item instanceof BlockItem) {
|
||||
Block block = ((BlockItem) item).getBlock();
|
||||
if (block instanceof EndChestBlock) {
|
||||
result.add(block);
|
||||
}
|
||||
}
|
||||
});
|
||||
return result.toArray(new Block[] {});
|
||||
}
|
||||
|
||||
static Block[] getBarrels() {
|
||||
List<Block> result = Lists.newArrayList();
|
||||
EndItems.getModBlocks().forEach((item) -> {
|
||||
if (item instanceof BlockItem) {
|
||||
Block block = ((BlockItem) item).getBlock();
|
||||
if (block instanceof EndBarrelBlock) {
|
||||
result.add(block);
|
||||
}
|
||||
}
|
||||
});
|
||||
return result.toArray(new Block[] {});
|
||||
}
|
||||
|
||||
static Block[] getSigns() {
|
||||
List<Block> result = Lists.newArrayList();
|
||||
EndItems.getModBlocks().forEach((item) -> {
|
||||
if (item instanceof BlockItem) {
|
||||
Block block = ((BlockItem) item).getBlock();
|
||||
if (block instanceof EndSignBlock) {
|
||||
result.add(block);
|
||||
}
|
||||
}
|
||||
});
|
||||
return result.toArray(new Block[] {});
|
||||
}
|
||||
|
||||
static Block[] getPedestals() {
|
||||
List<Block> result = Lists.newArrayList();
|
||||
|
@ -107,17 +47,4 @@ public class EndBlockEntities {
|
|||
});
|
||||
return result.toArray(new Block[] {});
|
||||
}
|
||||
|
||||
static Block[] getFurnaces() {
|
||||
List<Block> result = Lists.newArrayList();
|
||||
EndItems.getModBlocks().forEach((item) -> {
|
||||
if (item instanceof BlockItem) {
|
||||
Block block = ((BlockItem) item).getBlock();
|
||||
if (block instanceof EndFurnaceBlock) {
|
||||
result.add(block);
|
||||
}
|
||||
}
|
||||
});
|
||||
return result.toArray(new Block[] {});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,11 @@ package ru.betterend.registry;
|
|||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
|
||||
import ru.betterend.blocks.entities.render.EndChestBlockEntityRenderer;
|
||||
import ru.betterend.blocks.entities.render.EndSignBlockEntityRenderer;
|
||||
import ru.betterend.blocks.entities.render.PedestalItemRenderer;
|
||||
import ru.betterend.client.render.PedestalItemRenderer;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class EndBlockEntityRenders {
|
||||
public static void register() {
|
||||
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.CHEST, EndChestBlockEntityRenderer::new);
|
||||
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.SIGN, EndSignBlockEntityRenderer::new);
|
||||
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.PEDESTAL, PedestalItemRenderer::new);
|
||||
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.ETERNAL_PEDESTAL, PedestalItemRenderer::new);
|
||||
BlockEntityRendererRegistry.INSTANCE.register(EndBlockEntities.INFUSION_PEDESTAL, PedestalItemRenderer::new);
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
package ru.betterend.registry;
|
||||
|
||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item.Properties;
|
||||
import net.minecraft.world.item.WaterLilyBlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import ru.bclib.blocks.BasePathBlock;
|
||||
import ru.bclib.registry.BlocksRegistry;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.*;
|
||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||
import ru.betterend.blocks.basis.EndCropBlock;
|
||||
import ru.betterend.blocks.basis.EndFurnaceBlock;
|
||||
import ru.betterend.blocks.basis.EndLeavesBlock;
|
||||
import ru.betterend.blocks.basis.EndOreBlock;
|
||||
import ru.betterend.blocks.basis.EndPathBlock;
|
||||
import ru.betterend.blocks.basis.EndPillarBlock;
|
||||
import ru.betterend.blocks.basis.EndSlabBlock;
|
||||
import ru.betterend.blocks.basis.EndStairsBlock;
|
||||
|
@ -36,12 +34,11 @@ import ru.betterend.blocks.complex.MetalMaterial;
|
|||
import ru.betterend.blocks.complex.StoneMaterial;
|
||||
import ru.betterend.blocks.complex.WoodenMaterial;
|
||||
import ru.betterend.config.Configs;
|
||||
import ru.betterend.interfaces.ISpetialItem;
|
||||
import ru.betterend.item.EndAnvilItem;
|
||||
import ru.betterend.item.material.EndArmorMaterial;
|
||||
import ru.betterend.item.material.EndToolMaterial;
|
||||
import ru.betterend.tab.CreativeTabs;
|
||||
|
||||
public class EndBlocks {
|
||||
public class EndBlocks extends BlocksRegistry {
|
||||
// Terrain //
|
||||
public static final Block ENDSTONE_DUST = registerBlock("endstone_dust", new EndstoneDustBlock());
|
||||
public static final Block END_MYCELIUM = registerBlock("end_mycelium", new EndTerrainBlock(MaterialColor.COLOR_LIGHT_BLUE));
|
||||
|
@ -57,17 +54,17 @@ public class EndBlocks {
|
|||
public static final Block RUTISCUS = registerBlock("rutiscus", new EndTerrainBlock(MaterialColor.COLOR_ORANGE));
|
||||
|
||||
// Roads //
|
||||
public static final Block END_MYCELIUM_PATH = registerBlock("end_mycelium_path", new EndPathBlock(END_MYCELIUM));
|
||||
public static final Block END_MOSS_PATH = registerBlock("end_moss_path", new EndPathBlock(END_MOSS));
|
||||
public static final Block CHORUS_NYLIUM_PATH = registerBlock("chorus_nylium_path", new EndPathBlock(CHORUS_NYLIUM));
|
||||
public static final Block CAVE_MOSS_PATH = registerBlock("cave_moss_path", new EndPathBlock(CAVE_MOSS));
|
||||
public static final Block CRYSTAL_MOSS_PATH = registerBlock("crystal_moss_path", new EndPathBlock(CRYSTAL_MOSS));
|
||||
public static final Block SHADOW_GRASS_PATH = registerBlock("shadow_grass_path", new EndPathBlock(SHADOW_GRASS));
|
||||
public static final Block PINK_MOSS_PATH = registerBlock("pink_moss_path", new EndPathBlock(PINK_MOSS));
|
||||
public static final Block AMBER_MOSS_PATH = registerBlock("amber_moss_path", new EndPathBlock(AMBER_MOSS));
|
||||
public static final Block JUNGLE_MOSS_PATH = registerBlock("jungle_moss_path", new EndPathBlock(JUNGLE_MOSS));
|
||||
public static final Block SANGNUM_PATH = registerBlock("sangnum_path", new EndPathBlock(SANGNUM));
|
||||
public static final Block RUTISCUS_PATH = registerBlock("rutiscus_path", new EndPathBlock(RUTISCUS));
|
||||
public static final Block END_MYCELIUM_PATH = registerBlock("end_mycelium_path", new BasePathBlock(END_MYCELIUM));
|
||||
public static final Block END_MOSS_PATH = registerBlock("end_moss_path", new BasePathBlock(END_MOSS));
|
||||
public static final Block CHORUS_NYLIUM_PATH = registerBlock("chorus_nylium_path", new BasePathBlock(CHORUS_NYLIUM));
|
||||
public static final Block CAVE_MOSS_PATH = registerBlock("cave_moss_path", new BasePathBlock(CAVE_MOSS));
|
||||
public static final Block CRYSTAL_MOSS_PATH = registerBlock("crystal_moss_path", new BasePathBlock(CRYSTAL_MOSS));
|
||||
public static final Block SHADOW_GRASS_PATH = registerBlock("shadow_grass_path", new BasePathBlock(SHADOW_GRASS));
|
||||
public static final Block PINK_MOSS_PATH = registerBlock("pink_moss_path", new BasePathBlock(PINK_MOSS));
|
||||
public static final Block AMBER_MOSS_PATH = registerBlock("amber_moss_path", new BasePathBlock(AMBER_MOSS));
|
||||
public static final Block JUNGLE_MOSS_PATH = registerBlock("jungle_moss_path", new BasePathBlock(JUNGLE_MOSS));
|
||||
public static final Block SANGNUM_PATH = registerBlock("sangnum_path", new BasePathBlock(SANGNUM));
|
||||
public static final Block RUTISCUS_PATH = registerBlock("rutiscus_path", new BasePathBlock(RUTISCUS));
|
||||
|
||||
public static final Block MOSSY_OBSIDIAN = registerBlock("mossy_obsidian", new MossyObsidian());
|
||||
public static final Block DRAGON_BONE_BLOCK = registerBlock("dragon_bone_block", new EndPillarBlock(Blocks.BONE_BLOCK));
|
||||
|
@ -96,7 +93,7 @@ public class EndBlocks {
|
|||
public static final Block PURPUR_PEDESTAL = registerBlock("purpur_pedestal", new PedestalVanilla(Blocks.PURPUR_BLOCK));
|
||||
|
||||
public static final Block HYDROTHERMAL_VENT = registerBlock("hydrothermal_vent", new HydrothermalVentBlock());
|
||||
public static final Block VENT_BUBBLE_COLUMN = registerBlockNI("vent_bubble_column", new VentBubbleColumnBlock());
|
||||
public static final Block VENT_BUBBLE_COLUMN = registerEndBlockOnly("vent_bubble_column", new VentBubbleColumnBlock());
|
||||
|
||||
public static final Block DENSE_SNOW = registerBlock("dense_snow", new DenseSnowBlock());
|
||||
public static final Block EMERALD_ICE = registerBlock("emerald_ice", new EmeraldIceBlock());
|
||||
|
@ -119,8 +116,8 @@ public class EndBlocks {
|
|||
|
||||
public static final Block END_LOTUS_SEED = registerBlock("end_lotus_seed", new EndLotusSeedBlock());
|
||||
public static final Block END_LOTUS_STEM = registerBlock("end_lotus_stem", new EndLotusStemBlock());
|
||||
public static final Block END_LOTUS_LEAF = registerBlockNI("end_lotus_leaf", new EndLotusLeafBlock());
|
||||
public static final Block END_LOTUS_FLOWER = registerBlockNI("end_lotus_flower", new EndLotusFlowerBlock());
|
||||
public static final Block END_LOTUS_LEAF = registerEndBlockOnly("end_lotus_leaf", new EndLotusLeafBlock());
|
||||
public static final Block END_LOTUS_FLOWER = registerEndBlockOnly("end_lotus_flower", new EndLotusFlowerBlock());
|
||||
public static final WoodenMaterial END_LOTUS = new WoodenMaterial("end_lotus", MaterialColor.COLOR_LIGHT_BLUE, MaterialColor.COLOR_CYAN);
|
||||
|
||||
public static final Block LACUGROVE_SAPLING = registerBlock("lacugrove_sapling", new LacugroveSaplingBlock());
|
||||
|
@ -180,15 +177,15 @@ public class EndBlocks {
|
|||
public static final Block LAMELLARIUM = registerBlock("lamellarium", new TerrainPlantBlock(RUTISCUS));
|
||||
|
||||
public static final Block BLUE_VINE_SEED = registerBlock("blue_vine_seed", new BlueVineSeedBlock());
|
||||
public static final Block BLUE_VINE = registerBlockNI("blue_vine", new BlueVineBlock());
|
||||
public static final Block BLUE_VINE = registerEndBlockOnly("blue_vine", new BlueVineBlock());
|
||||
public static final Block BLUE_VINE_LANTERN = registerBlock("blue_vine_lantern", new BlueVineLanternBlock());
|
||||
public static final Block BLUE_VINE_FUR = registerBlock("blue_vine_fur", new FurBlock(BLUE_VINE_SEED, 15, 3, false));
|
||||
|
||||
public static final Block LANCELEAF_SEED = registerBlock("lanceleaf_seed", new LanceleafSeedBlock());
|
||||
public static final Block LANCELEAF = registerBlockNI("lanceleaf", new LanceleafBlock());
|
||||
public static final Block LANCELEAF = registerEndBlockOnly("lanceleaf", new LanceleafBlock());
|
||||
|
||||
public static final Block GLOWING_PILLAR_SEED = registerBlock("glowing_pillar_seed", new GlowingPillarSeedBlock());
|
||||
public static final Block GLOWING_PILLAR_ROOTS = registerBlockNI("glowing_pillar_roots", new GlowingPillarRootsBlock());
|
||||
public static final Block GLOWING_PILLAR_ROOTS = registerEndBlockOnly("glowing_pillar_roots", new GlowingPillarRootsBlock());
|
||||
public static final Block GLOWING_PILLAR_LUMINOPHOR = registerBlock("glowing_pillar_luminophor", new GlowingPillarLuminophorBlock());
|
||||
public static final Block GLOWING_PILLAR_LEAVES = registerBlock("glowing_pillar_leaves", new FurBlock(GLOWING_PILLAR_SEED, 15, 3, false));
|
||||
|
||||
|
@ -196,10 +193,10 @@ public class EndBlocks {
|
|||
public static final Block BOLUX_MUSHROOM = registerBlock("bolux_mushroom", new BoluxMushroomBlock());
|
||||
|
||||
public static final Block LUMECORN_SEED = registerBlock("lumecorn_seed", new LumecornSeedBlock());
|
||||
public static final Block LUMECORN = registerBlockNI("lumecorn", new LumecornBlock());
|
||||
public static final Block LUMECORN = registerEndBlockOnly("lumecorn", new LumecornBlock());
|
||||
|
||||
public static final Block SMALL_AMARANITA_MUSHROOM = registerBlock("small_amaranita_mushroom", new SmallAmaranitaBlock());
|
||||
public static final Block LARGE_AMARANITA_MUSHROOM = registerBlockNI("large_amaranita_mushroom", new LargeAmaranitaBlock());
|
||||
public static final Block LARGE_AMARANITA_MUSHROOM = registerEndBlockOnly("large_amaranita_mushroom", new LargeAmaranitaBlock());
|
||||
public static final Block AMARANITA_STEM = registerBlock("amaranita_stem", new AmaranitaStemBlock());
|
||||
public static final Block AMARANITA_HYPHAE = registerBlock("amaranita_hyphae", new AmaranitaStemBlock());
|
||||
public static final Block AMARANITA_HYMENOPHORE = registerBlock("amaranita_hymenophore", new AmaranitaHymenophoreBlock());
|
||||
|
@ -232,11 +229,11 @@ public class EndBlocks {
|
|||
public static final Block CHARNIA_CYAN = registerBlock("charnia_cyan", new CharniaBlock());
|
||||
public static final Block CHARNIA_GREEN = registerBlock("charnia_green", new CharniaBlock());
|
||||
|
||||
public static final Block END_LILY = registerBlockNI("end_lily", new EndLilyBlock());
|
||||
public static final Block END_LILY = registerEndBlockOnly("end_lily", new EndLilyBlock());
|
||||
public static final Block END_LILY_SEED = registerBlock("end_lily_seed", new EndLilySeedBlock());
|
||||
|
||||
public static final Block HYDRALUX_SAPLING = registerBlock("hydralux_sapling", new HydraluxSaplingBlock());
|
||||
public static final Block HYDRALUX = registerBlockNI("hydralux", new HydraluxBlock());
|
||||
public static final Block HYDRALUX = registerEndBlockOnly("hydralux", new HydraluxBlock());
|
||||
public static final Block HYDRALUX_PETAL_BLOCK = registerBlock("hydralux_petal_block", new HydraluxPetalBlock());
|
||||
public static final ColoredMaterial HYDRALUX_PETAL_BLOCK_COLORED = new ColoredMaterial(HydraluxPetalColoredBlock::new, HYDRALUX_PETAL_BLOCK, true);
|
||||
|
||||
|
@ -318,45 +315,47 @@ public class EndBlocks {
|
|||
public static final Block AETERNIUM_ANVIL = registerBlock("aeternium_anvil", new AeterniumAnvil());
|
||||
|
||||
// Technical
|
||||
public static final Block END_PORTAL_BLOCK = registerBlockNI("end_portal_block", new EndPortalBlock());
|
||||
|
||||
public static void register() {}
|
||||
|
||||
public static final Block END_PORTAL_BLOCK = registerEndBlockOnly("end_portal_block", new EndPortalBlock());
|
||||
|
||||
private static BlocksRegistry BLOCKS_REGISTRY;
|
||||
|
||||
private EndBlocks(CreativeModeTab creativeTab) {
|
||||
super(creativeTab);
|
||||
}
|
||||
|
||||
public static Block registerBlock(ResourceLocation id, Block block) {
|
||||
if (!Configs.BLOCK_CONFIG.getBooleanRoot(id.getPath(), true)) {
|
||||
return block;
|
||||
}
|
||||
Registry.register(Registry.BLOCK, id, block);
|
||||
int maxCount = 64;
|
||||
boolean placeOnWater = false;
|
||||
if (block instanceof ISpetialItem) {
|
||||
ISpetialItem item = (ISpetialItem) block;
|
||||
maxCount = item.getStackSize();
|
||||
placeOnWater = item.canPlaceOnWater();
|
||||
}
|
||||
Properties item = EndItems.makeBlockItemSettings().stacksTo(maxCount);
|
||||
if (placeOnWater) {
|
||||
EndItems.registerBlockItem(id, new WaterLilyBlockItem(block, item));
|
||||
}
|
||||
else {
|
||||
if (block instanceof EndAnvilBlock) {
|
||||
EndItems.registerBlockItem(id, new EndAnvilItem(block));
|
||||
}
|
||||
else {
|
||||
EndItems.registerBlockItem(id, new BlockItem(block, item));
|
||||
}
|
||||
}
|
||||
if (block.defaultBlockState().getMaterial().isFlammable() && FlammableBlockRegistry.getDefaultInstance().get(block).getBurnChance() == 0) {
|
||||
FlammableBlockRegistry.getDefaultInstance().add(block, 5, 5);
|
||||
}
|
||||
getBlockRegistry().register(id, block);
|
||||
return block;
|
||||
}
|
||||
|
||||
public static Block registerBlock(String name, Block block) {
|
||||
return registerBlock(BetterEnd.makeID(name), block);
|
||||
if (!Configs.BLOCK_CONFIG.getBooleanRoot(name, true)) {
|
||||
return block;
|
||||
}
|
||||
return getBlockRegistry().register(name, block);
|
||||
}
|
||||
|
||||
public static Block registerBlockNI(String name, Block block) {
|
||||
return Registry.register(Registry.BLOCK, BetterEnd.makeID(name), block);
|
||||
public static Block registerEndBlockOnly(String name, Block block) {
|
||||
return getBlockRegistry().registerBlockOnly(name, block);
|
||||
}
|
||||
|
||||
public static FabricItemSettings makeBlockItemSettings() {
|
||||
return getBlockRegistry().makeItemSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation createModId(String name) {
|
||||
return BetterEnd.makeID(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static BlocksRegistry getBlockRegistry() {
|
||||
if (BLOCKS_REGISTRY == null) {
|
||||
BLOCKS_REGISTRY = new EndBlocks(CreativeTabs.TAB_BLOCKS);
|
||||
}
|
||||
return BLOCKS_REGISTRY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class EndEntities {
|
|||
EntityType<T> type = FabricEntityTypeBuilder.<T>create(group, entity).dimensions(fixedSize ? EntityDimensions.fixed(width, height) : EntityDimensions.scalable(width, height)).build();
|
||||
if (Configs.ENTITY_CONFIG.getBooleanRoot(id.getPath(), true)) {
|
||||
FabricDefaultAttributeRegistry.register(type, attributes);
|
||||
EndItems.registerEgg("spawn_egg_" + name, type, eggColor, dotsColor);
|
||||
EndItems.registerEndEgg("spawn_egg_" + name, type, eggColor, dotsColor);
|
||||
return Registry.register(Registry.ENTITY_TYPE, BetterEnd.makeID(name), type);
|
||||
}
|
||||
return type;
|
||||
|
|
|
@ -2,35 +2,19 @@ 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;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
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.level.block.DispenserBlock;
|
||||
import ru.bclib.util.TagHelper;
|
||||
import net.minecraft.world.item.*;
|
||||
import ru.bclib.items.BaseArmorItem;
|
||||
import ru.bclib.items.tool.*;
|
||||
import ru.bclib.registry.ItemsRegistry;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.config.Configs;
|
||||
import ru.betterend.item.ArmoredElytra;
|
||||
|
@ -42,8 +26,6 @@ import ru.betterend.item.DrinkItem;
|
|||
import ru.betterend.item.EnchantedPetalItem;
|
||||
import ru.betterend.item.EndArmorItem;
|
||||
import ru.betterend.item.EndBucketItem;
|
||||
import ru.betterend.item.EndDiscItem;
|
||||
import ru.betterend.item.EndSpawnEggItem;
|
||||
import ru.betterend.item.EternalCrystalItem;
|
||||
import ru.betterend.item.ModelProviderItem;
|
||||
import ru.betterend.item.material.EndArmorMaterial;
|
||||
|
@ -56,216 +38,162 @@ import ru.betterend.item.tool.EndShovelItem;
|
|||
import ru.betterend.item.tool.EndSwordItem;
|
||||
import ru.betterend.tab.CreativeTabs;
|
||||
|
||||
public class EndItems {
|
||||
private static final List<Item> MOD_BLOCKS = Lists.newArrayList();
|
||||
private static final List<Item> MOD_ITEMS = Lists.newArrayList();
|
||||
|
||||
public class EndItems extends ItemsRegistry {
|
||||
// Materials //
|
||||
public final static Item ENDER_DUST = registerItem("ender_dust");
|
||||
public final static Item ENDER_SHARD = registerItem("ender_shard");
|
||||
public final static Item AETERNIUM_INGOT = registerItem("aeternium_ingot");
|
||||
public final static Item AETERNIUM_FORGED_PLATE = registerItem("aeternium_forged_plate");
|
||||
public final static Item END_LILY_LEAF = registerItem("end_lily_leaf");
|
||||
public final static Item END_LILY_LEAF_DRIED = registerItem("end_lily_leaf_dried");
|
||||
public final static Item CRYSTAL_SHARDS = registerItem("crystal_shards");
|
||||
public final static Item RAW_AMBER = registerItem("raw_amber");
|
||||
public final static Item AMBER_GEM = registerItem("amber_gem");
|
||||
public final static Item GLOWING_BULB = registerItem("glowing_bulb");
|
||||
public final static Item CRYSTALLINE_SULPHUR = registerItem("crystalline_sulphur");
|
||||
public final static Item HYDRALUX_PETAL = registerItem("hydralux_petal");
|
||||
public final static Item GELATINE = registerItem("gelatine");
|
||||
public static final Item ETERNAL_CRYSTAL = registerItem("eternal_crystal", new EternalCrystalItem());
|
||||
public final static Item ENCHANTED_PETAL = registerItem("enchanted_petal", new EnchantedPetalItem());
|
||||
public final static Item LEATHER_STRIPE = registerItem("leather_stripe");
|
||||
public final static Item LEATHER_WRAPPED_STICK = registerItem("leather_wrapped_stick");
|
||||
public final static Item SILK_FIBER = registerItem("silk_fiber");
|
||||
public final static Item LUMECORN_ROD = registerItem("lumecorn_rod");
|
||||
public final static Item SILK_MOTH_MATRIX = registerItem("silk_moth_matrix");
|
||||
public final static Item ENDER_DUST = registerEndItem("ender_dust");
|
||||
public final static Item ENDER_SHARD = registerEndItem("ender_shard");
|
||||
public final static Item AETERNIUM_INGOT = registerEndItem("aeternium_ingot");
|
||||
public final static Item AETERNIUM_FORGED_PLATE = registerEndItem("aeternium_forged_plate");
|
||||
public final static Item END_LILY_LEAF = registerEndItem("end_lily_leaf");
|
||||
public final static Item END_LILY_LEAF_DRIED = registerEndItem("end_lily_leaf_dried");
|
||||
public final static Item CRYSTAL_SHARDS = registerEndItem("crystal_shards");
|
||||
public final static Item RAW_AMBER = registerEndItem("raw_amber");
|
||||
public final static Item AMBER_GEM = registerEndItem("amber_gem");
|
||||
public final static Item GLOWING_BULB = registerEndItem("glowing_bulb");
|
||||
public final static Item CRYSTALLINE_SULPHUR = registerEndItem("crystalline_sulphur");
|
||||
public final static Item HYDRALUX_PETAL = registerEndItem("hydralux_petal");
|
||||
public final static Item GELATINE = registerEndItem("gelatine");
|
||||
public static final Item ETERNAL_CRYSTAL = registerEndItem("eternal_crystal", new EternalCrystalItem());
|
||||
public final static Item ENCHANTED_PETAL = registerEndItem("enchanted_petal", new EnchantedPetalItem());
|
||||
public final static Item LEATHER_STRIPE = registerEndItem("leather_stripe");
|
||||
public final static Item LEATHER_WRAPPED_STICK = registerEndItem("leather_wrapped_stick");
|
||||
public final static Item SILK_FIBER = registerEndItem("silk_fiber");
|
||||
public final static Item LUMECORN_ROD = registerEndItem("lumecorn_rod");
|
||||
public final static Item SILK_MOTH_MATRIX = registerEndItem("silk_moth_matrix");
|
||||
|
||||
// Music Discs
|
||||
public final static Item MUSIC_DISC_STRANGE_AND_ALIEN = registerDisc("music_disc_strange_and_alien", 0, EndSounds.RECORD_STRANGE_AND_ALIEN);
|
||||
public final static Item MUSIC_DISC_GRASPING_AT_STARS = registerDisc("music_disc_grasping_at_stars", 0, EndSounds.RECORD_GRASPING_AT_STARS);
|
||||
public final static Item MUSIC_DISC_ENDSEEKER = registerDisc("music_disc_endseeker", 0, EndSounds.RECORD_ENDSEEKER);
|
||||
public final static Item MUSIC_DISC_EO_DRACONA = registerDisc("music_disc_eo_dracona", 0, EndSounds.RECORD_EO_DRACONA);
|
||||
public final static Item MUSIC_DISC_STRANGE_AND_ALIEN = registerEndDisc("music_disc_strange_and_alien", 0, EndSounds.RECORD_STRANGE_AND_ALIEN);
|
||||
public final static Item MUSIC_DISC_GRASPING_AT_STARS = registerEndDisc("music_disc_grasping_at_stars", 0, EndSounds.RECORD_GRASPING_AT_STARS);
|
||||
public final static Item MUSIC_DISC_ENDSEEKER = registerEndDisc("music_disc_endseeker", 0, EndSounds.RECORD_ENDSEEKER);
|
||||
public final static Item MUSIC_DISC_EO_DRACONA = registerEndDisc("music_disc_eo_dracona", 0, EndSounds.RECORD_EO_DRACONA);
|
||||
|
||||
// Armor //
|
||||
public static final Item AETERNIUM_HELMET = registerItem("aeternium_helmet", new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.HEAD, makeItemSettings().fireResistant()));
|
||||
public static final Item AETERNIUM_CHESTPLATE = registerItem("aeternium_chestplate", new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.CHEST, makeItemSettings().fireResistant()));
|
||||
public static final Item AETERNIUM_LEGGINGS = registerItem("aeternium_leggings", new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.LEGS, makeItemSettings().fireResistant()));
|
||||
public static final Item AETERNIUM_BOOTS = registerItem("aeternium_boots", new EndArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.FEET, makeItemSettings().fireResistant()));
|
||||
public static final Item CRYSTALITE_HELMET = registerItem("crystalite_helmet", new CrystaliteHelmet());
|
||||
public static final Item CRYSTALITE_CHESTPLATE = registerItem("crystalite_chestplate", new CrystaliteChestplate());
|
||||
public static final Item CRYSTALITE_LEGGINGS = registerItem("crystalite_leggings", new CrystaliteLeggings());
|
||||
public static final Item CRYSTALITE_BOOTS = registerItem("crystalite_boots", new CrystaliteBoots());
|
||||
public static final Item ARMORED_ELYTRA = registerItem("elytra_armored", new ArmoredElytra("elytra_armored", EndArmorMaterial.AETERNIUM, Items.PHANTOM_MEMBRANE, 900, 0.96D, true));
|
||||
public static final Item AETERNIUM_HELMET = registerEndItem("aeternium_helmet", new BaseArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.HEAD, makeEndItemSettings().fireResistant()));
|
||||
public static final Item AETERNIUM_CHESTPLATE = registerEndItem("aeternium_chestplate", new BaseArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.CHEST, makeEndItemSettings().fireResistant()));
|
||||
public static final Item AETERNIUM_LEGGINGS = registerEndItem("aeternium_leggings", new BaseArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.LEGS, makeEndItemSettings().fireResistant()));
|
||||
public static final Item AETERNIUM_BOOTS = registerEndItem("aeternium_boots", new BaseArmorItem(EndArmorMaterial.AETERNIUM, EquipmentSlot.FEET, makeEndItemSettings().fireResistant()));
|
||||
public static final Item CRYSTALITE_HELMET = registerEndItem("crystalite_helmet", new CrystaliteHelmet());
|
||||
public static final Item CRYSTALITE_CHESTPLATE = registerEndItem("crystalite_chestplate", new CrystaliteChestplate());
|
||||
public static final Item CRYSTALITE_LEGGINGS = registerEndItem("crystalite_leggings", new CrystaliteLeggings());
|
||||
public static final Item CRYSTALITE_BOOTS = registerEndItem("crystalite_boots", new CrystaliteBoots());
|
||||
public static final Item ARMORED_ELYTRA = registerEndItem("elytra_armored", new ArmoredElytra("elytra_armored", EndArmorMaterial.AETERNIUM, Items.PHANTOM_MEMBRANE, 900, 0.96D, true));
|
||||
|
||||
// Tools //
|
||||
public static final TieredItem AETERNIUM_SHOVEL = registerTool("aeternium_shovel", new EndShovelItem(EndToolMaterial.AETERNIUM, 1.5F, -3.0F, makeItemSettings().fireResistant()));
|
||||
public static final TieredItem AETERNIUM_SWORD = registerTool("aeternium_sword", new EndSwordItem(EndToolMaterial.AETERNIUM, 3, -2.4F, makeItemSettings().fireResistant()));
|
||||
public static final TieredItem AETERNIUM_PICKAXE = registerTool("aeternium_pickaxe", new EndPickaxeItem(EndToolMaterial.AETERNIUM, 1, -2.8F, makeItemSettings().fireResistant()));
|
||||
public static final TieredItem AETERNIUM_AXE = registerTool("aeternium_axe", new EndAxeItem(EndToolMaterial.AETERNIUM, 5.0F, -3.0F, makeItemSettings().fireResistant()));
|
||||
public static final TieredItem AETERNIUM_HOE = registerTool("aeternium_hoe", new EndHoeItem(EndToolMaterial.AETERNIUM, -3, 0.0F, makeItemSettings().fireResistant()));
|
||||
public static final TieredItem AETERNIUM_HAMMER = registerTool("aeternium_hammer", new EndHammerItem(EndToolMaterial.AETERNIUM, 6.0F, -3.0F, 0.3D, makeItemSettings().fireResistant()));
|
||||
public static final TieredItem AETERNIUM_SHOVEL = registerEndTool("aeternium_shovel", new BaseShovelItem(EndToolMaterial.AETERNIUM, 1.5F, -3.0F, makeEndItemSettings().fireResistant()));
|
||||
public static final TieredItem AETERNIUM_SWORD = registerEndTool("aeternium_sword", new BaseSwordItem(EndToolMaterial.AETERNIUM, 3, -2.4F, makeEndItemSettings().fireResistant()));
|
||||
public static final TieredItem AETERNIUM_PICKAXE = registerEndTool("aeternium_pickaxe", new BasePickaxeItem(EndToolMaterial.AETERNIUM, 1, -2.8F, makeEndItemSettings().fireResistant()));
|
||||
public static final TieredItem AETERNIUM_AXE = registerEndTool("aeternium_axe", new BaseAxeItem(EndToolMaterial.AETERNIUM, 5.0F, -3.0F, makeEndItemSettings().fireResistant()));
|
||||
public static final TieredItem AETERNIUM_HOE = registerEndTool("aeternium_hoe", new BaseHoeItem(EndToolMaterial.AETERNIUM, -3, 0.0F, makeEndItemSettings().fireResistant()));
|
||||
public static final TieredItem AETERNIUM_HAMMER = registerEndTool("aeternium_hammer", new EndHammerItem(EndToolMaterial.AETERNIUM, 6.0F, -3.0F, 0.3D, makeEndItemSettings().fireResistant()));
|
||||
|
||||
// Toolparts //
|
||||
public final static Item AETERNIUM_SHOVEL_HEAD = registerItem("aeternium_shovel_head");
|
||||
public final static Item AETERNIUM_PICKAXE_HEAD = registerItem("aeternium_pickaxe_head");
|
||||
public final static Item AETERNIUM_AXE_HEAD = registerItem("aeternium_axe_head");
|
||||
public final static Item AETERNIUM_HOE_HEAD = registerItem("aeternium_hoe_head");
|
||||
public final static Item AETERNIUM_HAMMER_HEAD = registerItem("aeternium_hammer_head");
|
||||
public final static Item AETERNIUM_SWORD_BLADE = registerItem("aeternium_sword_blade");
|
||||
public final static Item AETERNIUM_SWORD_HANDLE = registerItem("aeternium_sword_handle");
|
||||
public final static Item AETERNIUM_SHOVEL_HEAD = registerEndItem("aeternium_shovel_head");
|
||||
public final static Item AETERNIUM_PICKAXE_HEAD = registerEndItem("aeternium_pickaxe_head");
|
||||
public final static Item AETERNIUM_AXE_HEAD = registerEndItem("aeternium_axe_head");
|
||||
public final static Item AETERNIUM_HOE_HEAD = registerEndItem("aeternium_hoe_head");
|
||||
public final static Item AETERNIUM_HAMMER_HEAD = registerEndItem("aeternium_hammer_head");
|
||||
public final static Item AETERNIUM_SWORD_BLADE = registerEndItem("aeternium_sword_blade");
|
||||
public final static Item AETERNIUM_SWORD_HANDLE = registerEndItem("aeternium_sword_handle");
|
||||
|
||||
// Hammers //
|
||||
public static final TieredItem IRON_HAMMER = registerTool("iron_hammer", new EndHammerItem(Tiers.IRON, 5.0F, -3.2F, 0.2D, makeItemSettings()));
|
||||
public static final TieredItem GOLDEN_HAMMER = registerTool("golden_hammer", new EndHammerItem(Tiers.GOLD, 4.5F, -3.4F, 0.3D, makeItemSettings()));
|
||||
public static final TieredItem DIAMOND_HAMMER = registerTool("diamond_hammer", new EndHammerItem(Tiers.DIAMOND, 5.5F, -3.1F, 0.2D, makeItemSettings()));
|
||||
public static final TieredItem NETHERITE_HAMMER = registerTool("netherite_hammer", new EndHammerItem(Tiers.NETHERITE, 5.0F, -3.0F, 0.2D, makeItemSettings().fireResistant()));
|
||||
public static final TieredItem IRON_HAMMER = registerEndTool("iron_hammer", new EndHammerItem(Tiers.IRON, 5.0F, -3.2F, 0.2D, makeEndItemSettings()));
|
||||
public static final TieredItem GOLDEN_HAMMER = registerEndTool("golden_hammer", new EndHammerItem(Tiers.GOLD, 4.5F, -3.4F, 0.3D, makeEndItemSettings()));
|
||||
public static final TieredItem DIAMOND_HAMMER = registerEndTool("diamond_hammer", new EndHammerItem(Tiers.DIAMOND, 5.5F, -3.1F, 0.2D, makeEndItemSettings()));
|
||||
public static final TieredItem NETHERITE_HAMMER = registerEndTool("netherite_hammer", new EndHammerItem(Tiers.NETHERITE, 5.0F, -3.0F, 0.2D, makeEndItemSettings().fireResistant()));
|
||||
|
||||
// Food //
|
||||
public final static Item SHADOW_BERRY_RAW = registerFood("shadow_berry_raw", 4, 0.5F);
|
||||
public final static Item SHADOW_BERRY_COOKED = registerFood("shadow_berry_cooked", 6, 0.7F);
|
||||
public final static Item END_FISH_RAW = registerFood("end_fish_raw", Foods.SALMON);
|
||||
public final static Item END_FISH_COOKED = registerFood("end_fish_cooked", Foods.COOKED_SALMON);
|
||||
public final static Item BUCKET_END_FISH = registerItem("bucket_end_fish", new EndBucketItem(EndEntities.END_FISH));
|
||||
public final static Item BUCKET_CUBOZOA = registerItem("bucket_cubozoa", new EndBucketItem(EndEntities.CUBOZOA));
|
||||
public final static Item SWEET_BERRY_JELLY = registerFood("sweet_berry_jelly", 8, 0.7F);
|
||||
public final static Item SHADOW_BERRY_JELLY = registerFood("shadow_berry_jelly", 6, 0.8F, new MobEffectInstance(MobEffects.NIGHT_VISION, 400));
|
||||
public final static Item BLOSSOM_BERRY_JELLY = registerFood("blossom_berry_jelly", 8, 0.7F);
|
||||
public final static Item BLOSSOM_BERRY = registerFood("blossom_berry", Foods.APPLE);
|
||||
public final static Item AMBER_ROOT_RAW = registerFood("amber_root_raw", 2, 0.8F);
|
||||
public final static Item CHORUS_MUSHROOM_RAW = registerFood("chorus_mushroom_raw", 3, 0.5F);
|
||||
public final static Item CHORUS_MUSHROOM_COOKED = registerFood("chorus_mushroom_cooked", Foods.MUSHROOM_STEW);
|
||||
public final static Item BOLUX_MUSHROOM_COOKED = registerFood("bolux_mushroom_cooked", Foods.MUSHROOM_STEW);
|
||||
public final static Item CAVE_PUMPKIN_PIE = registerFood("cave_pumpkin_pie", Foods.PUMPKIN_PIE);
|
||||
|
||||
public final static Item SHADOW_BERRY_RAW = registerEndFood("shadow_berry_raw", 4, 0.5F);
|
||||
public final static Item SHADOW_BERRY_COOKED = registerEndFood("shadow_berry_cooked", 6, 0.7F);
|
||||
public final static Item END_FISH_RAW = registerEndFood("end_fish_raw", Foods.SALMON);
|
||||
public final static Item END_FISH_COOKED = registerEndFood("end_fish_cooked", Foods.COOKED_SALMON);
|
||||
public final static Item BUCKET_END_FISH = registerEndItem("bucket_end_fish", new EndBucketItem(EndEntities.END_FISH));
|
||||
public final static Item BUCKET_CUBOZOA = registerEndItem("bucket_cubozoa", new EndBucketItem(EndEntities.CUBOZOA));
|
||||
public final static Item SWEET_BERRY_JELLY = registerEndFood("sweet_berry_jelly", 8, 0.7F);
|
||||
public final static Item SHADOW_BERRY_JELLY = registerEndFood("shadow_berry_jelly", 6, 0.8F, new MobEffectInstance(MobEffects.NIGHT_VISION, 400));
|
||||
public final static Item BLOSSOM_BERRY_JELLY = registerEndFood("blossom_berry_jelly", 8, 0.7F);
|
||||
public final static Item BLOSSOM_BERRY = registerEndFood("blossom_berry", Foods.APPLE);
|
||||
public final static Item AMBER_ROOT_RAW = registerEndFood("amber_root_raw", 2, 0.8F);
|
||||
public final static Item CHORUS_MUSHROOM_RAW = registerEndFood("chorus_mushroom_raw", 3, 0.5F);
|
||||
public final static Item CHORUS_MUSHROOM_COOKED = registerEndFood("chorus_mushroom_cooked", Foods.MUSHROOM_STEW);
|
||||
public final static Item BOLUX_MUSHROOM_COOKED = registerEndFood("bolux_mushroom_cooked", Foods.MUSHROOM_STEW);
|
||||
public final static Item CAVE_PUMPKIN_PIE = registerEndFood("cave_pumpkin_pie", Foods.PUMPKIN_PIE);
|
||||
// Drinks //
|
||||
public final static Item UMBRELLA_CLUSTER_JUICE = registerDrink("umbrella_cluster_juice", 5, 0.7F);
|
||||
|
||||
public static Item registerDisc(String name, int power, SoundEvent sound) {
|
||||
return registerItem(BetterEnd.makeID(name), new EndDiscItem(power, sound, makeItemSettings()));
|
||||
public final static Item UMBRELLA_CLUSTER_JUICE = registerEndDrink("umbrella_cluster_juice", 5, 0.7F);
|
||||
|
||||
private final static ItemsRegistry ITEM_REGISTRY = new EndItems(CreativeTabs.TAB_ITEMS);
|
||||
|
||||
protected EndItems(CreativeModeTab creativeTab) {
|
||||
super(creativeTab);
|
||||
}
|
||||
|
||||
public static Item registerEndDisc(String name, int power, SoundEvent sound) {
|
||||
return ITEM_REGISTRY.registerDisc(name, power, sound);
|
||||
}
|
||||
|
||||
public static Item registerItem(String name) {
|
||||
return registerItem(BetterEnd.makeID(name), new ModelProviderItem(makeItemSettings()));
|
||||
public static Item registerEndItem(String name) {
|
||||
return ITEM_REGISTRY.registerItem(name);
|
||||
}
|
||||
|
||||
public static Item registerItem(String name, Item item) {
|
||||
return registerItem(BetterEnd.makeID(name), item);
|
||||
public static Item registerEndItem(String name, Item item) {
|
||||
return ITEM_REGISTRY.register(BetterEnd.makeID(name), item);
|
||||
}
|
||||
|
||||
public static Item registerItem(ResourceLocation id, Item item) {
|
||||
public static Item registerEndItem(ResourceLocation id, Item item) {
|
||||
if (item instanceof ArmorItem) {
|
||||
return registerArmor(id, item);
|
||||
return registerEndArmor(id, item);
|
||||
}
|
||||
if (!Configs.ITEM_CONFIG.getBoolean("items", id.getPath(), true)) {
|
||||
return item;
|
||||
}
|
||||
registerItem(id, item, MOD_ITEMS);
|
||||
ITEM_REGISTRY.register(id, item);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static Item registerBlockItem(ResourceLocation id, Item item) {
|
||||
registerItem(id, item, MOD_BLOCKS);
|
||||
return item;
|
||||
}
|
||||
|
||||
private static void registerItem(ResourceLocation id, Item item, List<Item> registry) {
|
||||
if (item != Items.AIR) {
|
||||
Registry.register(Registry.ITEM, id, item);
|
||||
registry.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private static Item registerArmor(ResourceLocation id, Item item) {
|
||||
if (!Configs.ITEM_CONFIG.getBoolean("armor", id.getPath(), true)) {
|
||||
private static Item registerEndArmor(ResourceLocation itemId, Item item) {
|
||||
if (!Configs.ITEM_CONFIG.getBoolean("armor", itemId.getPath(), true)) {
|
||||
return item;
|
||||
}
|
||||
registerItem(id, item, MOD_ITEMS);
|
||||
ITEM_REGISTRY.register(itemId, item);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static TieredItem registerTool(String name, TieredItem item) {
|
||||
ResourceLocation id = BetterEnd.makeID(name);
|
||||
if (!Configs.ITEM_CONFIG.getBoolean("tools", id.getPath(), true)) {
|
||||
public static TieredItem registerEndTool(String name, TieredItem item) {
|
||||
if (!Configs.ITEM_CONFIG.getBoolean("tools", name, true)) {
|
||||
return item;
|
||||
}
|
||||
registerItem(id, item, MOD_ITEMS);
|
||||
|
||||
if (item instanceof ShovelItem) {
|
||||
TagHelper.addTag((Tag.Named<Item>) FabricToolTags.SHOVELS, item);
|
||||
} else if (item instanceof SwordItem) {
|
||||
TagHelper.addTag((Tag.Named<Item>) FabricToolTags.SWORDS, item);
|
||||
} else if (item instanceof EndPickaxeItem) {
|
||||
TagHelper.addTag((Tag.Named<Item>) FabricToolTags.PICKAXES, item);
|
||||
} else if (item instanceof EndAxeItem) {
|
||||
TagHelper.addTag((Tag.Named<Item>) FabricToolTags.AXES, item);
|
||||
} else if (item instanceof EndHoeItem) {
|
||||
TagHelper.addTag((Tag.Named<Item>) FabricToolTags.HOES, item);
|
||||
} else if (item instanceof EndHammerItem) {
|
||||
TagHelper.addTag(EndTags.HAMMERS, item);
|
||||
}
|
||||
|
||||
return item;
|
||||
return ITEM_REGISTRY.registerTool(name, item);
|
||||
}
|
||||
|
||||
public static Item registerEgg(String name, EntityType<?> type, int background, int dots) {
|
||||
SpawnEggItem item = new EndSpawnEggItem(type, background, dots, makeItemSettings());
|
||||
DefaultDispenseItemBehavior behavior = new DefaultDispenseItemBehavior() {
|
||||
public ItemStack execute(BlockSource pointer, ItemStack stack) {
|
||||
Direction direction = pointer.getBlockState().getValue(DispenserBlock.FACING);
|
||||
EntityType<?> entityType = ((SpawnEggItem) stack.getItem()).getType(stack.getTag());
|
||||
entityType.spawn(pointer.getLevel(), stack, null, pointer.getPos().relative(direction), MobSpawnType.DISPENSER, direction != Direction.UP, false);
|
||||
stack.shrink(1);
|
||||
return stack;
|
||||
}
|
||||
};
|
||||
DispenserBlock.registerBehavior(item, behavior);
|
||||
return registerItem(name, item);
|
||||
public static Item registerEndEgg(String name, EntityType<?> type, int background, int dots) {
|
||||
return ITEM_REGISTRY.registerEgg(name, type, background, dots);
|
||||
}
|
||||
|
||||
public static Item registerFood(String name, int hunger, float saturation, MobEffectInstance... effects) {
|
||||
FoodProperties.Builder builder = new FoodProperties.Builder().nutrition(hunger).saturationMod(saturation);
|
||||
for (MobEffectInstance effect: effects) {
|
||||
builder.effect(effect, 1F);
|
||||
}
|
||||
return registerFood(name, builder.build());
|
||||
public static Item registerEndFood(String name, int hunger, float saturation, MobEffectInstance... effects) {
|
||||
return ITEM_REGISTRY.registerFood(name, hunger, saturation, effects);
|
||||
}
|
||||
|
||||
public static Item registerFood(String name, FoodProperties foodComponent) {
|
||||
return registerItem(name, new ModelProviderItem(makeItemSettings().food(foodComponent)));
|
||||
public static Item registerEndFood(String name, FoodProperties foodComponent) {
|
||||
return ITEM_REGISTRY.registerFood(name, foodComponent);
|
||||
}
|
||||
|
||||
public static Item registerDrink(String name) {
|
||||
return registerItem(name, new DrinkItem(makeItemSettings().stacksTo(1)));
|
||||
public static Item registerEndDrink(String name) {
|
||||
return ITEM_REGISTRY.registerDrink(name);
|
||||
}
|
||||
|
||||
public static Item registerDrink(String name, FoodProperties foodComponent) {
|
||||
return registerItem(name, new DrinkItem(makeItemSettings().stacksTo(1).food(foodComponent)));
|
||||
public static Item registerEndDrink(String name, FoodProperties foodComponent) {
|
||||
return ITEM_REGISTRY.registerDrink(name, foodComponent);
|
||||
}
|
||||
|
||||
public static Item registerDrink(String name, int hunger, float saturation) {
|
||||
FoodProperties.Builder builder = new FoodProperties.Builder().nutrition(hunger).saturationMod(saturation);
|
||||
return registerDrink(name, builder.build());
|
||||
public static Item registerEndDrink(String name, int hunger, float saturation) {
|
||||
return ITEM_REGISTRY.registerDrink(name, hunger, saturation);
|
||||
}
|
||||
|
||||
public static FabricItemSettings makeItemSettings() {
|
||||
FabricItemSettings properties = new FabricItemSettings();
|
||||
return (FabricItemSettings) properties.tab(CreativeTabs.TAB_ITEMS);
|
||||
}
|
||||
|
||||
public static FabricItemSettings makeBlockItemSettings() {
|
||||
FabricItemSettings properties = new FabricItemSettings();
|
||||
return (FabricItemSettings) properties.tab(CreativeTabs.TAB_BLOCKS);
|
||||
public static FabricItemSettings makeEndItemSettings() {
|
||||
return ITEM_REGISTRY.makeItemSettings();
|
||||
}
|
||||
|
||||
public static void register() {}
|
||||
|
||||
public static List<Item> getModBlocks() {
|
||||
return MOD_BLOCKS;
|
||||
}
|
||||
|
||||
public static List<Item> getModItems() {
|
||||
return MOD_ITEMS;
|
||||
@Override
|
||||
public ResourceLocation createModId(String name) {
|
||||
return BetterEnd.makeID(name);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue