Posted March 28, 20187 yr Hello all, So I have this directional block in my mod, that accepts 3 types of capabilities (fluids, energy and items), however, on the front of the 'machine' I want the capabilities to return null, so it does not connect to any power handlers / fluid handlers / item handlers. I have most of it working, other than finding the side for it to return null on. I have tried this: IBlockState state = this.world.getBlockState(this.getPos()); EnumFacing front = EnumFacing.getFront(state.getBlock().getMetaFromState(state)); if(facing != front) { return this.storage; } return null; however, only 1 direction (north) actually returns null on the front. How can I find the front of a directional block? Thanks. Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
March 29, 20187 yr .getMetaFromState(state) No. Bad modder. EnumFacing facing = state.getValue(BlockDirectional.FACING) Edited March 29, 20187 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.
March 29, 20187 yr Author I changed my code: @Override public IEnergyStorage getEnergyStorage(EnumFacing facing) { IBlockState state = this.world.getBlockState(this.getPos()); EnumFacing face = state.getValue(BlockDirectional.FACING); if(facing != face) { return this.storage; } return null; } @Override public IFluidHandler getFluidHandler(EnumFacing facing) { IBlockState state = this.world.getBlockState(this.getPos()); EnumFacing face = state.getValue(BlockDirectional.FACING); if(facing != face) { return this.fluidStorage; } return null; } @Override public IItemHandler getItemHandler(EnumFacing facing) { IBlockState state = this.world.getBlockState(this.getPos()); EnumFacing face = state.getValue(BlockDirectional.FACING); if(facing != face) { return this.slots; } return null; } However now it crashes: java.lang.IllegalArgumentException: Cannot get property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[down, up, north, south, west, east]} as it does not exist in BlockStateContainer{block=ce:void_infuser, properties=[facing]} at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:204) at com.unassigned.customenchants.blocks.tile.TileEntityVoidInfuser.getEnergyStorage(TileEntityVoidInfuser.java:167) at com.unassigned.customenchants.blocks.tile.base.TileEntityBase.getCapability(TileEntityBase.java:144) at com.unassigned.customenchants.blocks.tile.base.TileEntityBase.hasCapability(TileEntityBase.java:133) at cofh.thermaldynamics.duct.energy.DuctUnitEnergy.cacheTile(DuctUnitEnergy.java:115) at cofh.thermaldynamics.duct.energy.DuctUnitEnergy.cacheTile(DuctUnitEnergy.java:19) at cofh.thermaldynamics.duct.tiles.DuctUnit.loadSignificantCache(DuctUnit.java:157) at cofh.thermaldynamics.duct.energy.DuctUnitEnergy.handleTileSideUpdate(DuctUnitEnergy.java:88) at cofh.thermaldynamics.duct.tiles.DuctUnit.handleTileSideUpdate(DuctUnit.java:115) at cofh.thermaldynamics.duct.tiles.DuctUnit.updateAllSides(DuctUnit.java:231) at cofh.thermaldynamics.duct.tiles.TileGrid.onNeighborBlockChange(TileGrid.java:195) at cofh.thermaldynamics.duct.tiles.DuctUnit.onNeighborBlockChange(DuctUnit.java:283) at cofh.thermaldynamics.multiblock.MultiBlockFormer.checkMultiBlock(MultiBlockFormer.java:33) at cofh.thermaldynamics.multiblock.MultiBlockFormer.formGrid(MultiBlockFormer.java:23) at cofh.thermaldynamics.duct.tiles.DuctUnit.formGrid(DuctUnit.java:252) at cofh.thermaldynamics.duct.tiles.DuctUnit.singleTick(DuctUnit.java:349) at cofh.thermaldynamics.util.WorldGridList.tickEnd(WorldGridList.java:84) at cofh.thermaldynamics.util.TickHandler.tick(TickHandler.java:93) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_63_TickHandler_tick_WorldTickEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) at net.minecraftforge.fml.common.FMLCommonHandler.onPostWorldTick(FMLCommonHandler.java:273) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:849) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:741) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:590) at java.lang.Thread.run(Unknown Source) here is my block class: Spoiler package com.unassigned.customenchants.blocks; import com.unassigned.customenchants.CustomEnchants; import com.unassigned.customenchants.blocks.base.BlockTEBase; import com.unassigned.customenchants.blocks.tile.TileEntityVoidInfuser; import com.unassigned.customenchants.blocks.tile.inventory.gui.GuiHandler; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockVoidInfuser extends BlockTEBase { public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public BlockVoidInfuser(String name, Material materialIn) { super(name, materialIn); setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); } @Override public boolean hasTileEntity(IBlockState state) { return true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEntityVoidInfuser(); } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ if(!world.isRemote){ TileEntityVoidInfuser tile = (TileEntityVoidInfuser)world.getTileEntity(pos); if(tile != null){ player.openGui(CustomEnchants.instance, GuiHandler.GuiTypes.VOID_INFUSER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; } return true; } //V directional code V @Override public IBlockState getStateFromMeta(int meta) { EnumFacing facing = EnumFacing.getHorizontal(meta); return this.getDefaultState().withProperty(FACING, facing); } @Override public int getMetaFromState(IBlockState state) { EnumFacing facing = (EnumFacing)state.getValue(FACING); int face = facing.getHorizontalIndex(); return face; } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {FACING}); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { EnumFacing enumfacing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw); return this.getDefaultState().withProperty(FACING, enumfacing); } } Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
March 29, 20187 yr Ah, you're using the horizontal facing. s/BlockDirectional.FACING/FACING Also: public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); You can just use BlockHorizontal.FACING, rather than creating a new property. Edited March 29, 20187 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.
March 29, 20187 yr Author Okay I changed to use the property from BlockHorizontal, but I didn't understand what you meant by: 2 hours ago, Draco18s said: Ah, you're using the horizontal facing. As I still don't see the problem on why its crashing. Okay, I picked up on what you meant, I changed your code to this: EnumFacing face = state.getValue(BlockHorizontal.FACING); However, the back of the machine is being ignored, not the front Edited March 29, 20187 yr by Lambda Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
March 29, 20187 yr Author Maybe I should do a bit of looking around before asking for more help. EnumFacing.getOpposite() seems to work great for this. Thanks for your help! Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
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.