- 57
- 2
- 0
Всем привет! Регистрирую TileEntityType с помощью DefferedRegister:
Ошибка (место указано комментарием): Cannot resolve constructor 'TileEntityStoneSmelter', хотя конструктор определён и существует. Код остальных связанных классов:
Очень надеюсь на вашу помощь. Заранее спасибо.
ModTileEntityTypes.java:
package sqcode.realindustry.util;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import sqcode.realindustry.RealIndustry;
import sqcode.realindustry.blocks.tiles.TileEntityStoneSmelter;
public class ModTileEntityTypes
{
private static final DeferredRegister<TileEntityType<?>> TILE_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, RealIndustry.MOD_ID);
public static final RegistryObject<TileEntityType<TileEntityStoneSmelter>> STONE_SMELTER = TILE_ENTITY_TYPES.register("te_type_stone_smelter", () -> TileEntityType.Builder.create(TileEntityStoneSmelter::new /* <- ругается на new */, RegistryHandler.BLOCK_SMELTER_STONE).build(null));
}
TileEntityStoneSmelter.java:
package sqcode.realindustry.blocks.tiles;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import sqcode.realindustry.util.ModTileEntityTypes;
public class TileEntityStoneSmelter extends TileEntity
{
public TileEntityStoneSmelter(final TileEntityType<?> tileEntityTypeIn)
{
super(tileEntityTypeIn);
}
public TileEntityStoneSmelter()
{
this(ModTileEntityTypes.STONE_SMELTER.get());
}
/*@Override
public CompoundNBT write(CompoundNBT compound) {
return super.write(compound);
}*/
}
BlockSmelter.java:
package sqcode.realindustry.blocks;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.ToolType;
import sqcode.realindustry.items.IngotItem;
import sqcode.realindustry.util.ModTileEntityTypes;
import sqcode.realindustry.util.RegistryHandler;
import javax.annotation.Nullable;
import java.util.stream.Stream;
public class BlockSmelter extends Block
{
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
public static final VoxelShape SHAPE_N = Stream.of(
Block.makeCuboidShape(0, 1, 1, 1, 6, 15),
Block.makeCuboidShape(0, 0, 0, 16, 1, 16),
Block.makeCuboidShape(0, 1, 0, 16, 6, 1),
Block.makeCuboidShape(0, 1, 15, 16, 6, 16),
Block.makeCuboidShape(15, 1, 1, 16, 6, 15)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
public static final VoxelShape SHAPE_E = Stream.of(
Block.makeCuboidShape(1, 1, 0, 15, 6, 1),
Block.makeCuboidShape(0, 0, 0, 16, 1, 16),
Block.makeCuboidShape(15, 1, 0, 16, 6, 16),
Block.makeCuboidShape(0, 1, 0, 1, 6, 16),
Block.makeCuboidShape(1, 1, 15, 15, 6, 16)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
public static final VoxelShape SHAPE_S = Stream.of(
Block.makeCuboidShape(15, 1, 1, 16, 6, 15),
Block.makeCuboidShape(0, 0, 0, 16, 1, 16),
Block.makeCuboidShape(0, 1, 15, 16, 6, 16),
Block.makeCuboidShape(0, 1, 0, 16, 6, 1),
Block.makeCuboidShape(0, 1, 1, 1, 6, 15)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
public static final VoxelShape SHAPE_W = Stream.of(
Block.makeCuboidShape(1, 1, 15, 15, 6, 16),
Block.makeCuboidShape(0, 0, 0, 16, 1, 16),
Block.makeCuboidShape(0, 1, 0, 1, 6, 16),
Block.makeCuboidShape(15, 1, 0, 16, 6, 16),
Block.makeCuboidShape(1, 1, 0, 15, 6, 1)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
public BlockSmelter()
{
super(Properties.create(Material.ROCK)
.hardnessAndResistance(3.5f, 4f)
.harvestLevel(1)
.sound(SoundType.STONE)
.harvestTool(ToolType.PICKAXE)
.noDrops()
);
}
@Override
public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) {
return 0.6f;
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
switch (state.get(FACING))
{
case NORTH:
return SHAPE_N;
case EAST:
return SHAPE_E;
case SOUTH:
return SHAPE_S;
case WEST:
return SHAPE_W;
default:
return SHAPE_N;
}
}
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext context)
{
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
public BlockState rotate(BlockState state, Rotation rotation)
{
return state.with(FACING, rotation.rotate(state.get(FACING)));
}
@Override
public BlockState mirror(BlockState state, Mirror mirrorIn)
{
return state.rotate(mirrorIn.toRotation(state.get(FACING)));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
{
builder.add(FACING);
}
@Override
public boolean hasTileEntity(BlockState state)
{
return true;
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return ModTileEntityTypes.STONE_SMELTER.get().create();
}
}