
Lyras
Members-
Posts
41 -
Joined
-
Last visited
Everything posted by Lyras
-
public static void moveNearest ( Entity horse ) { if ( InputHandler.riding ) { if ( Route.route == null || Route.routeConfig == null ) { Route.route = InputHandler.route; Route.routeConfig = new Configuration( Route.route ); } ArrayList < MarkerPoint > array = RouteReader.markersInRadius( Route.routeConfig ); MarkerPoint marker = Maths.nearestMarker( array ); EntityLiving entity = ( EntityLiving ) horse; double entitySpeed = ( ( EntityHorse ) entity ).getEntityAttribute( SharedMonsterAttributes.movementSpeed ).getAttributeValue() * 20; } } I changed the code a little bit.
-
1. Somehow I must get the object... 2. Something more helpful? xP
-
Hey, I've been making my mod for a while and a part of it is the moving of my horse and there's the problem: I don't know how to move it correctly. I guess there many ways and I tested many ways but none of them worked. EntityLiving entity = ( EntityLiving ) Minecraft.getMinecraft().thePlayer.ridingEntity; double entitySpeed = ( ( EntityHorse ) entity ).getEntityAttribute( SharedMonsterAttributes.movementSpeed ).getAttributeValue() * 20; ~Lyras PS: It's a normal horse, not my own entity
-
Thanks to you all and thanks for your patience You helped me alot Now someone must add "[solved]" to the title Greets from Germany
-
That's a left-over from old code I made. Sorry about that Mistake xP May be. I will take a look into the code Where's the problem?
-
For this I used the MaxX, MaxY and MaxZ... They're just used to compare the coords-bundle in the config, like you said, and the coords of the block. If there is match, I will spawn particles above it...
-
Now I done everything you said. When I don't filter the states... public static ArrayList < IBlockState > getBlocksNearby ( Entity player , int radius ) { ArrayList < IBlockState > stateList = new ArrayList < IBlockState > (); for( int x = ( int ) Math.min( player.posX - radius , player.posX + radius ); x <= Math.max( player.posX - radius , player.posY + radius ); x++ ) { for( int y = ( int ) Math.min( player.posY - radius , player.posY + radius ); y <= Math.max( player.posY - radius , player.posY + radius ); y++ ) { for( int z = ( int ) Math.min( player.posZ - radius , player.posZ + radius ); z <= Math.max( player.posZ - radius , player.posZ + radius ); z++ ) { IBlockState state = player.worldObj.getBlockState( new BlockPos ( x , y , z ) ); stateList.add( state ); } } } return stateList; } ... it will output "148617", I guess that's the amount of different states for the blocks within a radius of 10. In the same moment the game freezes and I have to close the window BUT the programm still outputs my sysout's. Now I'm gone further but the game still freezes :'( Code: private static File route = null; Configuration config = null; private static boolean markingUp = false; public static void setRoute ( File file ) { route = file; } /** * This method gets used when the player starts riding * with this method, I can markup the blocks of the loaded route by sending * particle packages to the player * @param bool The boolean which I use for my loop */ public static boolean markupWay ( boolean bool ) { markingUp = bool; return bool; } public static ArrayList < IBlockState > getBlocksNearby ( Entity player , int radius ) { ArrayList < IBlockState > stateList = new ArrayList < IBlockState > (); for( int x = ( int ) Math.min( player.posX - radius , player.posX + radius ); x <= Math.max( player.posX - radius , player.posY + radius ); x++ ) { for( int y = ( int ) Math.min( player.posY - radius , player.posY + radius ); y <= Math.max( player.posY - radius , player.posY + radius ); y++ ) { for( int z = ( int ) Math.min( player.posZ - radius , player.posZ + radius ); z <= Math.max( player.posZ - radius , player.posZ + radius ); z++ ) { IBlockState state = player.worldObj.getBlockState( new BlockPos ( x , y , z ) ); if ( stateList.contains( state ) ) { stateList.add( state ); } } } } return stateList; } @SubscribeEvent public void onClientTick ( TickEvent.ClientTickEvent e ) { if ( e.phase == Phase.END ) { System.out.println( "test" ); if ( markingUp ) { System.out.println( "debug inner" ); if ( route == null ) { route = InputHandler.route; } if ( config == null ) { config = new Configuration ( route ); } ArrayList < IBlockState > stateList = getBlocksNearby( Minecraft.getMinecraft().thePlayer , 10 ); System.out.println( stateList.size() ); for ( IBlockState state : stateList ) { for ( int i = 0; i < RouteReader.getMarkerPoints( config ); i++ ) { if ( config.get( "posX" , i + ":" , 0 ).getInt() == ( int ) state.getBlock().getBlockBoundsMaxX() ) { if ( config.get( "posY" , i + ":" , 0 ).getInt() == ( int ) state.getBlock().getBlockBoundsMaxY() ) { if ( config.get( "posZ" , i + ":" , 0 ).getInt() == ( int ) state.getBlock().getBlockBoundsMaxZ() ) { Minecraft.getMinecraft().thePlayer.worldObj.spawnParticle( EnumParticleTypes.REDSTONE , ( ( state.getBlock().getBlockBoundsMaxX() + state.getBlock().getBlockBoundsMinX() ) / 2 ) , ( ( state.getBlock().getBlockBoundsMaxY() + state.getBlock().getBlockBoundsMinY() ) / 2 ) , ( ( state.getBlock().getBlockBoundsMaxZ() + state.getBlock().getBlockBoundsMinZ() ) / 2 ) , 0.3 , 0.3 , 0.3 ); } } } } } } } } Anyway... Thank you for the help so far
-
Already done before you wrote it The boolean was even global before I want the method to put ALL blocks within a radius of 10 blocks array. Then I want to check if the coords of the block-object I am currently testing are the same as a coordinate-bundle in the file. So basicly I want to put every single block with its data into this array and not just the type.
-
I will do it with the ClientTickEvent. But there's another problem: The method "getBlocksNearby" is intended to get all blocks in the specified radius. But the method just returns the amount of different blocktypes...
-
1. The boolean will change. When the boolean is false and the player presses the specified button for auto-riding, the boolean will change to true. When it's true it will change to false. But if I pass true to the method the game instantly freezes and nothing gets outputted and I don't have the chance to change the passed boolean because it freezes. 2. I just want to get the blocks in the radius and then test if their coords are registered in the route-file.
-
"crashes" is the wrong word. When I press the button, a boolean gets set to true and then I call the method which will call itself as long as the boolean is true. But when this happens, the window doesn't react and gets whitish. And thats the problem: I don't get ANY output and so I cannot figure out the problem EDIT: I found out that the array only holds 7 elements and these elements are just blocktypes. Thats a new problem D: Is there a way to get blocks in a specified radius? I wrote several methods but no method really worked. :'(
-
Nothing happens. There is nothing in my console and "breakpoint" doesn't give me any information... As I said: The game just crashes without any output into the console or something like that. As long as the player is riding, the particles have to spawn above the blocks. As you can see in the code, the method is called anew while the boolean is true and the boolean is true as long the player is riding.
-
Hey folks, I've got a problem in my project that I can't fix: package utils; import java.io.File; import java.util.ArrayList; import handler.InputHandler; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumParticleTypes; import net.minecraftforge.common.config.Configuration; public class Marker { private static File route = null; public static void setRoute ( File file ) { route = file; } /** * This method gets used when the player starts riding * with this method, I can markup the blocks of the loaded route by sending * particle packages to the player * @param bool The boolean witch I use for my loop */ public static void markupWay ( boolean bool ) { if ( route != null ) { route = InputHandler.route; } Configuration config = new Configuration ( route ); if ( bool ) { /* Goes through all block objects in the list... */ for ( Block block : getBlocksNearby( Minecraft.getMinecraft().thePlayer , 10 ) ) { for ( int i = 0; i < RouteReader.getMarkerPoints( config ); i++ ) { /* ... and if the x-coord is equal to an value in the config... */ if ( config.get( "posX" , i + ":" , 0 ).getInt() == ( int ) block.getBlockBoundsMaxX() ) { /* ... and if the y-coord is equal to an value in the config... */ if ( config.get( "posY" , i + ":" , 0 ).getInt() == ( int ) block.getBlockBoundsMaxY() ) { /* ... and if the z-coord is equal to an value in the config... */ if ( config.get( "posZ" , i + ":" , 0 ).getInt() == ( int ) block.getBlockBoundsMaxZ() ) { /* Then I will send particles at the blocks position */ Minecraft.getMinecraft().thePlayer.worldObj.spawnParticle( EnumParticleTypes.REDSTONE , ( ( block.getBlockBoundsMaxX() + block.getBlockBoundsMinX() ) / 2 ) , ( ( block.getBlockBoundsMaxY() + block.getBlockBoundsMinY() ) / 2 ) , ( ( block.getBlockBoundsMaxZ() + block.getBlockBoundsMinZ() ) / 2 ) , 0.3 , 0.3 , 0.3 ); } } } } } //TODO Test if block is in list //send particle markupWay( bool ); } } public static ArrayList < Block > getBlocksNearby ( Entity player , int radius ) { ArrayList < Block > list = new ArrayList < Block > (); for ( int x = ( int ) player.posX - radius; x <= ( int ) player.posX + radius; x++ ) { for ( int y = ( int ) player.posY - radius; y <= ( int ) player.posY + radius; y++ ) { for ( int z = ( int ) player.posZ - radius; z <= ( int ) player.posZ + radius; z++ ) { if ( !list.contains( player.worldObj.getBlockState( new BlockPos ( x , y , z ) ).getBlock() ) ) { list.add( player.worldObj.getBlockState( new BlockPos ( x , y , z ) ).getBlock() ); } } } } return list; } } The player can choose a route and as soon as he starts riding by pressing a button, I want particles to spawn above the blocks, which are registered in the routes file. When I run the code, the game stops working and nothing happens and no crash-log will be created. Thanks in advance