Jump to content

iAmRinzler

Members
  • Posts

    22
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    Building Knowledge

iAmRinzler's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Thanks for clearing that up. I'll look into the instance. I only thought the function needed the property type, not the specific property instance.
  2. I understand the bits of code that aren't valid java. I only posted them to illustrate that I have been attempting everything and Java is a fairly new language for me. I also understand that the forge documentation is pseudocode, that doesn't mean it is clear or 'good' pseudocode. From the Forge documentation. This confused me. If I can't use IProperty<EnumDyeColor> then how do I get the appropriate IProperty instance I want the value of? Thanks.
  3. Hello! How do I get the value of the property? I have been experimenting with blockstates recently but I can't seem to pass the appropriate argument to the .getValue(IProperty<T> property) function. if (args.length == 1 && args[0].equals("blockstate")) { World world = sender.getEntityWorld(); cDroid.setPos2(cDroid.getBlockPosUnderMouse()); sender.addChatMessage(new TextComponentString("Setting Block: " + cDroid.getPos2() + "\n")); System.out.println(world.getBlockState(cDroid.getPos2())); System.out.println(world.getBlockState(cDroid.getPos2()).getMaterial() + " THE MATERIAL"); System.out.println(world.getBlockState(cDroid.getPos2()).getProperties() + " THE PROPERTIES"); System.out.println(world.getBlockState(cDroid.getPos2()).getPropertyNames() + " THE PROPERTY NAMES."); System.out.println(world.getBlockState(cDroid.getPos2()).getBlock() + " THE BLOCK."); } This is a bit that I have written to dive into what I can do with blockstates. All the above calls provide the expected output. My issue is with getting individual values of the properties so i can run comparisons against similar blocks. I can't seem to pass the IProperty<T> property argument to the .getValue function properly. 1) I have a Wool block that has the property color=lime. 2) How do I pull the value 'lime' out of the property? The forge (https://mcforge.readthedocs.io/en/latest/blockstates/states/)documentation about blockstates tells me that I should pass .getValue(<PROPERTY>) to get the values of the properties. This clearly doesn't work and the compiler complains anyway I try and pass this argument. I have tried every way I can think of to pass the EnumDyeColor property to this function: .getValue(<EnumDyeColor>) //doesn't work .getValue(EnumDyeColor.LIME) //doesn't work .getValue(IProperty<EnumDyeColor> EnumDyeColor.LIME) //doesn't work For the sake of redundancy I won't post all my various attempts but none of them provide a property value (I have also tried passing PropertyEnum, the class used for the wool block colors as returned by blockstate.getProperties()). Sorry if I am missing something simple here... The only thing I'm trying to do right now is (in the case of wool blocks): If property color = X //do stuff If property color = Y //do different stuff
  4. Thanks I am looking at it now. Lot's going on in RenderGlobal but I will work around in it. For now though I think I can use recolorBlock on wool and glass to produce the effect I want for my testing.
  5. An example would be the case where I have set two position markers (BlockPos or Double X,Y,Z's idc) A and B and I want to do something like make A look Red and B look Green. When I say transparent I mean only that it isn't necessary to replace the texture of the native block. Or perhaps changing the color of an array of blocks such as the surface area of the rectangle given by two BlockPos. (If you've ever used the factions mod it could be that we highlight the blocks slightly when a chunk is claimed and remove the color if that chunk is unclaimed). sorry If I am aimlessly wandering here. I have been hittin' the coffee hard. Basically I would have the function in a ticker and have it update a block color/tint if some condition is true.
  6. Ah so if the blocks were dyed wool then color should update. I can make a test world using wool blocks for what I'm doing then and the recolorBlock function should be fine. For adding a transparent tint layer over the block faces should I be looking in the Render package? It seems like I should be using VertexBuffer in place of WorldRenderer but meh it is all very confusing.
  7. Hello again! So I am working on something and it came up that it would be a nice feature to change the color of a block based on...stuff (really anything). Specifically right now I am working with pathfinding algorithms such as A*, DFS, BFS, Dijkstra's etc. In the case of A* I would like to tint a block slightly to visually differentiate which blocks are in the open/closed lists, which blocks are being scanned, etc. I found the function in the block class: /** * Common way to recolor a block with an external tool * @param world The world * @param pos Block position in world * @param side The side hit with the coloring tool * @param color The color to change to * @return If the recoloring was successful */ @SuppressWarnings({ "unchecked", "rawtypes" }) public boolean recolorBlock(World world, BlockPos pos, EnumFacing side, net.minecraft.item.EnumDyeColor color) { IBlockState state = world.getBlockState(pos); for (IProperty prop : state.getProperties().keySet()) { if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class) { net.minecraft.item.EnumDyeColor current = (net.minecraft.item.EnumDyeColor)state.getValue(prop); if (current != color) { world.setBlockState(pos, state.withProperty(prop, color)); return true; } } } return false; } This function doesn't seem to change the color of a block as expected though and always returns false for me. What should I do differently here? P.S. I have seen positions marked in classes that used WorldRenderer. But that doesn't seem to exist anymore.
  8. These are not the same thing. 2.5-10 is 0.0001048576 I think you meant 2.5 * 10-10 Also, you probably meant -7, not -10. yup. I caught that too. easy mistake to make sometimes.
  9. I understood the number itself and how floating point conversions are lossy (btw 2.5x10-7 == 0.00000025 != 2.5-10). I was only curious why it was being used there. It makes sense to clamp off the number at some small value though. Thanks! I appreciate your explanation!
  10. I am working on a rotation function that updates player's pitch and yaw based on the location of a block or entity near the player. I understand how to compute the angular change, theta, required from the players current look vector to the desired look vector using 2d or 3d vectors yada yada yada... All that being said when I am reviewing rotation functions that others have coded I see something like: final double d0 = x - mc.thePlayer.posX; final double d1 = z - mc.thePlayer.posZ; final double d2 = y - mc.thePlayer.posY - mc.thePlayer.getEyeHeight(); final double d3 = d0 * d0 + d2 * d2 + d1 * d1; if (d3 < 2.500000277905201E-7D) { return 0; } //DoStuff So my question is what is the significance of the number 2.500000277905201E-7? I haven't been able to find useful posts about it.
  11. I like Syntactic Sugar. It reminds me of the flavor of my tears when sitting through Data Structures and Algorithms a couple years ago.
  12. Exactly what I needed. Thanks! I have it working as I wanted now. However, do I need to handle the help text for each subcommand? I can't seem to access it otherwise. /help mymod gets the help text from the CommandTreeBase...but I can't seem to find the texts for the subcommands. I could just add a help argument branch for each subcommand... edit: I am generating the help text by simply having public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length == 1 && args[0].equals("help")) { sender.addChatMessage(new TextComponentString(getCommandUsage(sender))); } } in my subcommand execution. Seems to be working fine, although perhaps there is a better way. For my mod's command, I added a help sub-command that extends CommandHelp , stores the instance of the base command and overrides CommandHelp#getCommandMap and CommandHelp#getSortedPossibleCommands to return values from the base command. CommandTreeBase provides a getCommandMap method, but you have to implement getSortedPossibleCommands yourself ( CommandHelp calls ICommandManager#getPossibleCommands and sorts the result). You can see the base command here and the help sub-command here. Unfortunately this prints the vanilla header (which says /help instead of /testmod3 help ), but you'd need to re-implement CommandHelp#execute yourself to get around this. For the help files I am now using if (args.length == 1 && args[0].equals("help")) { throw new WrongUsageException("commands.testmod.command1.usage", new Object[0]); //TextComponentTranslation tct = new TextComponentTranslation("commands.testmod.command1.usage", new Object[0]); //sender.addChatMessage(tct); } Seems to work fine. Both the WrongUsageException and the TextComponentTranslation are working to get the string from the lang file.
  13. Well I seem to have gotten it working but in order to do so I had to just create an entirely new testmod. I don't have the slightest clue what was wrong with the first testmod but nothing I was doing would allow the .lang file to be recognized. I should note that the first testmod file had somehow been built into it's own gradle project and was independent of my Minecraft Forge gradle project (although it could still use the forge classes etc). I closed that testmod gradle project and recoded a testmod in the Minecraft Forge src file and my .lang file is being read properly now. I must have somehow screwed something up, I wish I knew what. Hopefully it continues to work for me. Thanks Choonster and Animefan for the helps.
  14. commands.testmod.usage=/testmod <command> /test <command> /tm <command> commands.testmod.setpos1.usage=/testmod setpos1 sets position 1. commands.testmod.setpos2.usage=/testmod setpos2 sets position 2. this is all that is in it. File currently saved as en_us.lang. Inside assets.testmod.lang.
  15. Everything I have read said that it needed to be "en_US.lang". However, I changed it to lowercase per your suggestion and it still isn't working. I get usage: commands.testmod.usage. There seemed to be debate as to whether it should be in the src folder or the resources folder though. right now I have it in both...
×
×
  • Create New...

Important Information

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