Posted June 25, 20169 yr okay so ive been looking online and i cant find where world.getBlockMetadata is or what it was replaced with. ive looked for about a day and can not find it. if anyone could help that would be amazing.
June 25, 20169 yr Methods relating to Block s and metadata now use IBlockState instead. Forge's documentation has an introduction to block states here. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
June 25, 20169 yr It doesn't exist. World#getBlockState is the replacement for both World#getBlock and World#getBlockMetadata . Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
June 25, 20169 yr Author okay so ive been working and trying to figure out how this goes but i cant get my head to work out what to do im trying to check to see if the block is a source block, and im not finding how to do the block pos that the code is asking for if i try x,y,z it gives me an error, so heres the line of code im working on some of it is misssing since ive been working on this since last night and every time i try something i dose not work. the problems im having are at the playsound, getblock, setblock, the metadata of a block at the x,y,z , and checking a blocks light value at the x,y,z public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack, IBlockState blockState) { if (itemStack.getItem() == DefineCraftModItems.HellStoneBoots) { for(int _x = -3; _x <= 3; _x++) { for(int _z = -3; _z <= 3; _z++) { if(Math.abs(_x) + Math.abs(_z) <= 3) { int x = (int) player.posX; int y = (int) player.posY - 1; int z = (int) player.posZ; boolean IsFlowing = (world.getBlockState(null) != null); //(x+_x, y, z+_z).getBlock >= 1); boolean IsStill = (world.getBlockMetadata(x+_x, y, z+_z) == 0); Block block0 = world.getBlock(x,y+1,z); Block block = world.getBlock(x+_x, y, z+_z); //check and replace. if(block == Blocks.water && IsStill || block ==Blocks.flowing_water && IsStill){ blockState.setBlock(x+_x, y, z+_z, DefineCraftModBlocks.meltingObsidian1); world.playSound(player, (float)x + 0.5F, (float)y + 0.5F, (float)z + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); } if(block == Blocks.lava && IsStill || block ==Blocks.flowing_lava && IsStill){ world.setBlock(x+_x, y, z+_z, DefineCraftModBlocks.meltingObsidian); world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); } if(block == Blocks.water && IsFlowing || block ==Blocks.flowing_water && IsFlowing || block == Blocks.lava && IsFlowing || block ==Blocks.flowing_lava && IsFlowing){ world.setBlock(x+_x, y, z+_z, DefineCraftModBlocks.meltingObsidian0); world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); } //has full armor if (itemStack.getItem() == DefineCraftModItems.HellStoneBoots && itemStack.getItem() == DefineCraftModItems.HellStoneLegs && itemStack.getItem() == DefineCraftModItems.HellStoneChest && itemStack.getItem() == DefineCraftModItems.HellStoneHelmet){ { if (world.getLightValue (x-1, y+1, z) <7 && block0 != DefineCraftModBlocks.VanishingLight){ if (world.getBlock(x-1, y+1, z) == Blocks.air){ world.setBlock(x-1,y+1,z, DefineCraftModBlocks.VanishingLight); world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "step.stone", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); } else { world.setBlock(x-1,y+2,z, DefineCraftModBlocks.VanishingLight); world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "step.stone", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); } } if (player.isBurning()){ player.extinguish(); world.playSound((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); } } } } } } } //Just Chest if (itemStack.getItem() == (DefineCraftModItems.HellStoneChest)){ player.fallDistance = 0.0F; player.capabilities.allowFlying = true; } //just helme if(itemStack.getItem().getUnlocalizedName() == "HellStoneHelmet") { if(player.isInWater()) { player.setAir(20); } } }
June 26, 20169 yr Author this is what i have came up with but its still not working, and its giving me an error boolean IsFlowing = (world.getBlockState(blockPos.getDistance(x+_x, y, z+_z)) >= 1); //(x+_x, y, z+_z).getBlock >= 1); the error is : The method getBlockState(BlockPos) in the type World is not applicable for the arguments (double)
June 26, 20169 yr Any method that took a block position as individual coordinate arguments now takes a single BlockPos argument instead. Use World#getBlockState to get the IBlockState at a BlockPos or World#setBlockState to set it. Use IBlockState#getBlock to get the Block represented by an IBlockState . Use IBlockState#getValue to get the value of an IProperty in the IBlockState . Use Block#getDefaultState to get the default IBlockState of a Block , then chain IBlockState#withProperty calls to get the IBlockState with the specified property values set. Blocks usually store their properties in static fields. In this case, BlockLiquid.LEVEL is the property you want to query the value of. This uses the same values as the metadata in earlier versions, so 0 is a source block and 15 is the smallest amount of liquid. Forge's documentation explains how to play sounds in 1.9+ here. BlockPos has methods to offset the position in each cardinal direction (i.e. add the specified amount to a single coordinate) and to add an arbitrary amount to each coordinate. Use these instead of manually re-creating BlockPos objects where possible, this will make your code easier to read. All of the casts to double and float are pointless, int s are automatically promoted to float s, float s are automatically promoted to double s. You only see that in the vanilla code because the compiler generates the casts for you. You check if a single ItemStack 's Item is equal to all of your armour Item s; but it can only be one of them, not all of them. You later compare the Item using its unlocalised name; this is a bad idea since unlocalised names aren't unique and can change at any time. A class generally shouldn't be checking for specific instances of itself, use instanceof to check if the player's equipped items are your armour and the ItemArmor#armorType field to check which equipment slot this is for. Your onArmorTick method has a random IBlockState argument and doesn't override the super method. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
June 26, 20169 yr Author im not fully understanding what your saying, i understand most of it but im still getting an error, so i know im missing somthing in the code heres a link to the github if needed: https://github.com/x-j0nnay-x/Definecraft-1.9.4-Src
June 26, 20169 yr im not fully understanding what your saying, i understand most of it but im still getting an error, so i know im missing somthing in the code heres a link to the github if needed: https://github.com/x-j0nnay-x/Definecraft-1.9.4-Src This is kinda like: "That thing doesn't do the thing I want it to. I don't understand the thing that is supposed to make that other thing do its thing". In other words - you are too vague and we are not gonna write method for you. You got one of best explanation of IBlockState there is - what do you not understand? * x,y,z is now BlockPos - wrapped x,y,z * You don't separately ask world about Block or Metadata at given x,y,z - you ask it about state which is wrapper for both block and metadata. * Metadata is no longer integer 0-15 (it is, but only in serialization), but is represented by properties inside said state. Those properties can be whatever you want, you can have plenty of them, it's just that given x,y,z can still only hold 16 bits of data (said serialization metadata). What is so hard? 1.7.10 is no longer supported by forge, you are on your own.
June 26, 20169 yr Author Thank you i Understood that, its just when reading long lines i get mixed up, so if i am getting what your saying then this should work for checking if the block is the source or not. and this double Grid will be where it will check? double Grid = (blockPos.getDistance(x+_x, y, z+_z)); boolean IsSource = (world.getBlockState(blockPos).isFullBlock());
June 26, 20169 yr // Assumed variable: "blockPos" double Grid = (blockPos.getDistance(x+_x, y, z+_z)); // double "Grid" will be equal to distance from "blockPos" to coords of your choice "x+_x, y, z+_z" - where idk what are those variables. Also - this has nothing to do with line below so idk why you even posted it. boolean IsSource = (world.getBlockState(blockPos).isFullBlock()); // you will get state at "blockPos" (x/y/z) and check if block is full. Idk if full block means that it is source of water - if you want to check for source you need to get META from STATE and check if it is source (meta=0 i think). P.S - what's up with this "bold" code formatting 1.7.10 is no longer supported by forge, you are on your own.
June 26, 20169 yr Author the x+_x, y, z+_z is for my for loop. in 1.7.10 it checked 3 in front, back, left, right to see if its water or lava. i dont know where to look to find how things where changed, and i feel stupid for asking alot of questions. i did get the sound working now just need to get the checking the block done and the replacing the block done.
June 26, 20169 yr Something like this, idk wrote it in post: for (BlockPos pos : BlockPos.getAllInBox(blockPos.down(3).east(3), blockPos.up(3).west(3))) { IBlockState state = world.getBlockState(pos); if (state.getBlock() == WATER && state.getValue(BlockLiquid.LEVEL) == 0) do something and eventually call break if needed. } Source is either 0 or 15. or something, idk. 1.7.10 is no longer supported by forge, you are on your own.
June 26, 20169 yr Author ya, so they really made it that easy to call the directions? ive been way over thinking it
June 26, 20169 yr what ernio said would work. frankly i wouldn't write it that way (create 49 BlockPos objects for the loop variable and 6 for bounds), but it would work. calling getAllInBoxMutable instead eliminates object creation for iterations. anyway, relax about blockstates, they are a good thing (even if they are bothersome sometimes). if you have the state of a wooden log block, you can just ask "is its type a birch?" instead of "is meta & 3 equal to 2?". serious difference, don't you agree?
June 26, 20169 yr P.S - what's up with this "bold" code formatting The forum's new syntax highlighter is trying to syntax highlight your comments. 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.
June 26, 20169 yr P.S - what's up with this "bold" code formatting The forum's new syntax highlighter is trying to syntax highlight your comments. Well, that is obvious "d18" So then other question, is there something like [.code=java][./code] or something. Whoa... I didn't know =" " adds title: 1.7.10 is no longer supported by forge, you are on your own.
June 26, 20169 yr Author is there a place to find what forge looks for the sounds, what i have shows no errors but its not working, world.playSound(player, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), Blocks.FIRE.getSoundType().getPlaceSound(), null , Blocks.STONE.getSoundType().getVolume(), Blocks.STONE.getSoundType().getPitch()); world.playSound(player, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), Blocks.STONE.getSoundType().getPlaceSound(), null , Blocks.STONE.getSoundType().getVolume(), Blocks.STONE.getSoundType().getPitch()); so if you have any idea of why its not working i would like to know, i think its with how im getting the sound,
June 26, 20169 yr Author on a armor tick update for if there is water with in a 3x3 radius from player
June 26, 20169 yr Author for (BlockPos pos : BlockPos.getAllInBox(blockPos.down(3).east(3), blockPos.up(3).west(3))) { if (itemStack.getItem() == DefineCraftModItems.HellStoneBoots) { IBlockState state = world.getBlockState(blockPos); if (state.getBlock() == Blocks.WATER && state.getValue(BlockLiquid.LEVEL) == 0 || state.getBlock() == Blocks.FLOWING_WATER && state.getValue(BlockLiquid.LEVEL) == 0) { // world.setBlock(x+_x, y, z+_z, DefineCraftModBlocks.meltingObsidian1,0, 1); //blockState.setBlock(x+_x, y, z+_z, DefineCraftModBlocks.meltingObsidian1); world.playSound(player, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), Blocks.FIRE.getSoundType().getPlaceSound(), null , Blocks.STONE.getSoundType().getVolume(), Blocks.STONE.getSoundType().getPitch()); } if (state.getBlock() == Blocks.LAVA && state.getValue(BlockLiquid.LEVEL) == 0 || state.getBlock() == Blocks.FLOWING_LAVA && state.getValue(BlockLiquid.LEVEL) == 0) { // blockState.setBlock(x+_x, y, z+_z, DefineCraftModBlocks.meltingObsidian); world.playSound(player, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), Blocks.FIRE.getSoundType().getPlaceSound(), null , Blocks.STONE.getSoundType().getVolume(), Blocks.STONE.getSoundType().getPitch()); } else if (state.getBlock() == Blocks.LAVA && state.getValue(BlockLiquid.LEVEL) >= 1 || state.getBlock() == Blocks.FLOWING_LAVA && state.getValue(BlockLiquid.LEVEL) >= 1) { // blockState.setBlock(x+_x, y, z+_z, DefineCraftModBlocks.meltingObsidian0); world.playSound(player, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), Blocks.FIRE.getSoundType().getPlaceSound(), null , Blocks.STONE.getSoundType().getVolume(), Blocks.STONE.getSoundType().getPitch()); } }
June 26, 20169 yr Author okay, did not know you wanted the whole armor tick, its in the github link. but here is the latest setup public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack, IBlockState blockState, BlockPos blockPos) { int x = (int) player.posX; int y = (int) player.posY - 1; int z = (int) player.posZ; for(int _x = -3; _x <= 3; _x++) { for(int _z = -3; _z <= 3; _z++) { if(Math.abs(_x) + Math.abs(_z) <= 3) { for (BlockPos pos : BlockPos.getAllInBox(blockPos.down(3).east(3), blockPos.up(3).west(3))) { if (itemStack.getItem() == DefineCraftModItems.HellStoneBoots) { IBlockState state = world.getBlockState(blockPos); if (state.getBlock() == Blocks.WATER && state.getValue(BlockLiquid.LEVEL) == 0 || state.getBlock() == Blocks.FLOWING_WATER && state.getValue(BlockLiquid.LEVEL) == 0) { // world.setBlock(x+_x, y, z+_z, DefineCraftModBlocks.meltingObsidian1,0, 1); //blockState.setBlock(x+_x, y, z+_z, DefineCraftModBlocks.meltingObsidian1); world.playSound(player, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), Blocks.FIRE.getSoundType().getPlaceSound(), null , Blocks.STONE.getSoundType().getVolume(), Blocks.STONE.getSoundType().getPitch()); } if (state.getBlock() == Blocks.LAVA && state.getValue(BlockLiquid.LEVEL) == 0 || state.getBlock() == Blocks.FLOWING_LAVA && state.getValue(BlockLiquid.LEVEL) == 0) { // blockState.setBlock(x+_x, y, z+_z, DefineCraftModBlocks.meltingObsidian); world.playSound(player, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), Blocks.FIRE.getSoundType().getPlaceSound(), null , Blocks.STONE.getSoundType().getVolume(), Blocks.STONE.getSoundType().getPitch()); } else if (state.getBlock() == Blocks.LAVA && state.getValue(BlockLiquid.LEVEL) >= 1 || state.getBlock() == Blocks.FLOWING_LAVA && state.getValue(BlockLiquid.LEVEL) >= 1) { // blockState.setBlock(x+_x, y, z+_z, DefineCraftModBlocks.meltingObsidian0); world.playSound(player, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), Blocks.FIRE.getSoundType().getPlaceSound(), null , Blocks.STONE.getSoundType().getVolume(), Blocks.STONE.getSoundType().getPitch()); } } }//has full armor if (itemStack.getItem() == DefineCraftModItems.HellStoneBoots && itemStack.getItem() == DefineCraftModItems.HellStoneLegs && itemStack.getItem() == DefineCraftModItems.HellStoneChest && itemStack.getItem() == DefineCraftModItems.HellStoneHelmet){ { // if (world.getLightValue (x-1, y+1, z) <7 && block0 != DefineCraftModBlocks.VanishingLight){ // if (world.getBlock(x-1, y+1, z) == Blocks.air){ // world.setBlock(x-1,y+1,z, DefineCraftModBlocks.VanishingLight); world.playSound(player, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), Blocks.STONE.getSoundType().getPlaceSound(), null , Blocks.STONE.getSoundType().getVolume(), Blocks.STONE.getSoundType().getPitch()); // } // else // { // world.setBlock(x-1,y+2,z, DefineCraftModBlocks.VanishingLight); world.playSound(player, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), Blocks.STONE.getSoundType().getPlaceSound(), null , Blocks.STONE.getSoundType().getVolume(), Blocks.STONE.getSoundType().getPitch()); } } if (player.isBurning()){ player.extinguish(); world.playSound(player, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), Blocks.STONE.getSoundType().getPlaceSound(), null , Blocks.STONE.getSoundType().getVolume(), Blocks.STONE.getSoundType().getPitch()); } } // } // } } } //Just Chest if (itemStack.getItem() == (DefineCraftModItems.HellStoneChest)){ player.fallDistance = 0.0F; player.capabilities.allowFlying = true; } //just helme if(itemStack.getItem().getUnlocalizedName() == "HellStoneHelmet") { if(player.isInWater()) { player.setAir(20); } } }
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.