Jump to content

archieab

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by archieab

  1. Honestly, I don't know. I tweaked some stuff and it booted fine. I'll push it to my GitHub master later, so you'll be able to see there.
  2. I've seemed to have fixed it! Thanks for the help!
  3. As far as I'm aware, yes. Here is latest the crash report.
  4. How would you suggest I change it? Also, the game still crashes.
  5. Just fixed and pushed the 1st and 3rd issues to GitHub master branch. Why is this a bad idea?
  6. Now registered. Why? Changed it to only be 9.
  7. I'm not sure which specific code you are looking for, but here is my Git page for the mod. https://github.com/archiebaldry/Andustry
  8. Hello there! I have an issue with my GUI/Container. When I shift click out an item, the game crashes. Here is my crash report ---- Minecraft Crash Report ---- // Would you like a cupcake? Time: 1/31/18 9:08 AM Description: Updating screen events java.lang.IndexOutOfBoundsException: Index: 45, Size: 45 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at net.minecraft.inventory.Container.mergeItemStack(Container.java:632) at archieab.andustry.container.ContainerDrill.transferStackInSlot(ContainerDrill.java:62) at net.minecraft.inventory.Container.slotClick(Container.java:261) at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:600) at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:687) at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:429) at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:615) at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:580) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1792) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1119) at net.minecraft.client.Minecraft.run(Minecraft.java:407) 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:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at net.minecraft.inventory.Container.mergeItemStack(Container.java:632) at archieab.andustry.container.ContainerDrill.transferStackInSlot(ContainerDrill.java:62) at net.minecraft.inventory.Container.slotClick(Container.java:261) at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:600) at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:687) at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:429) at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:615) at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:580) -- Affected screen -- Details: Screen name: archieab.andustry.client.gui.GuiDrill -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player148'/3, l='MpServer', x=-190.89, y=56.00, z=47.29]] Chunk stats: MultiplayerChunkCache: 554, 554 Level seed: 0 Level generator: ID 01 - flat, ver 0. Features enabled: false Level generator options: Level spawn location: World: (-188,4,50), Chunk: (at 4,0,2 in -12,3; contains blocks -192,0,48 to -177,255,63), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 33143 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: 4 total; [EntityItemFrame['entity.ItemFrame.name'/0, l='MpServer', x=-181.03, y=57.50, z=47.50], EntityItemFrame['entity.ItemFrame.name'/1, l='MpServer', x=-181.03, y=57.50, z=46.50], EntityPlayerSP['Player148'/3, l='MpServer', x=-190.89, y=56.00, z=47.29], EntityItemFrame['entity.ItemFrame.name'/2, l='MpServer', x=-181.03, y=57.50, z=48.50]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:456) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2774) at net.minecraft.client.Minecraft.run(Minecraft.java:428) 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:26) -- System Details -- Details: Minecraft Version: 1.11.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_161, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 711053296 bytes (678 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.38 Powered by Forge 13.20.1.2588 6 mods loaded, 6 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA minecraft{1.11.2} [Minecraft] (minecraft.jar) UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.11.2-13.20.1.2588.jar) UCHIJAAAA forge{13.20.1.2588} [Minecraft Forge] (forgeSrc-1.11.2-13.20.1.2588.jar) UCHIJAAAA and{1.0} [Andustry] (bin) UCHIJAAAA waila{1.7.1} [waila] (Waila-1.7.1_1.11.2.jar) Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 390.65' Renderer: 'GeForce GTX 1060 3GB/PCIe/SSE2' Launched Version: 1.11.2 LWJGL: 2.9.4 OpenGL: GeForce GTX 1060 3GB/PCIe/SSE2 GL version 4.6.0 NVIDIA 390.65, 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: Current Language: English (US) Profiler Position: N/A (disabled) CPU: 4x Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz Many thanks, archieab
  9. Are you talking about my ModBlocks.java? If so, here's the code: package archieab.andustry.init; import archieab.andustry.Andustry; import archieab.andustry.Reference; import archieab.andustry.blocks.BlockCopperOre; import archieab.andustry.blocks.BlockDrill; import archieab.andustry.blocks.BlockMachineFrameAdvanced; import archieab.andustry.blocks.BlockMachineFrameBasic; import archieab.andustry.blocks.BlockTinOre; import archieab.andustry.blocks.BlockCoalCatalystBlock; import archieab.andustry.blocks.item.ItemBlockDrill; import archieab.andustry.handlers.EnumHandler; import archieab.andustry.util.Utils; import net.minecraft.block.Block; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.registry.GameRegistry; public class ModBlocks { public static Block copper_ore; public static Block tin_ore; public static Block machineframebasic; public static Block machineframeadvanced; public static Block drill; public static Block coalcatalystblock; public static void init() { copper_ore = new BlockCopperOre("copper_ore", "copper_ore"); tin_ore = new BlockTinOre("tin_ore", "tin_ore"); machineframebasic = new BlockMachineFrameBasic("machineframebasic", "machineframebasic"); machineframeadvanced = new BlockMachineFrameAdvanced("machineframeadvanced", "machineframeadvanced"); drill = new BlockDrill("drill"); coalcatalystblock = new BlockCoalCatalystBlock("coal_catalyst_block", "coal_catalyst_block"); } public static void register() { registerBlock(copper_ore); registerBlock(tin_ore); registerBlock(machineframebasic); registerBlock(machineframeadvanced); registerBlock(drill, new ItemBlockDrill(drill)); registerBlock(coalcatalystblock); } public static void registerRenders() { registerRender(copper_ore); registerRender(tin_ore); registerRender(machineframebasic); registerRender(machineframeadvanced); for(int i = 0; i < EnumHandler.MacTypes.values().length; i++) { registerRender(drill, i, "block_drill_" + EnumHandler.MacTypes.values()[i].getName()); } registerRender(coalcatalystblock); } public static void registerBlock(Block block) { block.setCreativeTab(Andustry.Blocks); GameRegistry.register(block); GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName())); Utils.getLogger().info("Registered Block: " + block.getUnlocalizedName().substring(5)); } public static void registerBlock(Block block, ItemBlock itemBlock) { block.setCreativeTab(Andustry.Blocks); GameRegistry.register(block); GameRegistry.register(itemBlock.setRegistryName(block.getRegistryName())); Utils.getLogger().info("Registered Block: " + block.getUnlocalizedName().substring(5)); } public static void registerRender(Block block) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(new ResourceLocation(Reference.MODID, block.getUnlocalizedName().substring(5)), "inventory")); Utils.getLogger().info("Registered render for " + block.getUnlocalizedName().substring(5)); } public static void registerRender(Block block, int meta, String fileName) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta, new ModelResourceLocation(new ResourceLocation(Reference.MODID, fileName), "inventory")); Utils.getLogger().info("Register render for " + block.getUnlocalizedName().substring(5)); } }
  10. It's not to do with the lang. I haven't added the block's into the lang purely so you can see the raw name. I'm almost certain the issue is to do with it's SpecialName or UnlocalizedName.
  11. Hello! My block Drill's name is not displaying correctly. The block has the three properties, PropertyEnum for types, PropertyDirection for model rotation and PropertyBool for redstone activation. For some reason, both the basic drill and advanced drill, in the inventory show the same block.drill.basic.name. Yet, the placed blocks display (using Waila) the block.drill.basic.name and block.drill.advanced.name. I'm presuming it's an issue with it's unlocalized name in my block's BlockDrill.java? Basic Drill Image https://ibb.co/jpWM16 Advanced Drill Image https://ibb.co/d1XiER BlockDrill.java package archieab.andustry.blocks; import java.util.List; import archieab.andustry.Reference; import archieab.andustry.blocks.item.IMetaBlockName; import archieab.andustry.handlers.EnumHandler.MacTypes; import net.minecraft.block.Block; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class BlockDrill extends Block implements IMetaBlockName { public static final PropertyEnum TYPE = PropertyEnum.create("type", MacTypes.class); public static final PropertyDirection FACING = PropertyDirection.create("facing"); public static final PropertyBool ACTIVATED = PropertyBool.create("activated"); public BlockDrill(String unlocalizedName) { super(Material.IRON); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(new ResourceLocation(Reference.MODID, unlocalizedName)); this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, MacTypes.BASIC).withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVATED, Boolean.valueOf(false))); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {TYPE,FACING,ACTIVATED}); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return this.getDefaultState().withProperty(FACING, EnumFacing.getDirectionFromEntityLiving(pos, placer)).withProperty(ACTIVATED, Boolean.valueOf(false)).withProperty(TYPE, getStateFromMeta(meta * EnumFacing.values().length).getValue(TYPE)); } @Override public int getMetaFromState(IBlockState state) { MacTypes type = (MacTypes) state.getValue(TYPE); EnumFacing facing = (EnumFacing) state.getValue(FACING); int meta = type.getID() * EnumFacing.values().length + facing.ordinal(); return meta; } @Override public IBlockState getStateFromMeta(int meta) { MacTypes type = MacTypes.values()[(int)(meta / EnumFacing.values().length) % MacTypes.values().length]; EnumFacing facing = EnumFacing.values()[meta % EnumFacing.values().length]; return this.getDefaultState().withProperty(TYPE, type).withProperty(FACING, facing); } @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(Item.getItemFromBlock(this), 1, (int) (getMetaFromState(world.getBlockState(pos)) / EnumFacing.values().length)); } @Override public int damageDropped(IBlockState state) { return (int) (getMetaFromState(state) / EnumFacing.values().length); } @Override public String getSpecialName(ItemStack stack) { return MacTypes.values()[stack.getItemDamage() / EnumFacing.values().length].getName(); } @Override public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) { for (int i = 0; i < MacTypes.values().length; i++) { list.add(new ItemStack(itemIn, 1, i)); } } } Any help would be greatly appreciated!
  12. Okay, I will attempt to encode these two methods into my metadata.
  13. No, that was an issue of the PropertyDirection not working altogether. This is purely just the PropertyDirection not saving.
  14. Hello there! After recently adding a new block with PropertyEnum, Direction and Bool, I've encountered an issue. Everything works perfectly loading the game placing the block - everything - but, when I leave the game and come back, the PropertyDirection reverts back to facing=north. Any help would be appreciated! My block's java file package archieab.andustry.blocks; import java.util.List; import archieab.andustry.Reference; import archieab.andustry.blocks.item.IMetaBlockName; import archieab.andustry.handlers.EnumHandler.MacTypes; import net.minecraft.block.Block; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class BlockDrill extends Block implements IMetaBlockName { public static final PropertyEnum TYPE = PropertyEnum.create("type", MacTypes.class); public static final PropertyDirection FACING = PropertyDirection.create("facing"); public static final PropertyBool ACTIVATED = PropertyBool.create("activated"); public BlockDrill(String unlocalizedName) { super(Material.IRON); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(new ResourceLocation(Reference.MODID, unlocalizedName)); this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, MacTypes.BASIC).withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVATED, Boolean.valueOf(false))); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {TYPE,FACING,ACTIVATED}); } @Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { if(worldIn.isBlockPowered(pos)) { worldIn.setBlockState(pos, state.withProperty(ACTIVATED, Boolean.valueOf(true)), 2); } else { worldIn.setBlockState(pos, state.withProperty(ACTIVATED, Boolean.valueOf(false)), 2); } } @Override public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return super.onBlockPlaced(worldIn, pos, BlockPistonBase.getFacingFromEntity(pos, placer), hitX, hitY, hitZ, meta, placer); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { worldIn.setBlockState(pos, state.withProperty(FACING, BlockPistonBase.getFacingFromEntity(pos, placer)), 2); } @Override public int getMetaFromState(IBlockState state) { MacTypes type = (MacTypes) state.getValue(TYPE); return type.getID(); } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(TYPE, MacTypes.values()[meta]); } @Override public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list) { for(int i = 0; i < MacTypes.values().length; i++) { list.add(new ItemStack(itemIn, 1, i)); } } @Override public String getSpecialName(ItemStack stack) { return MacTypes.values()[stack.getItemDamage()].getName(); } @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos))); } @Override public int damageDropped(IBlockState state) { return getMetaFromState(state); } }
  15. Oh shit, sorry man, I was using 1.10.2. Thanks for the tip, will definitely keep in mind when I next run into an issue. I just like to comment on the fact that your support was very helpful and easy to understand.
  16. In the EnumFacing.class, there is no mention of getDirectionFromEntityLiving. package net.minecraft.util; import com.google.common.base.Predicate; import com.google.common.collect.Iterators; import com.google.common.collect.Maps; import java.util.Iterator; import java.util.Map; import java.util.Random; import javax.annotation.Nullable; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3i; public enum EnumFacing implements IStringSerializable { DOWN(0, 1, -1, "down", EnumFacing.AxisDirection.NEGATIVE, EnumFacing.Axis.Y, new Vec3i(0, -1, 0)), UP(1, 0, -1, "up", EnumFacing.AxisDirection.POSITIVE, EnumFacing.Axis.Y, new Vec3i(0, 1, 0)), NORTH(2, 3, 2, "north", EnumFacing.AxisDirection.NEGATIVE, EnumFacing.Axis.Z, new Vec3i(0, 0, -1)), SOUTH(3, 2, 0, "south", EnumFacing.AxisDirection.POSITIVE, EnumFacing.Axis.Z, new Vec3i(0, 0, 1)), WEST(4, 5, 1, "west", EnumFacing.AxisDirection.NEGATIVE, EnumFacing.Axis.X, new Vec3i(-1, 0, 0)), EAST(5, 4, 3, "east", EnumFacing.AxisDirection.POSITIVE, EnumFacing.Axis.X, new Vec3i(1, 0, 0)); /** Ordering index for D-U-N-S-W-E */ private final int index; /** Index of the opposite Facing in the VALUES array */ private final int opposite; /** Ordering index for the HORIZONTALS field (S-W-N-E) */ private final int horizontalIndex; private final String name; private final EnumFacing.Axis axis; private final EnumFacing.AxisDirection axisDirection; /** Normalized Vector that points in the direction of this Facing */ private final Vec3i directionVec; /** All facings in D-U-N-S-W-E order */ public static final EnumFacing[] VALUES = new EnumFacing[6]; /** All Facings with horizontal axis in order S-W-N-E */ public static final EnumFacing[] HORIZONTALS = new EnumFacing[4]; private static final Map<String, EnumFacing> NAME_LOOKUP = Maps.<String, EnumFacing>newHashMap(); private EnumFacing(int indexIn, int oppositeIn, int horizontalIndexIn, String nameIn, EnumFacing.AxisDirection axisDirectionIn, EnumFacing.Axis axisIn, Vec3i directionVecIn) { this.index = indexIn; this.horizontalIndex = horizontalIndexIn; this.opposite = oppositeIn; this.name = nameIn; this.axis = axisIn; this.axisDirection = axisDirectionIn; this.directionVec = directionVecIn; } /** * Get the Index of this Facing (0-5). The order is D-U-N-S-W-E */ public int getIndex() { return this.index; } /** * Get the index of this horizontal facing (0-3). The order is S-W-N-E */ public int getHorizontalIndex() { return this.horizontalIndex; } /** * Get the AxisDirection of this Facing. */ public EnumFacing.AxisDirection getAxisDirection() { return this.axisDirection; } /** * Get the opposite Facing (e.g. DOWN => UP) */ public EnumFacing getOpposite() { return getFront(this.opposite); } /** * Rotate this Facing around the given axis clockwise. If this facing cannot be rotated around the given axis, * returns this facing without rotating. */ public EnumFacing rotateAround(EnumFacing.Axis axis) { switch (axis) { case X: if (this != WEST && this != EAST) { return this.rotateX(); } return this; case Y: if (this != UP && this != DOWN) { return this.rotateY(); } return this; case Z: if (this != NORTH && this != SOUTH) { return this.rotateZ(); } return this; default: throw new IllegalStateException("Unable to get CW facing for axis " + axis); } } /** * Rotate this Facing around the Y axis clockwise (NORTH => EAST => SOUTH => WEST => NORTH) */ public EnumFacing rotateY() { switch (this) { case NORTH: return EAST; case EAST: return SOUTH; case SOUTH: return WEST; case WEST: return NORTH; default: throw new IllegalStateException("Unable to get Y-rotated facing of " + this); } } /** * Rotate this Facing around the X axis (NORTH => DOWN => SOUTH => UP => NORTH) */ private EnumFacing rotateX() { switch (this) { case NORTH: return DOWN; case EAST: case WEST: default: throw new IllegalStateException("Unable to get X-rotated facing of " + this); case SOUTH: return UP; case UP: return NORTH; case DOWN: return SOUTH; } } /** * Rotate this Facing around the Z axis (EAST => DOWN => WEST => UP => EAST) */ private EnumFacing rotateZ() { switch (this) { case EAST: return DOWN; case SOUTH: default: throw new IllegalStateException("Unable to get Z-rotated facing of " + this); case WEST: return UP; case UP: return EAST; case DOWN: return WEST; } } /** * Rotate this Facing around the Y axis counter-clockwise (NORTH => WEST => SOUTH => EAST => NORTH) */ public EnumFacing rotateYCCW() { switch (this) { case NORTH: return WEST; case EAST: return NORTH; case SOUTH: return EAST; case WEST: return SOUTH; default: throw new IllegalStateException("Unable to get CCW facing of " + this); } } /** * Returns a offset that addresses the block in front of this facing. */ public int getFrontOffsetX() { return this.axis == EnumFacing.Axis.X ? this.axisDirection.getOffset() : 0; } public int getFrontOffsetY() { return this.axis == EnumFacing.Axis.Y ? this.axisDirection.getOffset() : 0; } /** * Returns a offset that addresses the block in front of this facing. */ public int getFrontOffsetZ() { return this.axis == EnumFacing.Axis.Z ? this.axisDirection.getOffset() : 0; } /** * Same as getName, but does not override the method from Enum. */ public String getName2() { return this.name; } public EnumFacing.Axis getAxis() { return this.axis; } /** * Get the facing specified by the given name */ @Nullable public static EnumFacing byName(String name) { return name == null ? null : (EnumFacing)NAME_LOOKUP.get(name.toLowerCase()); } /** * Get a Facing by it's index (0-5). The order is D-U-N-S-W-E. Named getFront for legacy reasons. */ public static EnumFacing getFront(int index) { return VALUES[MathHelper.abs_int(index % VALUES.length)]; } /** * Get a Facing by it's horizontal index (0-3). The order is S-W-N-E. */ public static EnumFacing getHorizontal(int horizontalIndexIn) { return HORIZONTALS[MathHelper.abs_int(horizontalIndexIn % HORIZONTALS.length)]; } /** * Get the Facing corresponding to the given angle (0-360). An angle of 0 is SOUTH, an angle of 90 would be WEST. */ public static EnumFacing fromAngle(double angle) { return getHorizontal(MathHelper.floor_double(angle / 90.0D + 0.5D) & 3); } public float getHorizontalAngle() { return (float)((this.horizontalIndex & 3) * 90); } /** * Choose a random Facing using the given Random */ public static EnumFacing random(Random rand) { return values()[rand.nextInt(values().length)]; } public static EnumFacing getFacingFromVector(float x, float y, float z) { EnumFacing enumfacing = NORTH; float f = Float.MIN_VALUE; for (EnumFacing enumfacing1 : values()) { float f1 = x * (float)enumfacing1.directionVec.getX() + y * (float)enumfacing1.directionVec.getY() + z * (float)enumfacing1.directionVec.getZ(); if (f1 > f) { f = f1; enumfacing = enumfacing1; } } return enumfacing; } public String toString() { return this.name; } public String getName() { return this.name; } public static EnumFacing getFacingFromAxis(EnumFacing.AxisDirection axisDirectionIn, EnumFacing.Axis axisIn) { for (EnumFacing enumfacing : values()) { if (enumfacing.getAxisDirection() == axisDirectionIn && enumfacing.getAxis() == axisIn) { return enumfacing; } } throw new IllegalArgumentException("No such direction: " + axisDirectionIn + " " + axisIn); } /** * Get a normalized Vector that points in the direction of this Facing. */ public Vec3i getDirectionVec() { return this.directionVec; } static { for (EnumFacing enumfacing : values()) { VALUES[enumfacing.index] = enumfacing; if (enumfacing.getAxis().isHorizontal()) { HORIZONTALS[enumfacing.horizontalIndex] = enumfacing; } NAME_LOOKUP.put(enumfacing.getName2().toLowerCase(), enumfacing); } } public static enum Axis implements Predicate<EnumFacing>, IStringSerializable { X("x", EnumFacing.Plane.HORIZONTAL), Y("y", EnumFacing.Plane.VERTICAL), Z("z", EnumFacing.Plane.HORIZONTAL); private static final Map<String, EnumFacing.Axis> NAME_LOOKUP = Maps.<String, EnumFacing.Axis>newHashMap(); private final String name; private final EnumFacing.Plane plane; private Axis(String name, EnumFacing.Plane plane) { this.name = name; this.plane = plane; } /** * Get the axis specified by the given name */ @Nullable public static EnumFacing.Axis byName(String name) { return name == null ? null : (EnumFacing.Axis)NAME_LOOKUP.get(name.toLowerCase()); } /** * Like getName but doesn't override the method from Enum. */ public String getName2() { return this.name; } /** * If this Axis is on the vertical plane (Only true for Y) */ public boolean isVertical() { return this.plane == EnumFacing.Plane.VERTICAL; } /** * If this Axis is on the horizontal plane (true for X and Z) */ public boolean isHorizontal() { return this.plane == EnumFacing.Plane.HORIZONTAL; } public String toString() { return this.name; } public boolean apply(@Nullable EnumFacing p_apply_1_) { return p_apply_1_ != null && p_apply_1_.getAxis() == this; } /** * Get this Axis' Plane (VERTICAL for Y, HORIZONTAL for X and Z) */ public EnumFacing.Plane getPlane() { return this.plane; } public String getName() { return this.name; } static { for (EnumFacing.Axis enumfacing$axis : values()) { NAME_LOOKUP.put(enumfacing$axis.getName2().toLowerCase(), enumfacing$axis); } } } public static enum AxisDirection { POSITIVE(1, "Towards positive"), NEGATIVE(-1, "Towards negative"); private final int offset; private final String description; private AxisDirection(int offset, String description) { this.offset = offset; this.description = description; } /** * Get the offset for this AxisDirection. 1 for POSITIVE, -1 for NEGATIVE */ public int getOffset() { return this.offset; } public String toString() { return this.description; } } public static enum Plane implements Predicate<EnumFacing>, Iterable<EnumFacing> { HORIZONTAL, VERTICAL; /** * All EnumFacing values for this Plane */ public EnumFacing[] facings() { switch (this) { case HORIZONTAL: return new EnumFacing[] {EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST}; case VERTICAL: return new EnumFacing[] {EnumFacing.UP, EnumFacing.DOWN}; default: throw new Error("Someone\'s been tampering with the universe!"); } } /** * Choose a random Facing from this Plane using the given Random */ public EnumFacing random(Random rand) { EnumFacing[] aenumfacing = this.facings(); return aenumfacing[rand.nextInt(aenumfacing.length)]; } public boolean apply(@Nullable EnumFacing p_apply_1_) { return p_apply_1_ != null && p_apply_1_.getAxis().getPlane() == this; } public Iterator<EnumFacing> iterator() { return Iterators.<EnumFacing>forArray(this.facings()); } } }
  17. I'm still really struggling to understand what you are saying. I know this site says that they will only help members with a above amateur knowledge of Java, but I really need to finish this so I can keep learning and move on. Could you explain exactly what I have to do?
  18. Thanks for the response, and yes I am familiar with casting.
  19. For some reason, my EnumFacing.getDirectionFromEntityLiving is throwing the error, "The method getDirectionFromEntityLiving(BlockPos, EntityLivingBase) is undefined for the type EnumFacing". Here is my block's .java file and my EnumHandler: package archieab.andustry.blocks; import java.util.List; import archieab.andustry.Reference; import archieab.andustry.blocks.item.IMetaBlockName; import archieab.andustry.handlers.EnumHandler.MacTypes; import net.minecraft.block.Block; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class BlockDrill extends Block implements IMetaBlockName { public static final PropertyEnum TYPE = PropertyEnum.create("type", MacTypes.class); public static final PropertyDirection FACING = PropertyDirection.create("facing"); public BlockDrill(String unlocalizedName) { super(Material.IRON); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(new ResourceLocation(Reference.MODID, unlocalizedName)); this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, MacTypes.BASIC).withProperty(FACING, EnumFacing.NORTH)); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {TYPE,FACING}); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return this.getDefaultState().withProperty(FACING, EnumFacing.getDirectionFromEntityLiving(pos, placer)) .withProperty(TYPE, getStateFromMeta(meta * EnumFacing.values().length).getValue(TYPE)); } @Override public int getMetaFromState(IBlockState state) { MacTypes type = (MacTypes) state.getValue(TYPE); EnumFacing facing = (EnumFacing) state.getValue(FACING); int meta = type.getID() * EnumFacing.values().length + facing.ordinal(); return meta; } @Override public IBlockState getStateFromMeta(int meta) { MacTypes type = MacTypes.values()[(int)(meta / EnumFacing.values().length) % MacTypes.values().length]; EnumFacing facing = EnumFacing.values()[meta % EnumFacing.values().length]; return this.getDefaultState().withProperty(TYPE, type).withProperty(FACING, facing); } @Override public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list) { for(int i = 0; i < MacTypes.values().length; i++) { list.add(new ItemStack(itemIn, 1, i)); } } @Override public String getSpecialName(ItemStack stack) { return MacTypes.values()[stack.getItemDamage()].getName(); } @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos))); } @Override public int damageDropped(IBlockState state) { return getMetaFromState(state); } } package archieab.andustry.handlers; import net.minecraft.util.IStringSerializable; public class EnumHandler { public static enum MacTypes implements IStringSerializable { BASIC("basic", 0), ADVANCED("advanced", 1); private int ID; private String name; private MacTypes(String name, int ID) { this.ID = ID; this.name = name; } @Override public String getName() { return this.name; } public int getID() { return ID; } @Override public String toString() { return getName(); } } } Additionally, my block will always place with the facing tag "=up" for some odd reason. Any help would be appreciated!
  20. I've now updated my block's .java file. package archieab.andustry.blocks; import java.util.List; import archieab.andustry.Reference; import archieab.andustry.blocks.item.IMetaBlockName; import archieab.andustry.handlers.EnumHandler.MacTypes; import net.minecraft.block.Block; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class BlockDrill extends Block implements IMetaBlockName { public static final PropertyEnum TYPE = PropertyEnum.create("type", MacTypes.class); public static final PropertyDirection FACING = PropertyDirection.create("facing"); public BlockDrill(String unlocalizedName) { super(Material.IRON); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(new ResourceLocation(Reference.MODID, unlocalizedName)); this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, MacTypes.BASIC).withProperty(FACING, EnumFacing.NORTH)); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {TYPE,FACING}); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return this.getDefaultState().withProperty(FACING, EnumFacing.getDirectionFromEntityLiving(pos, placer)) .withProperty(TYPE, getStateFromMeta(meta * EnumFacing.values().length).getValue(TYPE)); } @Override public int getMetaFromState(IBlockState state) { MacTypes type = (MacTypes) state.getValue(TYPE); EnumFacing facing = (EnumFacing) state.getValue(FACING); int meta = type.getID() * EnumFacing.values().length + facing.ordinal(); return meta; } @Override public IBlockState getStateFromMeta(int meta) { MacTypes type = MacTypes.values()[(int)(meta / EnumFacing.values().length) % MacTypes.values().length]; EnumFacing facing = EnumFacing.values()[meta % EnumFacing.values().length]; return this.getDefaultState().withProperty(TYPE, type).withProperty(FACING, facing); } @Override public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list) { for(int i = 0; i < MacTypes.values().length; i++) { list.add(new ItemStack(itemIn, 1, i)); } } @Override public String getSpecialName(ItemStack stack) { return MacTypes.values()[stack.getItemDamage()].getName(); } @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos))); } @Override public int damageDropped(IBlockState state) { return getMetaFromState(state); } } Now, for some reason, my EnumFacing.getDirectionFromEntityLiving is throwing an error "The method getDirectionFromEntityLiving(BlockPos, EntityLivingBase) is undefined for the type EnumFacing". Here is my EnumHandler, if it helps with troubleshooting: package archieab.andustry.handlers; import net.minecraft.util.IStringSerializable; public class EnumHandler { public static enum MacTypes implements IStringSerializable { BASIC("basic", 0), ADVANCED("advanced", 1); private int ID; private String name; private MacTypes(String name, int ID) { this.ID = ID; this.name = name; } @Override public String getName() { return this.name; } public int getID() { return ID; } @Override public String toString() { return getName(); } } } Additionally, my block will now always place with the facing tag "=up". Any help would be appreciated!
  21. Thank you very much (both of you) for the support and I will get back to you tomorrow.
  22. Could you elaborate on what I need to do now? (I have a fairly amateur knowledge of Java)
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.