Posted February 2, 20178 yr Hey guys, I working on some lanterns that I want to connect to basically all solid side blocks (I hope you guys understand what I'm trying to say here), including stairs (much like torches do). I have looked at how torches connect to solid side blocks, but that would not be possible to do with my block, unless I rewrite most of the code, that I already have in my lantern class. public class LanternBlock extends Block { public static final PropertyBool UP = PropertyBool.create("up"); public static final PropertyBool NORTH = PropertyBool.create("north"); public static final PropertyBool EAST = PropertyBool.create("east"); public static final PropertyBool SOUTH = PropertyBool.create("south"); public static final PropertyBool WEST = PropertyBool.create("west"); protected static final double pixel = 1/16D; private static final AxisAlignedBB LANTERN_BOUNDING_AABB = new AxisAlignedBB(5*pixel, 0.0D, 5*pixel, 11*pixel, 13*pixel, 11*pixel); public LanternBlock(String name) { super(Material.ANVIL); this.setUnlocalizedName(name); this.setRegistryName(name); this.setHardness(1.0F); this.setSoundType(SoundType.ANVIL); this.isToolEffective("pickaxe", getDefaultState()); this.setCreativeTab(CreativeTabs.DECORATIONS); this.setDefaultState(this.blockState.getBaseState().withProperty(UP, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false))); } @Override public int getLightValue(IBlockState state) { return 15; } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public boolean isFullCube(IBlockState state) { return false; } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return LANTERN_BOUNDING_AABB; } @Override public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { return LANTERN_BOUNDING_AABB; } @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { double d0 = (double)pos.getX() + 0.5D; double d1 = (double)pos.getY() + 6.5*pixel; double d2 = (double)pos.getZ() + 0.5D; worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]); } @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { state = state.withProperty(UP, false).withProperty(NORTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.canConnectTo(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.canConnectTo(worldIn, pos.west()))); IBlockState block_above = worldIn.getBlockState(pos.up()); if(!(block_above.getBlock() == null)) { if(block_above.isFullCube() || block_above.getProperties().containsValue(BlockSlab.EnumBlockHalf.BOTTOM) || block_above.getProperties().containsValue(BlockStairs.EnumHalf.BOTTOM)) { state = state.withProperty(UP, true); } } if(((Boolean)state.getValue(NORTH)).booleanValue() || ((Boolean)state.getValue(SOUTH)).booleanValue()) { state = state.withProperty(EAST, false).withProperty(WEST, false); } if(((Boolean)state.getValue(UP)).booleanValue()) { state = state.withProperty(NORTH, false).withProperty(EAST, false).withProperty(SOUTH, false).withProperty(WEST, false); } return state; } public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos) { IBlockState state = worldIn.getBlockState(pos); return state.isFullCube(); } @Override public int getMetaFromState(IBlockState state) { return 0; } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {UP, NORTH, EAST, WEST, SOUTH}); } } (Sorry for not putting code in a spoiler, couldn't find it with the new layout) I have tried something similar to how I did the block_above in the getActualState method, which worked fine if I was just checking one side, but if I added more it didn't work. But what I would like to know is if there's a way to check for stairs' solid side in my canConnectTo method perhaps, so that I didn't have to do some funky business? Also I know that my code most likely could be done much cleaner, but you know, if it ain't broke don't fix it Edited February 6, 20178 yr by Erfurt
February 3, 20178 yr You are checking whether the whole block is solid, you want to just check the side that is facing your lantern. It used to be a method along the lines of isSideSolid(facing, pos) but it might have changed.
February 3, 20178 yr Author 33 minutes ago, Alpvax said: You are checking whether the whole block is solid, you want to just check the side that is facing your lantern. It used to be a method along the lines of isSideSolid(facing, pos) but it might have changed. I wasn't checking the whole block, but only the side that's facing my lantern, however when I tried to do it for more than one side the state wouldn't update, and when I went to F3 to see if the lantern had changed its properties I would get a crash, pointing back to where I was checking the sides for being solid. Maybe there's an easy way to add the check into the canConnectTo method? I was previously doing the check in my getActualState.
February 3, 20178 yr Post your code and the crash report. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
February 3, 20178 yr Author 15 hours ago, Animefan8888 said: Post your code and the crash report. This was the code that I had inside the getActualState method. IBlockState block_north = worldIn.getBlockState(pos.north()); IBlockState block_east = worldIn.getBlockState(pos.east()); IBlockState block_south = worldIn.getBlockState(pos.south()); IBlockState block_west = worldIn.getBlockState(pos.west()); if(!(block_north.getBlock() == null)) { if(block_above.getValue(BlockStairs.FACING) == EnumFacing.SOUTH) { state = state.withProperty(NORTH, true); } } if(!(block_east.getBlock() == null)) { if(block_east.getValue(BlockStairs.FACING) == EnumFacing.WEST) { state = state.withProperty(EAST, true); } } if(!(block_south.getBlock() == null)) { if(block_south.getValue(BlockStairs.FACING) == EnumFacing.NORTH) { state = state.withProperty(SOUTH, true); } } if(!(block_west.getBlock() == null)) { if(block_west.getValue(BlockStairs.FACING) == EnumFacing.EAST) { state = state.withProperty(WEST, true); } } Here's the crash-report ---- Minecraft Crash Report ---- // You should try our sister game, Minceraft! Time: 03-02-17 18:48 Description: Unexpected error java.lang.IllegalArgumentException: Cannot get property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[north, south, west, east]} as it does not exist in BlockStateContainer{block=minecraft:air, properties=[]} at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:196) at erfurt.walls.blocks.LanternBlock.getActualState(LanternBlock.java:114) at net.minecraft.block.state.BlockStateContainer$StateImplementation.getActualState(BlockStateContainer.java:416) at net.minecraft.client.gui.GuiOverlayDebug.getDebugInfoRight(GuiOverlayDebug.java:207) at net.minecraftforge.client.GuiIngameForge$GuiOverlayDebugForge.getRight(GuiIngameForge.java:913) at net.minecraftforge.client.GuiIngameForge$GuiOverlayDebugForge.access$200(GuiIngameForge.java:895) at net.minecraftforge.client.GuiIngameForge.renderHUDText(GuiIngameForge.java:689) at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:171) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1125) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1139) at net.minecraft.client.Minecraft.run(Minecraft.java:406) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 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(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:196) at erfurt.walls.blocks.LanternBlock.getActualState(LanternBlock.java:114) at net.minecraft.block.state.BlockStateContainer$StateImplementation.getActualState(BlockStateContainer.java:416) at net.minecraft.client.gui.GuiOverlayDebug.getDebugInfoRight(GuiOverlayDebug.java:207) at net.minecraftforge.client.GuiIngameForge$GuiOverlayDebugForge.getRight(GuiIngameForge.java:913) at net.minecraftforge.client.GuiIngameForge$GuiOverlayDebugForge.access$200(GuiIngameForge.java:895) at net.minecraftforge.client.GuiIngameForge.renderHUDText(GuiIngameForge.java:689) at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:171) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player438'/221, l='MpServer', x=-32,82, y=72,06, z=231,41]] Chunk stats: MultiplayerChunkCache: 620, 620 Level seed: 0 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: Level spawn location: World: (-14,64,207), Chunk: (at 2,4,15 in -1,12; contains blocks -16,0,192 to -1,255,207), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 340921 game time, 1000 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 111 total; [EntityPlayerSP['Player438'/221, l='MpServer', x=-32,82, y=72,06, z=231,41], EntitySkeleton['Skeleton'/56, l='MpServer', x=-103,44, y=32,00, z=178,28], EntityZombie['Zombie'/57, l='MpServer', x=-104,19, y=32,00, z=179,51], EntityCow['Cow'/58, l='MpServer', x=-96,85, y=72,00, z=209,59], EntitySheep['Sheep'/59, l='MpServer', x=-100,21, y=71,00, z=216,52], EntityChicken['Chicken'/60, l='MpServer', x=-108,85, y=70,00, z=223,41], EntitySheep['Sheep'/61, l='MpServer', x=-80,50, y=74,00, z=188,19], EntitySheep['Sheep'/62, l='MpServer', x=-87,42, y=73,00, z=207,23], EntitySheep['Sheep'/63, l='MpServer', x=-95,73, y=69,00, z=270,46], EntitySheep['Sheep'/64, l='MpServer', x=-81,21, y=72,00, z=281,77], EntitySheep['Sheep'/72, l='MpServer', x=-71,21, y=72,00, z=178,48], EntityBat['Bat'/73, l='MpServer', x=-69,47, y=31,10, z=199,65], EntityZombie['Zombie'/74, l='MpServer', x=-77,41, y=42,00, z=199,76], EntityCow['Cow'/75, l='MpServer', x=-75,97, y=71,00, z=195,84], EntitySheep['Sheep'/76, l='MpServer', x=-70,57, y=62,39, z=216,96], EntitySheep['Sheep'/77, l='MpServer', x=-69,73, y=72,00, z=267,17], EntitySheep['Sheep'/78, l='MpServer', x=-70,80, y=72,00, z=270,21], EntityCreeper['Creeper'/79, l='MpServer', x=-67,50, y=36,00, z=276,50], EntitySheep['Sheep'/80, l='MpServer', x=-74,70, y=72,00, z=280,81], EntitySheep['Sheep'/90, l='MpServer', x=-63,57, y=72,00, z=185,90], EntitySheep['Sheep'/91, l='MpServer', x=-65,18, y=71,00, z=195,23], EntityBat['Bat'/92, l='MpServer', x=-56,71, y=32,45, z=206,80], EntityCreeper['Creeper'/93, l='MpServer', x=-57,47, y=50,00, z=217,84], EntityCreeper['Creeper'/94, l='MpServer', x=-54,50, y=51,00, z=219,50], EntityZombie['Zombie'/95, l='MpServer', x=-58,41, y=50,00, z=220,17], EntitySpider['Spider'/96, l='MpServer', x=-50,00, y=36,00, z=236,70], EntityCreeper['Creeper'/97, l='MpServer', x=-52,50, y=50,00, z=235,50], EntityCreeper['Creeper'/98, l='MpServer', x=-53,50, y=50,00, z=235,50], EntityCreeper['Creeper'/99, l='MpServer', x=-49,99, y=52,00, z=224,58], EntityCreeper['Creeper'/100, l='MpServer', x=-50,63, y=52,00, z=225,21], EntityMinecartEmpty['entity.MinecartRideable.name'/101, l='MpServer', x=-48,37, y=72,00, z=233,67], EntityMountableBlock['entity.wm.MountableBlock.name'/102, l='MpServer', x=-51,50, y=72,44, z=224,50], EntityMountableBlock['entity.wm.MountableBlock.name'/103, l='MpServer', x=-51,50, y=72,44, z=225,50], EntityMountableBlock['entity.wm.MountableBlock.name'/104, l='MpServer', x=-51,50, y=72,44, z=226,50], EntityMountableBlock['entity.wm.MountableBlock.name'/105, l='MpServer', x=-51,50, y=72,44, z=227,50], EntityZombie['Zombie'/106, l='MpServer', x=-49,50, y=30,00, z=258,50], EntityCreeper['Creeper'/107, l='MpServer', x=-51,40, y=32,00, z=269,20], EntityCreeper['Creeper'/108, l='MpServer', x=-50,50, y=32,00, z=263,50], EntitySkeleton['Skeleton'/109, l='MpServer', x=-49,50, y=45,00, z=299,50], EntitySkeleton['Skeleton'/110, l='MpServer', x=-59,50, y=45,00, z=298,50], EntitySkeleton['Skeleton'/111, l='MpServer', x=-58,50, y=45,00, z=295,50], EntityCreeper['Creeper'/112, l='MpServer', x=-58,21, y=44,00, z=301,37], EntityZombie['Zombie'/114, l='MpServer', x=-56,50, y=34,00, z=307,50], EntityZombie['entity.Zombie.name'/120, l='MpServer', x=-43,50, y=23,00, z=158,50], EntityCreeper['Creeper'/121, l='MpServer', x=-40,50, y=23,00, z=157,50], EntitySheep['Sheep'/122, l='MpServer', x=-36,73, y=62,61, z=156,28], EntityWitch['Witch'/123, l='MpServer', x=-36,50, y=50,00, z=154,50], EntityZombie['Zombie'/124, l='MpServer', x=-40,50, y=44,00, z=176,50], EntityWitch['Witch'/125, l='MpServer', x=-41,43, y=38,00, z=222,95], EntitySkeleton['Skeleton'/126, l='MpServer', x=-38,69, y=21,00, z=239,49], EntityBat['Bat'/127, l='MpServer', x=-37,75, y=42,10, z=227,75], EntitySpider['Spider'/128, l='MpServer', x=-40,70, y=40,00, z=227,30], EntityWitch['Witch'/129, l='MpServer', x=-42,50, y=38,00, z=233,84], EntityZombie['Zombie'/130, l='MpServer', x=-35,49, y=54,46, z=229,38], EntityBat['Bat'/131, l='MpServer', x=-35,39, y=58,10, z=234,75], EntityCreeper['Creeper'/132, l='MpServer', x=-36,85, y=51,00, z=227,47], EntityZombie['Zombie'/133, l='MpServer', x=-45,52, y=47,00, z=228,60], EntityZombie['Zombie'/134, l='MpServer', x=-43,76, y=47,00, z=226,71], EntityCreeper['Creeper'/135, l='MpServer', x=-39,50, y=21,00, z=242,50], EntityCreeper['Creeper'/136, l='MpServer', x=-32,48, y=18,00, z=253,82], EntityZombie['Zombie'/137, l='MpServer', x=-47,50, y=32,00, z=267,50], EntitySkeleton['Skeleton'/138, l='MpServer', x=-40,50, y=48,00, z=290,50], EntitySkeleton['Skeleton'/139, l='MpServer', x=-45,53, y=48,00, z=293,23], EntityZombie['Zombie'/140, l='MpServer', x=-34,51, y=43,00, z=308,80], EntityBat['Bat'/147, l='MpServer', x=-17,47, y=46,10, z=172,54], EntitySheep['Sheep'/148, l='MpServer', x=-16,70, y=64,00, z=172,49], EntitySpider['Spider'/149, l='MpServer', x=-19,50, y=37,00, z=202,50], EntityBat['Bat'/150, l='MpServer', x=-22,22, y=42,73, z=199,75], EntityBat['Bat'/151, l='MpServer', x=-31,13, y=37,78, z=223,29], EntityBat['Bat'/152, l='MpServer', x=-25,63, y=40,28, z=210,24], EntityBat['Bat'/153, l='MpServer', x=-30,71, y=20,07, z=261,72], EntitySheep['Sheep'/154, l='MpServer', x=-28,73, y=70,00, z=299,53], EntitySheep['Sheep'/155, l='MpServer', x=-31,24, y=71,00, z=293,60], EntityCreeper['Creeper'/157, l='MpServer', x=-21,50, y=28,00, z=311,50], EntityZombie['Zombie'/163, l='MpServer', x=-6,50, y=27,00, z=152,50], EntityCreeper['Creeper'/164, l='MpServer', x=-6,50, y=16,00, z=167,50], EntityZombie['Zombie'/165, l='MpServer', x=-13,55, y=44,00, z=171,76], EntitySheep['Sheep'/167, l='MpServer', x=-10,67, y=63,00, z=190,23], EntitySpider['Spider'/168, l='MpServer', x=-7,58, y=23,00, z=201,11], EntityVillager['Villager'/169, l='MpServer', x=-13,50, y=71,00, z=207,89], EntityCreeper['Creeper'/170, l='MpServer', x=-1,16, y=42,00, z=219,50], EntityVillager['Villager'/171, l='MpServer', x=-10,50, y=71,00, z=213,50], EntitySheep['Sheep'/172, l='MpServer', x=-0,30, y=72,00, z=229,81], EntitySheep['Sheep'/173, l='MpServer', x=-8,19, y=72,00, z=255,51], EntitySkeleton['Skeleton'/174, l='MpServer', x=-3,50, y=57,00, z=271,50], EntitySheep['Sheep'/175, l='MpServer', x=-2,54, y=70,00, z=264,25], EntitySheep['Sheep'/176, l='MpServer', x=-0,19, y=70,00, z=281,49], EntitySheep['Sheep'/177, l='MpServer', x=-8,73, y=54,00, z=301,48], EntitySheep['Sheep'/178, l='MpServer', x=-8,50, y=67,00, z=293,80], EntityCreeper['Creeper'/180, l='MpServer', x=4,50, y=27,00, z=155,50], EntityCreeper['Creeper'/181, l='MpServer', x=5,22, y=24,00, z=162,59], EntitySkeleton['Skeleton'/182, l='MpServer', x=5,50, y=43,00, z=205,71], EntityBat['Bat'/183, l='MpServer', x=11,46, y=14,68, z=207,40], EntitySheep['Sheep'/184, l='MpServer', x=10,55, y=71,00, z=223,55], EntitySheep['Sheep'/185, l='MpServer', x=8,46, y=72,00, z=223,27], EntitySheep['Sheep'/186, l='MpServer', x=12,52, y=71,00, z=220,18], EntitySheep['Sheep'/187, l='MpServer', x=2,75, y=72,00, z=227,58], EntitySheep['Sheep'/188, l='MpServer', x=7,50, y=72,00, z=229,23], EntitySheep['Sheep'/189, l='MpServer', x=9,67, y=66,00, z=253,23], EntityCow['Cow'/190, l='MpServer', x=-4,49, y=71,28, z=248,34], EntitySheep['Sheep'/191, l='MpServer', x=15,51, y=66,00, z=260,73], EntityEnderman['Enderman'/192, l='MpServer', x=5,50, y=17,00, z=281,50], EntityChicken['Chicken'/193, l='MpServer', x=10,64, y=60,00, z=299,87], EntityBat['Bat'/195, l='MpServer', x=2,44, y=53,10, z=310,17], EntityCreeper['Creeper'/197, l='MpServer', x=24,47, y=53,00, z=211,15], EntitySheep['Sheep'/198, l='MpServer', x=25,55, y=64,00, z=218,38], EntityCreeper['Creeper'/199, l='MpServer', x=18,50, y=14,00, z=247,50], EntityCreeper['Creeper'/200, l='MpServer', x=17,50, y=14,00, z=249,50], EntitySheep['Sheep'/201, l='MpServer', x=25,73, y=64,00, z=274,51], EntitySheep['Sheep'/209, l='MpServer', x=36,91, y=63,00, z=262,51], EntitySheep['Sheep'/210, l='MpServer', x=36,27, y=68,00, z=264,51]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:451) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2779) at net.minecraft.client.Minecraft.run(Minecraft.java:435) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 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(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) -- System Details -- Details: Minecraft Version: 1.10.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_77, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 109343960 bytes (104 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95 FML: MCP 9.32 Powered by Forge 12.18.2.2099 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.2.2099.jar) UCHIJAAAA Forge{12.18.2.2099} [Minecraft Forge] (forgeSrc-1.10.2-12.18.2.2099.jar) UCHIJAAAA wm{1.10.2_1.0.9b} [Walls mod] (bin) Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 378.49' Renderer: 'GeForce GTX 1070/PCIe/SSE2' Launched Version: 1.10.2 LWJGL: 2.9.4 OpenGL: GeForce GTX 1070/PCIe/SSE2 GL version 4.5.0 NVIDIA 378.49, 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: Yes Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: PureBDcraft 64x MC111.zip (incompatible) Current Language: English (US) Profiler Position: N/A (disabled) CPU: 4x Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
February 3, 20178 yr Also, !(a == b)? Why not a != b? Also, getBlock can never return null for a block in the world: every block is non-null even air, it's Blocks.AIR Edited February 3, 20178 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
February 3, 20178 yr Author 6 minutes ago, diesieben07 said: Yeah, if the block is not null it must definitely be a stair. Totally. Stone? Doesn't exist. Blasphemy! As I mentioned in the OP, I'm trying to get the check in the canConnectTo method, not really sure why that other guy wanted the that code and crash report. and that code was mostly from memory, as it was just for some testing stuff
February 3, 20178 yr Author 24 minutes ago, Draco18s said: Also, !(a == b)? Why not a != b? Also, getBlock can never return null for a block in the world: every block is non-null even air, it's Blocks.AIR Because I was derping around when I made that thing. And I actually thought that air would return null, but you learn every day
February 5, 20178 yr Author Hey guys just a quick question. I have decided to rewrite this class, as there was some things that I didn't like. I am planning on using a PropertyDirection, instead of all the PropertyBools I have currently, but I want to know if I can use one for all 6 sides? I know that it's most commonly used to get the horizontal sides, but I would need to get the up and down sides as well.
February 5, 20178 yr Author Just now, diesieben07 said: Yes, you can use PropertyDirection to store an EnumFacing value, which includes all 6 sides. Cool, I will give it a try, and post here if I get problems
February 6, 20178 yr Author Hey guys just a little update here. I have made it work with PropertyDirection, and I ended up using some code from BlockTorch, I have been trying to extend BlockTorch. But for some reason that didn't work. But nonetheless it's working now.
February 6, 20178 yr Author 3 minutes ago, TheSunCat said: Yay. Could we see the code? I am making an iron torch and would like to be able to see a modder's approach and Minecraft's approach. Thanks! Sure, I post it here when I get home from work in a couple of hours
February 6, 20178 yr Author 1 hour ago, TheSunCat said: Ok. Thanks. Here's my new class. But if you are going to make something that is more or less the same as a torch, I would try and extend BlockTorch, I would have done it with this class, but as I mentioned I couldn't get it to work the way I wanted it to work, so that's why I have used some code from the BlockTorch in my class. Spoiler public class LanternBlock extends Block { public static final PropertyDirection FACING = PropertyDirection.create("facing"); protected static final double pixel = 1/16D; private static final AxisAlignedBB LANTERN_BOUNDING_AABB = new AxisAlignedBB(5*pixel, 0.0D, 5*pixel, 11*pixel, 13*pixel, 11*pixel); public LanternBlock(String name) { super(Material.ANVIL); this.setUnlocalizedName(name); this.setRegistryName(name); this.setSoundType(SoundType.ANVIL); this.setCreativeTab(CreativeTabs.DECORATIONS); this.setTickRandomly(true); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.UP)); } @Override public int getLightValue(IBlockState state) { return 15; } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public boolean isFullCube(IBlockState state) { return false; } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return LANTERN_BOUNDING_AABB; } @Override public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { return LANTERN_BOUNDING_AABB; } @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { double d0 = (double)pos.getX() + 0.5D; double d1 = (double)pos.getY() + 6.5*pixel; double d2 = (double)pos.getZ() + 0.5D; worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]); } private boolean canPlaceOn(World worldIn, BlockPos pos) { IBlockState state = worldIn.getBlockState(pos); if (state.isSideSolid(worldIn, pos, EnumFacing.UP)) { return true; } else { return state.getBlock().canPlaceTorchOnTop(state, worldIn, pos); } } public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { for (EnumFacing enumfacing : FACING.getAllowedValues()) { if (this.canPlaceAt(worldIn, pos, enumfacing)) { return true; } } return false; } private boolean canPlaceAt(World worldIn, BlockPos pos, EnumFacing facing) { BlockPos blockpos = pos.offset(facing.getOpposite()); return facing != facing.UP && worldIn.isSideSolid(blockpos, facing, true) || facing.equals(EnumFacing.UP) && this.canPlaceOn(worldIn, blockpos); } public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { if (this.canPlaceAt(worldIn, pos, facing)) { return this.getDefaultState().withProperty(FACING, facing); } else { for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) { if (worldIn.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true)) { return this.getDefaultState().withProperty(FACING, enumfacing); } } return this.getDefaultState(); } } public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { this.checkForDrop(worldIn, pos, state); } public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { this.onNeighborChangeInternal(worldIn, pos, state); } protected boolean onNeighborChangeInternal(World worldIn, BlockPos pos, IBlockState state) { if (!this.checkForDrop(worldIn, pos, state)) { return true; } else { EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); EnumFacing enumfacing1 = enumfacing.getOpposite(); boolean flag = false; if (!worldIn.isSideSolid(pos.offset(enumfacing1), enumfacing, true)) { flag = true; } else if (!this.canPlaceOn(worldIn, pos.offset(enumfacing1))) { flag = true; } if (flag) { this.dropBlockAsItem(worldIn, pos, state, 0); worldIn.setBlockToAir(pos); return true; } else { return false; } } } protected boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state) { if (state.getBlock() == this && this.canPlaceAt(worldIn, pos, (EnumFacing)state.getValue(FACING))) { return true; } else { if (worldIn.getBlockState(pos).getBlock() == this) { this.dropBlockAsItem(worldIn, pos, state, 0); worldIn.setBlockToAir(pos); } return false; } } public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = this.getDefaultState(); switch (meta) { case 1: iblockstate = iblockstate.withProperty(FACING, EnumFacing.EAST); break; case 2: iblockstate = iblockstate.withProperty(FACING, EnumFacing.WEST); break; case 3: iblockstate = iblockstate.withProperty(FACING, EnumFacing.SOUTH); break; case 4: iblockstate = iblockstate.withProperty(FACING, EnumFacing.NORTH); break; case 5: default: iblockstate = iblockstate.withProperty(FACING, EnumFacing.UP); break; case 6: iblockstate = iblockstate.withProperty(FACING, EnumFacing.DOWN); } return iblockstate; } public int getMetaFromState(IBlockState state) { int i = 0; switch ((EnumFacing)state.getValue(FACING)) { case EAST: i = i | 1; break; case WEST: i = i | 2; break; case SOUTH: i = i | 3; break; case NORTH: i = i | 4; break; case UP: default: i = i | 5; break; case DOWN: i = i | 6; } return i; } public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); } public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {FACING}); } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.