Краш при создании блока с вариантами

MaximPixel

Каменная лига
Сообщения
651
Лучшие ответы
14
Симпатии
13
#1
Версия Minecraft
1.12.2
Подтверждение
Я максимально подробно описал проблему, включая исходный код файлов, краш лог, изображения и другую информацию, которая может помочь пользователям форума решить мой вопрос!
Хочу создать блок с несколькими вариантами, но происходит краш. Что не так?
Java:
public class BlockKek extends Block {
    
    public static final PropertyEnum<EnumMaterial> MATERIAL = PropertyEnum.<EnumMaterial>create("material", EnumMaterial.class);
    public static final PropertyEnum<EnumType> TYPE = PropertyEnum.<EnumType>create("type", EnumType.class);
    
    public BlockElectricPole() {
        super(Material.ROCK);
        
        setCreativeTab(CreativeTabs.REDSTONE);
        
        setDefaultState(blockState.getBaseState().withProperty(MATERIAL, EnumMaterial.STONE).withProperty(TYPE, EnumType.BASE));
    }
    
    @SuppressWarnings("deprecation")
    public boolean canBlockStay(World world, IBlockState state, BlockPos pos) {
        return state.isTopSolid() || state.getBlockFaceShape(world, pos.down(), EnumFacing.UP) == BlockFaceShape.SOLID || state.getBlock() instanceof BlockElectricPole;
    }
    
    @SuppressWarnings("deprecation")
    public boolean canBlockExist(World world, IBlockState state, BlockPos pos) {
        EnumType type = state.getValue(TYPE);
        if (type == EnumType.BASE) {
            if (world.getBlockState(pos.down()).isTopSolid() && isPoleBlock(world, pos.up(), EnumType.BEAM1)) {
                return true;
            }
        } else if (type == EnumType.BEAM1) {
            if (isPoleBlock(world, pos.down(), EnumType.BASE) && isPoleBlock(world, pos.up(), EnumType.BEAM1)) {
                return true;
            }
        } else if (type == EnumType.BEAM2) {
            if (isPoleBlock(world, pos.down(), EnumType.BEAM1) && isPoleBlock(world, pos.up(), EnumType.BEAM3)) {
                return true;
            }
        } else if (type == EnumType.BEAM3) {
            if (isPoleBlock(world, pos.down(), EnumType.BEAM2) && isPoleBlock(world, pos.up(), EnumType.BEAM4)) {
                return true;
            }
        } else if (type == EnumType.BEAM4) {
            if (isPoleBlock(world, pos.down(), EnumType.BEAM3)) {
                return true;
            }
        }
        return false;
    }
    
    public boolean isPoleBlock(World world, BlockPos pos, EnumType type) {
        IBlockState state = world.getBlockState(pos);
        return state.getBlock() instanceof BlockKek && state.getValue(TYPE) == type;
    }
    
    @Override
    public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
        return face.getAxis() == EnumFacing.Axis.Y ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
    }
    
    @Override
    public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
        if (!canBlockExist(world, state, pos)) {
            world.setBlockToAir(pos);
        }
    }
    
    @Override
    public boolean canPlaceBlockAt(World world, BlockPos pos) {
        return canBlockStay(world, world.getBlockState(pos.down()), pos) &&
                world.isAirBlock(pos.up(1)) && world.isAirBlock(pos.up(2)) &&
                world.isAirBlock(pos.up(3)) && world.isAirBlock(pos.up(4));
    }
    
    @Override
    protected BlockStateContainer createBlockState() {
        return new BlockStateContainer(this, new IProperty[] {MATERIAL, TYPE});
    }
    
    @Override
    public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
        for (int a = 0; a < 4; a++) {
            IBlockState beam = getDefaultState().withProperty(TYPE, EnumType.byMeta(a + 1));
            world.setBlockState(pos.up(a + 1), beam);
        }
    }
    
    @Override
    public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
        return false;
    }
    
    @Override
    public int getMetaFromState(IBlockState state) {
        return state.getValue(MATERIAL).getMeta() | state.getValue(TYPE).getMeta() << 3;
    }
    
    @Override
    public IBlockState getStateFromMeta(int meta) {
        return getDefaultState().withProperty(MATERIAL, EnumMaterial.byMeta(meta & 7))
                .withProperty(TYPE, EnumType.byMeta(meta >> 3 & 7));
    }
    
    @Override
    public boolean isOpaqueCube(IBlockState state) {
        return false;
    }

    @Override
    public boolean isFullCube(IBlockState state) {
        return false;
    }
    
    public static enum EnumType implements IStringSerializable {
        BASE(0, "base"),
        BEAM1(1, "beam1"),
        BEAM2(2, "beam2"),
        BEAM3(3, "beam3"),
        BEAM4(4, "beam4");
        
        private final int meta;
        private final String name;
        
        private EnumType(int meta, String name) {
            this.meta = meta;
            this.name = name;
        }
        
        @Override
        public String getName() {
            return name;
        }
        
        public int getMeta() {
            return meta;
        }
        
        public static EnumType byMeta(int meta) {
            EnumType[] values = EnumType.values();
            return values[Math.abs(meta % values.length)];
        }
    }
    
    public static enum EnumMaterial implements IStringSerializable {
        
        STONE(0, "stone");
        
        private final int meta;
        private final String name;
        
        private EnumMaterial(int meta, String name) {
            this.meta = meta;
            this.name = name;
        }
        
        @Override
        public String getName() {
            return name;
        }
        
        public int getMeta() {
            return meta;
        }
        
        public static EnumMaterial byMeta(int meta) {
            EnumMaterial[] values = EnumMaterial.values();
            return values[Math.abs(meta % values.length)];
        }
    }
}
 
Краш-лог:
[19:00:41] [main/ERROR] [FML]: Exception caught during firing event net.minecraftforge.event.RegistryEvent$Register@36173101:
java.lang.ArrayIndexOutOfBoundsException: 16
	at net.minecraftforge.registries.GameData$BlockCallbacks.onAdd(GameData.java:322) ~[GameData$BlockCallbacks.class:?]
	at net.minecraftforge.registries.GameData$BlockCallbacks.onAdd(GameData.java:296) ~[GameData$BlockCallbacks.class:?]
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:358) ~[ForgeRegistry.class:?]
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:289) ~[ForgeRegistry.class:?]
	at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:122) ~[ForgeRegistry.class:?]
	at net.minecraftforge.registries.ForgeRegistry.registerAll(ForgeRegistry.java:163) ~[ForgeRegistry.class:?]
	at net.mpmod.MPMod.registerBlocks(MPMod.java:443) ~[MPMod.class:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_34_MPMod_registerBlocks_Register.invoke(.dynamic) ~[?:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144) ~[EventBus$1.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?]
	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:777) [GameData.class:?]
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628) [Loader.class:?]
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252) [FMLClientHandler.class:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:513) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:25) [start/:?]
[19:00:41] [main/ERROR] [FML]: Index: 9 Listeners:
[19:00:41] [main/ERROR] [FML]: 0: NORMAL
[19:00:41] [main/ERROR] [FML]: 1: net.minecraftforge.fml.common.eventhandler.EventBus$1@28f7be33
[19:00:41] [main/ERROR] [FML]: 2: net.minecraftforge.fml.common.eventhandler.EventBus$1@dc1f7d1
[19:00:41] [main/ERROR] [FML]: 3: net.minecraftforge.fml.common.eventhandler.EventBus$1@5820e157
[19:00:41] [main/ERROR] [FML]: 4: net.minecraftforge.fml.common.eventhandler.EventBus$1@57b05c6b
[19:00:41] [main/ERROR] [FML]: 5: net.minecraftforge.fml.common.eventhandler.EventBus$1@42236688
[19:00:41] [main/ERROR] [FML]: 6: net.minecraftforge.fml.common.eventhandler.EventBus$1@405e6e62
[19:00:41] [main/ERROR] [FML]: 7: net.minecraftforge.fml.common.eventhandler.EventBus$1@1fab1567
[19:00:41] [main/ERROR] [FML]: 8: net.minecraftforge.fml.common.eventhandler.EventBus$1@4aad51fd
[19:00:41] [main/ERROR] [FML]: 9: net.minecraftforge.fml.common.eventhandler.EventBus$1@13e37906
[19:00:41] [main/ERROR] [FML]: 10: net.minecraftforge.fml.common.eventhandler.EventBus$1@207d3866
[19:00:41] [main/ERROR] [FML]: 11: net.minecraftforge.fml.common.eventhandler.EventBus$1@67ba1123
[19:00:41] [main/ERROR] [FML]: 12: net.minecraftforge.fml.common.eventhandler.EventBus$1@47389690
[19:00:41] [main/ERROR] [FML]: 13: net.minecraftforge.fml.common.eventhandler.EventBus$1@4f9bfc38
[19:00:41] [main/ERROR] [FML]: 14: net.minecraftforge.fml.common.eventhandler.EventBus$1@6ec53a5
[19:00:41] [main/ERROR] [FML]: 15: net.minecraftforge.fml.common.eventhandler.EventBus$1@31e86952
[19:00:41] [main/ERROR] [FML]: 16: net.minecraftforge.fml.common.eventhandler.EventBus$1@32e7f5e9
[19:00:41] [main/ERROR] [FML]: 17: net.minecraftforge.fml.common.eventhandler.EventBus$1@228da5b1
[19:00:41] [main/ERROR] [FML]: 18: net.minecraftforge.fml.common.eventhandler.EventBus$1@4698bb3e
[19:00:41] [main/ERROR] [FML]: 19: net.minecraftforge.fml.common.eventhandler.EventBus$1@3448f846
[19:00:41] [main/ERROR] [FML]: 20: net.minecraftforge.fml.common.eventhandler.EventBus$1@398d1b9b
[19:00:41] [main/ERROR] [FML]: 21: net.minecraftforge.fml.common.eventhandler.EventBus$1@76e29136
[19:00:41] [main/ERROR] [FML]: 22: net.minecraftforge.fml.common.eventhandler.EventBus$1@75a0859f
[19:00:41] [main/ERROR] [FML]: 23: net.minecraftforge.fml.common.eventhandler.EventBus$1@6d9d9a5
[19:00:41] [main/ERROR] [FML]: 24: net.minecraftforge.fml.common.eventhandler.EventBus$1@57d94b26
[19:00:41] [main/ERROR] [FML]: 25: net.minecraftforge.fml.common.eventhandler.EventBus$1@35500bca
[19:00:41] [main/ERROR] [FML]: 26: net.minecraftforge.fml.common.eventhandler.EventBus$1@442dec82
[19:00:41] [main/ERROR] [FML]: 27: net.minecraftforge.fml.common.eventhandler.EventBus$1@cf10153
[19:00:41] [main/ERROR] [FML]: 28: net.minecraftforge.fml.common.eventhandler.EventBus$1@11eceb90
[19:00:41] [main/ERROR] [FML]: 29: net.minecraftforge.fml.common.eventhandler.EventBus$1@24d7bc3c
[19:00:41] [main/ERROR] [FML]: 30: net.minecraftforge.fml.common.eventhandler.EventBus$1@fb50dd8
[19:00:41] [main/ERROR] [FML]: 31: net.minecraftforge.fml.common.eventhandler.EventBus$1@b4a6ee4
[19:00:41] [main/ERROR] [FML]: 32: net.minecraftforge.fml.common.eventhandler.EventBus$1@7d8cb476
[19:00:41] [main/ERROR] [FML]: 33: net.minecraftforge.fml.common.eventhandler.EventBus$1@6423d1a7
[19:00:41] [main/ERROR] [FML]: 34: net.minecraftforge.fml.common.eventhandler.EventBus$1@435fdb36
[19:00:41] [main/ERROR] [FML]: 35: net.minecraftforge.fml.common.eventhandler.EventBus$1@1b3aa0f7
[19:00:41] [main/ERROR] [FML]: 36: net.minecraftforge.fml.common.eventhandler.EventBus$1@30d88e2
[19:00:41] [main/ERROR] [FML]: 37: net.minecraftforge.fml.common.eventhandler.EventBus$1@7959cfcd
[19:00:41] [main/ERROR] [FML]: 38: net.minecraftforge.fml.common.eventhandler.EventBus$1@44623dbb
[19:00:41] [main/ERROR] [FML]: 39: net.minecraftforge.fml.common.eventhandler.EventBus$1@a9110d8
[19:00:41] [main/ERROR] [FML]: 40: net.minecraftforge.fml.common.eventhandler.EventBus$1@65b4d3f0
[19:00:41] [main/ERROR] [FML]: 41: net.minecraftforge.fml.common.eventhandler.EventBus$1@52a44f2c
[19:00:41] [main/ERROR] [FML]: 42: net.minecraftforge.fml.common.eventhandler.EventBus$1@77e3f26
[19:00:41] [main/ERROR] [FML]: 43: net.minecraftforge.fml.common.eventhandler.EventBus$1@56be8c1
[19:00:41] [main/ERROR] [FML]: 44: net.minecraftforge.fml.common.eventhandler.EventBus$1@460380cf
[19:00:41] [main/ERROR] [FML]: 45: net.minecraftforge.fml.common.eventhandler.EventBus$1@362e6a0c
[19:00:41] [main/ERROR] [FML]: 46: net.minecraftforge.fml.common.eventhandler.EventBus$1@40dfe4e0
[19:00:41] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ----

WARNING: coremods are present:
  BlurPlugin (Blur-1.0.4-14.jar)
Contact their authors BEFORE contacting forge

// Would you like a cupcake?

Time: 4/3/19 7:00 PM
Description: Initializing game

java.lang.ArrayIndexOutOfBoundsException: 16
	at net.minecraftforge.registries.GameData$BlockCallbacks.onAdd(GameData.java:322)
	at net.minecraftforge.registries.GameData$BlockCallbacks.onAdd(GameData.java:296)
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:358)
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:289)
	at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:122)
	at net.minecraftforge.registries.ForgeRegistry.registerAll(ForgeRegistry.java:163)
	at net.mpmod.MPMod.registerBlocks(MPMod.java:443)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_34_MPMod_registerBlocks_Register.invoke(.dynamic)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
	at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:777)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
	at net.minecraft.client.Minecraft.init(Minecraft.java:513)
	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:25)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
	at net.minecraftforge.registries.GameData$BlockCallbacks.onAdd(GameData.java:322)
	at net.minecraftforge.registries.GameData$BlockCallbacks.onAdd(GameData.java:296)
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:358)
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:289)
	at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:122)
	at net.minecraftforge.registries.ForgeRegistry.registerAll(ForgeRegistry.java:163)
	at net.mpmod.MPMod.registerBlocks(MPMod.java:443)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_34_MPMod_registerBlocks_Register.invoke(.dynamic)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
	at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:777)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
	at net.minecraft.client.Minecraft.init(Minecraft.java:513)

-- Initialization --
Details:
Stacktrace:
	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:25)

-- System Details --
Details:
	Minecraft Version: 1.12.2
	Operating System: Windows 8.1 (amd64) version 6.3
	Java Version: 1.8.0_181, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 119873616 bytes (114 MB) / 958922752 bytes (914 MB) up to 1908932608 bytes (1820 MB)
	JVM Flags: 0 total; 
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.42 Powered by Forge 14.23.5.2768 20 mods loaded, 20 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

	| State | ID                  | Version        | Source                                  | Signature                                |
	|:----- |:------------------- |:-------------- |:--------------------------------------- |:---------------------------------------- |
	| UCH   | minecraft           | 1.12.2         | minecraft.jar                           | None                                     |
	| UCH   | mcp                 | 9.42           | minecraft.jar                           | None                                     |
	| UCH   | FML                 | 8.0.99.99      | forgeSrc-1.12.2-14.23.5.2768.jar        | None                                     |
	| UCH   | forge               | 14.23.5.2768   | forgeSrc-1.12.2-14.23.5.2768.jar        | None                                     |
	| UCH   | mpmod               | 1.7            | bin                                     | None                                     |
	| UCH   | computercraft       | 1.80pr1        | ComputerCraft-1.80pr1-build5.jar        | None                                     |
	| UCH   | waila               | 1.8.26         | Hwyla-1.8.26-B41_1.12.2.jar             | None                                     |
	| UCH   | jei                 | 4.14.3.240     | jei_1.12.2-4.14.3.240.jar               | None                                     |
	| UCH   | buildcraftlib       | 7.99.19        | buildcraft-7.99.19.jar                  | None                                     |
	| UCH   | buildcraftcore      | 7.99.19        | buildcraft-7.99.19.jar                  | None                                     |
	| UCH   | buildcraftbuilders  | 7.99.19        | buildcraft-7.99.19.jar                  | None                                     |
	| UCH   | buildcraftenergy    | 7.99.19        | buildcraft-7.99.19.jar                  | None                                     |
	| UCH   | buildcraftfactory   | 7.99.19        | buildcraft-7.99.19.jar                  | None                                     |
	| UCH   | buildcraftrobotics  | 7.99.19        | buildcraft-7.99.19.jar                  | None                                     |
	| UCH   | buildcrafttransport | 7.99.19        | buildcraft-7.99.19.jar                  | None                                     |
	| UCH   | buildcraftsilicon   | 7.99.19        | buildcraft-7.99.19.jar                  | None                                     |
	| UCH   | blur                | 1.0.4-14       | Blur-1.0.4-14.jar                       | None                                     |
	| UCH   | jeresources         | 0.8.5.27       | JustEnoughResources-1.12.2-0.8.5.27.jar | None                                     |
	| UCH   | llor                | 1.1.6-mc1.12.2 | LLOverlayReloaded-1.1.6-mc1.12.2.jar    | None                                     |
	| UCH   | wawla               | 2.5.269        | Wawla-1.12.2-2.5.269.jar                | d476d1b22b218a10d845928d1665d45fce301b27 |

	Loaded coremods (and transformers): 
BlurPlugin (Blur-1.0.4-14.jar)
  com.tterrag.blur.BlurTransformer
	GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 391.01' Renderer: 'GeForce GT 710/PCIe/SSE2'
	Launched Version: 1.12.2
	LWJGL: 2.9.4
	OpenGL: GeForce GT 710/PCIe/SSE2 GL version 4.6.0 NVIDIA 391.01, NVIDIA Corporation
	GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

	Using VBOs: No
	Is Modded: Definitely; Client brand changed to 'fml,forge'
	Type: Client (map_client.txt)
	Resource Packs: 
	Current Language: English (US)
	Profiler Position: N/A (disabled)
	CPU: 2x Pentium(R) Dual-Core CPU E5700 @ 3.00GHz
[19:00:41] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: #@!@# Game crashed! Crash report saved to: #@!@# F:\Program Files\Minecraft Forge\Minecraft\run\.\crash-reports\crash-2019-04-03_19.00.41-client.txt

Крокодил

Железная лига
Сообщения
681
Лучшие ответы
13
Симпатии
142
#2
Ты где-то за мету вываливаешься вроде... Я с телефона, не могу сориентироваться. Скорее всего в getStateForMeta или getMetaForState, но не уверен...
А, там же registerBlock, беру слова обратно)
 
Последнее редактирование:

Doc

Золотая лига
Сообщения
2,343
Лучшие ответы
126
Симпатии
302
#3

hohserg1

Алмазная лига
Сообщения
3,665
Лучшие ответы
93
Симпатии
436
#4
@Override public int getMetaFromState(IBlockState state) { return state.getValue(MATERIAL).getMeta() | state.getValue(TYPE).getMeta() << 3; } @Override public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(MATERIAL, EnumMaterial.byMeta(meta & 7)) .withProperty(TYPE, EnumType.byMeta(meta >> 3 & 7)); }
Подобный код всегда нужно писать самому когда несколько IProperty?
 

MaximPixel

Каменная лига
Сообщения
651
Лучшие ответы
14
Симпатии
13
#5
@Doc, там просто регистрация
Java:
@SubscribeEvent
public void registerBlocks(RegistryEvent.Register<Block> event) {
    event.getRegistry().registerAll(BLOCK_KEK);
}
 

Крокодил

Железная лига
Сообщения
681
Лучшие ответы
13
Симпатии
142
#7
Подобный код всегда нужно писать самому когда несколько IProperty?
Вообще да. Но в ванили уже есть шаблоны почти на любое сочетание метадат. Хотя, если стейтов больше чем 0-15 то придётся подключать getActualState(). Иначе часть состояний, выходящая за пределы диапазона просто не будет сохранятся при выходе из мира.
 

fixable

Каменная лига
Сообщения
155
Лучшие ответы
5
Симпатии
36
#9
Извините, а почему все в одном классе? :DГде классы IExampleMeta и EnumBLockType :D? чет ты все в одну кашу бахнул. Я подозреваю, что ты все в один код бахнул
или прст чтоб не создавать больше пунктов в треде решил все скинуть в одну
 

fixable

Каменная лига
Сообщения
155
Лучшие ответы
5
Симпатии
36
#10
и еще как ты живешь с пеньком на два ядра :D и ощущение будто не весь краш-лог
 

fixable

Каменная лига
Сообщения
155
Лучшие ответы
5
Симпатии
36
#11
мдыт переписывай с нуля, это просто не рабочий говнокод,
дам тебе норм пример кода который сам делал для себя
это код листвы, ну, а ты сделай под себя
IDarknessMeta:
package Blocks;

import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;

public interface IDarknessMeta
{
    public String getMetaName(ItemStack stack);

    BlockRenderLayer getRenderLayer();

}
EnumLeafLog:
package Blocks;

import net.minecraft.util.IStringSerializable;

public enum EnumLeafType implements IStringSerializable
{

    Black(0, "black_leaves"), Grey(1, "Grey_oak_leaves");

    private int meta;

    private String unlocalizedName;

    EnumLeafType(int meta, String unlocalizedName)
    {
        this.meta = meta;
        this.unlocalizedName = unlocalizedName;
    }

    public static EnumLeafType getType(int meta)
    {
        return meta == 1 ? Black : Grey;
    }

    public int getMeta()
    {
        return this.meta;
    }

    public String toString()
    {
        return this.unlocalizedName;
    }

    public String getName()
    {
        return this.unlocalizedName;
    }

}
BlockDarknessLeaves:
package Blocks;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockPlanks.EnumType;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import particles.ParticleGreyOakLeaves;
;

public class BlockDarknessLeaves extends BlockLeaves implements IDarknessMeta
{

    public static final PropertyEnum<EnumLeafType> leaf_type = PropertyEnum.create("darkness_leaves", EnumLeafType.class);

    int[] surroundings;
    public BlockDarknessLeaves()
    {
        super();

        this.setHardness(0.2F);
        this.setLightOpacity(1);
        this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
        this.setDefaultState(this.getDefaultState().withProperty(leaf_type, EnumLeafType.Black).withProperty(CHECK_DECAY, Boolean.valueOf(true)).withProperty(DECAYABLE, Boolean.valueOf(true)));
    }

    @Override
    public String getMetaName(ItemStack stack)
    {
        return ((EnumLeafType)this.getStateFromMeta(stack.getItemDamage()).getValue(leaf_type)).getName();
    }

    @Override
    public int damageDropped(IBlockState state)
    {
        return 0;
    }

    @Override
    public boolean isOpaqueCube(IBlockState state)
    {
        return false;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public BlockRenderLayer getRenderLayer()
    {
        return BlockRenderLayer.CUTOUT_MIPPED;
    }

    @Override
    public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
    {
        return this.getStateFromMeta(meta).withProperty(DECAYABLE, false).withProperty(CHECK_DECAY, false);
    }

    @Override
    @SideOnly(Side.CLIENT)
    public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
    {
        return true;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random random)
    {
        super.randomDisplayTick(state, world, pos, random);

        if (!world.isRemote)
        {
            return;
        }

        if (Minecraft.getMinecraft().gameSettings.particleSetting != 2)
        {
            if (((EnumLeafType)state.getValue(leaf_type)) == EnumLeafType.Grey)
            {
                for (int ammount = 0; ammount < 4; ammount++)
                {
                    double d = pos.getX() + (random.nextFloat() - 0.5D) * 10;
                    double d1 = pos.getY() + (random.nextFloat() - 0.5D) * 10;
                    double d2 = pos.getZ() + (random.nextFloat() - 0.5D) * 10;
                    double d3 = (random.nextFloat() - 0.5D) * 0.5D;
                    double d4 = (random.nextFloat() - 0.5D) * 0.5D;
                    double d5 = (random.nextFloat() - 0.5D) * 0.5D;

                    ParticleGreyOakLeaves obj = new ParticleGreyOakLeaves(world, d, d1, d2, d3, d4, d5);
                    FMLClientHandler.instance().getClient().effectRenderer.addEffect(obj);
                }
            }
        }
    }

    @Override
    public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list)
    {
        for (int j = 0; j < EnumLeafType.values().length; ++j)
        {
            EnumLeafType leafType = EnumLeafType.values()[j];

            list.add(new ItemStack(this, 1, leafType.getMeta()));
        }
    }

    @Override
    public IBlockState getStateFromMeta(int meta)
    {
        return this.getDefaultState().withProperty(leaf_type,  EnumLeafType.getType(meta % 2)).withProperty(DECAYABLE, Boolean.valueOf((meta & 4) == 0)).withProperty(CHECK_DECAY, Boolean.valueOf((meta & 8) > 0));
    }

    public int getMetaFromState(IBlockState state)
    {
        int i = 0;
        i = i | ((EnumLeafType)state.getValue(leaf_type)).getMeta();

        if (!((Boolean)state.getValue(DECAYABLE)).booleanValue())
        {
            i |= 4;
        }

        if (((Boolean)state.getValue(CHECK_DECAY)).booleanValue())
        {
            i |= 8;
        }

        return i;
    }

    @Override
    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {leaf_type, DECAYABLE, CHECK_DECAY});
    }

    @Override
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        return ((EnumLeafType)state.getValue(leaf_type)) == EnumLeafType.Black ? Item.getItemFromBlock(BlocksDarkness.drakness_sapling) : Item.getItemFromBlock(BlocksDarkness.darkness_oak_sapling);
    }

    @Override
    public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune)
    {
        ArrayList<ItemStack> list = new ArrayList<ItemStack>();
        IBlockState state = world.getBlockState(pos);

        if (state.getValue(leaf_type) != null)
        {
            list.add(new ItemStack(this, 1, state.getValue(leaf_type).getMeta()));
        }

        return list;
    }

    @Override
    public EnumType getWoodType(int meta)
    {
        return null;
    }
   
    @Override
    public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
    {
        return new ItemStack(Item.getItemFromBlock(this), 1, this.getMetaFromState(state));
    }

    @Override
    public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
    {
        if (!worldIn.isRemote)
        {
            if (((Boolean)state.getValue(CHECK_DECAY)).booleanValue() && ((Boolean)state.getValue(DECAYABLE)).booleanValue())
            {
                int k = pos.getX();
                int l = pos.getY();
                int i1 = pos.getZ();
                int loadedRange = 7;
                int checkRange = 6;
               
                if (this.surroundings == null)
                {
                    this.surroundings = new int[32768]; // 2^15
                }

                if (worldIn.isAreaLoaded(new BlockPos(k - loadedRange, l - loadedRange, i1 - loadedRange), new BlockPos(k + loadedRange, l + loadedRange, i1 + loadedRange)))
                {
                    BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

                    for (int x = -checkRange; x <= checkRange; ++x)
                    {
                        for (int y = -checkRange; y <= checkRange; ++y)
                        {
                            for (int z = -checkRange; z <= checkRange; ++z)
                            {
                                IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos.setPos(k + x, l + y, i1 + z));
                                Block block = iblockstate.getBlock();

                                if (!block.canSustainLeaves(iblockstate, worldIn, blockpos$mutableblockpos.setPos(k + x, l + y, i1 + z)))
                                {
                                    if (block.isLeaves(iblockstate, worldIn, blockpos$mutableblockpos.setPos(k + x, l + y, i1 + z)))
                                    {
                                        // if leaves -2
                                        this.surroundings[(x + 16) * 1024 + (y + 16) * 32 + z + 16] = -2;
                                    }
                                    else
                                    {
                                        // if not sustain -1
                                        this.surroundings[(x + 16) * 1024 + (y + 16) * 32 + z + 16] = -1;
                                    }
                                }
                                else
                                {
                                    // if sustain 0
                                    this.surroundings[(x + 16) * 1024 + (y + 16) * 32 + z + 16] = 0;
                                }
                            }
                        }
                    }

                    for (int i3 = 1; i3 <= checkRange; ++i3)
                    {
                        for (int x = -checkRange; x <= checkRange; ++x)
                        {
                            for (int y = -checkRange; y <= checkRange; ++y)
                            {
                                for (int z = -checkRange; z <= checkRange; ++z)
                                {
                                    if (this.surroundings[(x + 16) * 1024 + (y + 16) * 32 + z + 16] == i3 - 1)
                                    {
                                        if (this.surroundings[(x + 16 - 1) * 1024 + (y + 16) * 32 + z + 16] == -2)
                                        {
                                            this.surroundings[(x + 16 - 1) * 1024 + (y + 16) * 32 + z + 16] = i3;
                                        }

                                        if (this.surroundings[(x + 16 + 1) * 1024 + (y + 16) * 32 + z + 16] == -2)
                                        {
                                            this.surroundings[(x + 16 + 1) * 1024 + (y + 16) * 32 + z + 16] = i3;
                                        }

                                        if (this.surroundings[(x + 16) * 1024 + (y + 16 - 1) * 32 + z + 16] == -2)
                                        {
                                            this.surroundings[(x + 16) * 1024 + (y + 16 - 1) * 32 + z + 16] = i3;
                                        }

                                        if (this.surroundings[(x + 16) * 1024 + (y + 16 + 1) * 32 + z + 16] == -2)
                                        {
                                            this.surroundings[(x + 16) * 1024 + (y + 16 + 1) * 32 + z + 16] = i3;
                                        }

                                        if (this.surroundings[(x + 16) * 1024 + (y + 16) * 32 + (z + 16 - 1)] == -2)
                                        {
                                            this.surroundings[(x + 16) * 1024 + (y + 16) * 32 + (z + 16 - 1)] = i3;
                                        }

                                        if (this.surroundings[(x + 16) * 1024 + (y + 16) * 32 + z + 16 + 1] == -2)
                                        {
                                            this.surroundings[(x + 16) * 1024 + (y + 16) * 32 + z + 16 + 1] = i3;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                int l2 = this.surroundings[16912];

                if (l2 >= 0)
                {
                    worldIn.setBlockState(pos, state.withProperty(CHECK_DECAY, Boolean.valueOf(false)), 4);
                }
                else
                {
                    this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
                    worldIn.setBlockToAir(pos);
                }
            }
        }
    }

}
BLockDarkness (тут регистрация):
package Blocks;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.registries.IForgeRegistry;
import pixels.PixelsMod;

public class BlocksDarkness
{
    public static Block darkness_leaves;
    private static int availableId;

    public static Block[] blockList = new Block[2];
   
    public static void registerBlocks(IForgeRegistry<Block> blockRegistry)
    {
        blockRegistry.registerAll(blockList);
    }

    public static void initialization()
    {
        darkness_leaves = registerMeta("darkness_leaves", new BlockDarknessLeaves());
    }

    private static Block register(String name, Block block) {
   
        block.setUnlocalizedName(name);
        block.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
       
        blockList[availableId] = block.setRegistryName(PixelsMod.locate(name));
       
        ++availableId;
        return block;
    }

    public static Block registerMeta(String name, Block block)
    {
        blockList[availableId] = block.setRegistryName(PixelsMod.locate(name));

        ++availableId;

        return block;
    }
   
}
 

Крокодил

Железная лига
Сообщения
681
Лучшие ответы
13
Симпатии
142
#12
@fixable ему не мета похоже нужна, а просто варианты, для которых и своих имён не предполагается. Зачем тут интерфейсы... Думаю тут как в ваниле , дверь например или блок забора.
 
Последнее редактирование:

MaximPixel

Каменная лига
Сообщения
651
Лучшие ответы
14
Симпатии
13
#13
@fixable, у тебя в блоке мало вариантов, а у меня больше. И тут дело не в коде, а наверное, в самом количестве этих вариантов.
 

fixable

Каменная лига
Сообщения
155
Лучшие ответы
5
Симпатии
36
#14
@MaximPixel нет именно в коде то и дело, у тебя куча ошибок как и в методах, так и синтакс ошибок
 

Крокодил

Железная лига
Сообщения
681
Лучшие ответы
13
Симпатии
142
#15
это просто не рабочий говнокод,
Как ты варазился, этот "нерабочий говнокод" у меня не плохо работает. Единственные отличия в том, что у меня 64 варианта, и возможно (ибо автор поста не выкладывал) другая регистрация.
 

fixable

Каменная лига
Сообщения
155
Лучшие ответы
5
Симпатии
36
#16
@Крокодил причем тут количество? берешь и создаешь скоко надо, это ни на что не влияет.
 

hohserg1

Алмазная лига
Сообщения
3,665
Лучшие ответы
93
Симпатии
436
#18
a + b == a.+(b) :unsure: Смысл тот же, но второе говнокод. Кстати, чистый код лучше понимается, поэтому в нем легче найти ошибку(а чаще всего ее там нет, потому что спроектировал правильно)
 

MaximPixel

Каменная лига
Сообщения
651
Лучшие ответы
14
Симпатии
13
#19
@fixable, где ты там ошибки увидел?
Как я выяснил, проблема заключается в том что у этого блока максимальное количество вариантов 16. Я убрал параметр MATERIAL и стало работать нормально.
 

Крокодил

Железная лига
Сообщения
681
Лучшие ответы
13
Симпатии
142
#20
@hohserg1 Я взял "говнокод" в кавычки ибо не считаю код maximpixel говнокодом. Подразумевал неоптимальный код. К примеру, класс своего предмета в котором не будет ни одного метода и new Item().setUnlocalizedName(имя).setRegistryName(имя) вещи вполне равносильные, но первая в целом не оптимальная.
 
Сверху