Не импортируется WorldGenAbstractTree

Версия Minecraft
1.12.2
Не импортируется WorldGenAbstractTree (скрин). Вообще не вкуриваю, в чем проблема. В net.minecraft.world.gen.feature этот класс есть. Ниже код, если нужен. Как решается?

Код:
package nuc.lamp.world.generate.gentree;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import nuc.lamp.block.BlockRegister;

import java.util.Random;

public class WorldGenHalfdeadTree extends WorldGenAbstractTree
{
    public static final IBlockState LOG = BlockRegister.LOG_OF_A_HALFDEAD_TREE.getDefaultState();
    public static final IBlockState LEAF = BlockRegister.HALFDEAD_FOLIAGE.getDefaultState();

    private final int minHeight;

    public WorldGenHalfdeadTree()
    {
        super(false);
        this.minHeight = 12;
    }

    public boolean generate(World world, Random rand, BlockPos pos)
    {
        int height = this.minHeight + rand.nextInt(3);
        boolean flag = true;

        int x = pos.getX();
        int y = pos.getY();
        int z = pos.getZ();

        for(int yPos = y; yPos <= y + 1 + height; yPos++)
        {
            int b0 = 2;
            if(yPos == y) b0 = 1;
            if(yPos >= y + 1 + height - 2) b0 = 2;

            BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();

            for(int xPos = x - b0; xPos <= x + b0 && flag; xPos++)
            {
                for(int zPos = z - b0; zPos <- z + b0 && flag; zPos++)
                {
                    if(yPos >= 0 && yPos < world.getHeight())
                    {
                        if(!this.isReplaceable(world, new BlockPos(xPos, yPos, zPos)))
                        {
                            flag = false;
                        }
                    }
                    else
                    {
                        flag = false;
                    }
                }
            }
        }

        if(!flag)
        {
            return false;
        }
        else
        {
            BlockPos down = pos.down();
            IBlockState state = world.getBlockState(down);
            boolean isSoil = state.getBlock().canSustainPlant(state, world, down, EnumFacing.UP, (IPlantable) BlockRegister.SAPLING_OF_A_HALFDEAD_TREE);

            if(isSoil && y < world.getHeight() - height - 1)
            {
                state.getBlock().onPlantGrow(state, world, down, pos);

                for(int yPos = y - 3 + height; yPos <= y + height; yPos++)
                {
                    int b1 = yPos - (y + height);
                    int b2 = 1 - b1 / 2;

                    for(int xPos = x - b2; xPos <= x + b2; xPos++)
                    {
                        int b3 = xPos - x;
                        for(int zPos = z - b2; zPos <= z + b2; zPos++)
                        {
                            int b4 = zPos - z;
                            if(Math.abs(b3) != b2 || Math.abs(b4) != b2 || rand.nextInt(2) != 0 && b1 != 0)
                            {
                                BlockPos treePos = new BlockPos(xPos, yPos, zPos);
                                IBlockState treeState = world.getBlockState(treePos);
                                if(treeState.getBlock().isAir(treeState, world, treePos) || treeState.getBlock().isAir(treeState, world, treePos))
                                {
                                    this.setBlockAndNotifyAdequately(world, treePos, LEAF);
                                    this.setBlockAndNotifyAdequately(world, treePos.add(0, -0.25 * height, 0), LEAF);
                                    this.setBlockAndNotifyAdequately(world, treePos.add(0, -0.5 * height, 0), LEAF);
                                }
                            }
                        }
                    }
                }

                for(int logHeight = 0; logHeight < height; logHeight++)
                {
                    BlockPos up = pos.up(logHeight);
                    IBlockState logState = world.getBlockState(up);

                    if(logState.getBlock().isAir(logState, world, up) || logState.getBlock().isLeaves(logState, world, up))
                    {
                        this.setBlockAndNotifyAdequately(world, pos.up(logHeight), LOG);
                    }
                }

                return true;
            }
        }

        return true;
    }

    protected boolean canGrowInto(Block blockType)
    {
        Material material = blockType.getDefaultState().getMaterial();
        return material == Material.AIR || material == Material.LEAVES || material == Material.GROUND || blockType == Blocks.GRASS || blockType == Blocks.DIRT || blockType == Blocks.LOG || blockType == Blocks.LOG2 || blockType == Blocks.SAPLING || blockType == Blocks.VINE;

    }
}
 

Вложения

  • Screenshot_27.png
    Screenshot_27.png
    16.5 KB · Просмотры: 8
Попробуй пересобрать воркспейс
 
Смотри как у меня всё реализовано
Java:
public class GuiClayFurnace extends GuiContainer {
    private static final ResourceLocation TEXTURES = new ResourceLocation(MInformation.MOD_ID + ":textures/gui/block_clay_furnace.png");
    public static final int GUI_CLAY_FURNACE = 0;
    private final InventoryPlayer player;
    private final TileEntityClayFurnace tileentity;
 
    public GuiClayFurnace(InventoryPlayer player, TileEntityClayFurnace tileentity) {
        super(new ContainerClayFurnace(player, tileentity));
        this.player = player;
        this.tileentity = tileentity;
    }
 
    @Override
    protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
        String tileName = this.tileentity.getDisplayName().getUnformattedText();
        this.fontRenderer.drawString(tileName, (this.xSize / 2 - this.fontRenderer.getStringWidth(tileName) / 2), 7, 4210752);
        this.fontRenderer.drawString(this.player.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
    }
 
    @Override
    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
        GlStateManager.color(1.0F, 1.0F, 1.0F);
        this.mc.getTextureManager().bindTexture(TEXTURES);
        this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
        if(TileEntityClayFurnace.isBurning(tileentity)) {
            int k = this.getBurnLeftScaled(13);
            this.drawTexturedModalRect(this.guiLeft + 17, this.guiTop + 37 + 12 - k, 176, 12 - k, 14, k + 1);
        } int l = this.getCookProgressScaled(24, 2, 3);
        this.drawTexturedModalRect(this.guiLeft + 80, this.guiTop + 21, 176, 14, l + 1, 16);
        int m = this.getCookProgressScaled(24, 4, 5);
        this.drawTexturedModalRect(this.guiLeft + 80, this.guiTop + 54, 176, 14, m + 1, 16);
    }
 
    private int getBurnLeftScaled(int pixels) {
        int i = this.tileentity.getField(1);
        if(i == 0) i = 200;
        return this.tileentity.getField(0) * pixels / i;
    }
 
    private int getCookProgressScaled(int pixels, int slot, int slot2) {
        int i = this.tileentity.getField(slot);
        int j = this.tileentity.getField(slot2);
        return j != 0 && i != 0 ? i * pixels / j : 0;
    }
}
Java:
@Config.LangKey("config.mod.category.general")
@Config(modid = MInformation.MOD_ID, name = "general")
public class MConfig {
    @Config.Name("GUI ID")
    @Config.Comment("�������� ID ��� GUI, ����� ��� �� ������������� � ������� ID �����") //Кодировка не та стояла 
    @Config.RequiresWorldRestart
    public static int GUI_CLAY_FURNACE = 0;
Java:
public class MGuiHandler implements IGuiHandler {
    @Override
    public Object getServerGuiElement(int id, EntityPlayer player, World world,    int x, int y, int z) {
        TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
        switch (MConfig.GUI_CLAY_FURNACE) {
        case GuiClayFurnace.GUI_CLAY_FURNACE:
            if ((tileEntity instanceof TileEntityClayFurnace)) {
                return new ContainerClayFurnace(player.inventory, (TileEntityClayFurnace)tileEntity);
            }
        } return null;
    }

    @Override
    public Object getClientGuiElement(int id, EntityPlayer player, World world,    int x, int y, int z) {
        TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
        switch (MConfig.GUI_CLAY_FURNACE) {
        case GuiClayFurnace.GUI_CLAY_FURNACE:
            if ((tileEntity instanceof TileEntityClayFurnace)) {
                return new GuiClayFurnace(player.inventory, (TileEntityClayFurnace)tileEntity);
            }
        } return null;
    }
Java:
public void init(FMLInitializationEvent event) {
NetworkRegistry.INSTANCE.registerGuiHandler(Mod.instance, new MGuiHandler());
}
 
Назад
Сверху