• 1

    posted a message on [SOLVED] Custom Arrow rendering in wrong position from server
    I didn't fuly understand this parameter, but thanks to you!!

    Wrote this explanation a while back, but for the most part it's still relevant.
    http://www.minecraft...0#entry18822284
    See the Tracker Entity Explanation section.

    Seems I need to update that chart.
    Posted in: Modification Development
  • 0

    posted a message on Wait() Java...
    lol
    Posted in: Modification Development
  • 0

    posted a message on [Forge] OnWorldCreate event?
    Including what FatherToast said, you could also check in ./saves/players folder to see if it's empty.

    One thing I noticed after world create button is pressed in GuiCreateWorld.actionPerformed() is
    //....
    WorldType.worldTypes[this.worldTypeId].onGUICreateWorldPress();
    //....

    Though from what I checked that method isn't used at all. Maybe it has a different name and purpose, but it would be a great help.
    Posted in: Modification Development
  • 0

    posted a message on A Letter to all intrested in learning to Mod or Learning Java (Plus a bit of personal opinion)
    p.s. my knowledge of Java is far larger then of English grammar so if i made a mistake just tell me.

    I lost count :P

    Biggest problem is everyone wants to jump right into modding because it's cooler than writing to the console; to some. Programmers like me and others say all the time to learn Java and then try modding, but some don't have the patience and want to create their ideas. Which I don't blame them because I was one of them. Before I knew enough Java I went into Android development and boy it was a lot more work; Assets, Layout files, Application Design and learning the basic APIs. I did however get my app out but It took a long time and looking back I knew it could of done been a lot better, which is what you will feel if you jump right into modding without a good background in programming, for the most part. It may seem like a lot learning Java but it pays off, trust me.

    As of now when I'm not busy I take a look at topics that are more Minecraft than Java related because it's a Minecraft Development Forum. No syntax errors or simple error reports which could of been fixed with some basic knowledge of Java. Maybe if people started doing that this forum wouldn't be filled with those types of topics and would make them learn some Java, but there is always someone to helping them lol.

    There are more stuff to be said but I'm not going to repeat what you guys said above.
    Posted in: Modification Development
  • 1

    posted a message on Bolt/Custom Arrow Glitch - Different than other topics I've Found
    Tried my own custom arrow by coping the code and not extending EntityArrow and got same problem as OP. Back to square one lol.

    why doesn't changing tracking to 'true'....

    Try it out yourself. Print some output every time setVelocity() is called on your custom EntityArrow. When set velocity updates is false, it will be called only once. When true, it will be called multiple times. I didn't see a difference but those extra calls to setVelocity wasn't needed and wastes network data because it sends a Packet28EntityVelocity everytime. I'm somewhat confused on it too.


    Looks like neither ThrowableEntity nor IThrowableEntity are in EntityTracker / EntityTrackerEntry, nor do they make an appearance in NetClientHandler, from what I can tell

    IThrowableEntity is part of forge and is used when creating a custom spawner packet. Take a look at cpw.mods.fml.common.network.EntitySpawnPacket#generatePacket method.
    if (ent instanceof IThrowableEntity)
    {
    Entity owner = ((IThrowableEntity)ent).getThrower();
    dat.writeInt(owner == null ? ent.entityId : owner.entityId);
    // ...
    dat.writeInt((int)(mX * 8000D));
    dat.writeInt((int)(mY * 8000D));
    dat.writeInt((int)(mZ * 8000D));
    }

    ​See the resemblance from NetClientHandler? Same thing as how EntityArrow is handled.

    On EntityTracker and its Entry, take a look at this method.
    net.minecraft.entity.EntityTracker#addEntityToTracker
    First it checks FML for a mod registered entity, and returns method if found. Then it checks vanilla entities. In the end it calls addEntityToTracker(entity, range, frequency, send VelocityUpdates). That will build the mob and vehicle packets which will be sent in net handler.


    Correct me if I'm wrong, but I didn't see anything to suggest that Packet23VehicleSpawn can handle custom entity types

    Read this: http://www.minecraft...__140#howto_mod
    When registering Mod Entities, it will use minecraft's custom packet and then their own custom spawn packet as I mentioned above.

    Back to OPs problem.
    It seems once the arrow is in the ground, it backfires using the original velocity. In OP video you can tell it's shooting fast and the backfire is large. When using my custom bow I shot the ground lightly, it back fired lightly. Time for some debugging...
    Posted in: Modification Development
  • 0

    posted a message on Bolt/Custom Arrow Glitch - Different than other topics I've Found
    Actually, just looked into IProjectile and it looks like that is only used for dispensers. Sets the position and direction when fired.

    As for velocity updates read this. http://www.minecraft...0#entry17787020 Was some time back but most of it is the same as of now.

    It's been a while since I went on this topic, but from what I remember is if the Entity has a throwerEntityId or the Shooting Entity, it will set the velocity update when spawned.
    // From NetClientHandler where entity has a throwerEntityId
    ((Entity)object).setVelocity((double)par1Packet23VehicleSpawn.speedX / 8000.0D, (double)par1Packet23VehicleSpawn.speedY / 8000.0D, (double)par1Packet23VehicleSpawn.speedZ / 8000.0D);

    That's where the IThrowableEntity interface comes in, which was part of Forge.

    EntityThrowable doesn't do that(I believe). Take a look at how you register a EntityThrowable and EntityArrow

    // Throwable Entity
    EntityRegistry.registerModEntity(EntityExtremeSlim.class,
    "Extreme Slim", 1, this, 64, 10, true);
    
    // Arrow Entity
    EntityRegistry.registerModEntity(EntityExtremeArrow.class,
    "EntityExtremeArrow", 2, this, 64, 20, false);

    The throwable entity has velocity updates(true), but the arrow doesn't(false). Velocity updates call method
    public void setVelocity(double x, double y, double z)


    Like I said it's been a while but for the most part, it's still the same.
    Posted in: Modification Development
  • 1

    posted a message on [SOLVED] Error when rendering Throwable Entity?
    When you see a report, always look at the line of code where the problem(NPE in this case) resides. For the most part it's easy to figure out. :) Plus I've seen this type of error a thousand times here lol.
    Posted in: Modification Development
  • 2

    posted a message on [SOLVED] Error when rendering Throwable Entity?
    From reading your original report:
    java.lang.NullPointerException at
    cpw.mods.fml.common.network.EntitySpawnPacket.generatePacket(EntitySpawnPacket.java:75)


    And looking at that code.
    NetworkModHandler handler = (NetworkModHandler) data[2];
    // ....
    
    dat.writeInt(handler.getNetworkId()); // error

    It seems you didn't put the NetworkMod annotation.
    Example:
    @Mod(modid = "extrememod", name = "Extreme", version = "0.1-a1")
    @NetworkMod(clientSideRequired = true, serverSideRequired = false)
    public class ModExtreme
    Posted in: Modification Development
  • 0

    posted a message on Bolt/Custom Arrow Glitch - Different than other topics I've Found
    Ah, didn't notice this.inGround is private.

    One difference I notice in your code vs. EntityArrow, although I doubt this is the source of your issue, is that you implement 'IThrowableEntity' whereas EntityArrow implements 'IProjectile'.

    You will definitely need IThrowableEntity and most likely IProjectile too. Reason for IThrowableEntity is it sends velocity updates to the Entity. Before that interface came out(back in modloader where I made my thread), you would have to edit base classes to send them because it would check if an entity is an instanceof EntityArrow, then send the velocity update. But when registering your entity in FML's ModEntity method it creates and sends their own custom packets; doesn't interfere with vanilla net handler. Other than that, IProjectile should be implemented.

    If you plan on making more bullet type entities, create an abstract class which has all EntityArrow properties and implemented interfaces. That way you don't have to copy them every time.
    Posted in: Modification Development
  • 0

    posted a message on Bolt/Custom Arrow Glitch - Different than other topics I've Found
    So you want to pick up a custom bolt which has same properties as an Arrow, but it's not one(Arrow)? If so, you can still extend EntityArrow which will contain the physics and other necessary components. If you plan on editing more properties than it looks like you will have to create your own Arrow implementation.

    One method you will need to override is
    public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)

    Take a look at it and you will notice how it returns an Arrow to ItemStack, that's where you put your own Item.

    The onUpdate method just checks if it collides to ground, entity, if in water,calculates velocity, etc. I don't think you need to override that.
    Posted in: Modification Development
  • 0

    posted a message on Bolt/Custom Arrow Glitch - Different than other topics I've Found
    I guess you saw my thread on arrows, right? Your video does seem like the same problem or some other velocity update issue. I don't have time to look through all your code, but I'm assuming you copied it from the EntityArrow? Have you tried extending EntityArrow instead of copying code?
    Posted in: Modification Development
  • 0

    posted a message on Wait() Java...
    First off
    Thread.wait()

    In Java multithreading you have methods wait(), notify(), and sleep(). The first two correspond with each other. You call wait() on an object which you want a lock on; not a Thread. The thread in which you called wait() on object will "wait" or just sit there until notify() is called on same object. Sleep() will "wait" for a specific amount of time. Take a look at this example.

    public class Executor {
    	static Executor executor = new Executor();
    
    
    	final Object object = new Object();
    	boolean stop = false;
    
    
    	public void doOperation() {
    		System.out.println("Called doOperation()");
    		while (stop) {
    			// wait until stop becomes true
    			try {
    				synchronized (object) {
    					object.wait();
    				}
    			} catch (InterruptedException e) {
    				// Handle when a thread calls interrupt();
    				// This can happen when the object doesn't relieve notify()
    				// and you want to stop this thread lock.
    				// Most of the time you can do nothing or send a message to logger.
    			}
    		}
    
    		// Stop is now true
    		System.out.println("Operation has continued!");
    	}
    
    	public void toggleStop() {
    		stop = !stop;
    	}
    
    	public void wakeup() {
    		synchronized (object) {
    			// call notify on same object. Now the thread will continue
    			object.notify();
    		}
    	}
    
    	public static void main(String[] args) throws InterruptedException {
    		// create new thread to sleep
    		new Thread() {
    			@Override
    			public void run() {
    				try {
    					System.out.println("Sleeping for 5 seconds");
    					Thread.sleep(5000);
    					System.out.println("Done sleeping");
    				} catch (InterruptedException e) {
    					// same as I said above
    				}
    
    				// change boolean to false
    				executor.toggleStop();
    				// wakeup executor
    				executor.wakeup();
    			}
    		}.start();
    
    		// change boolean to true
    		executor.toggleStop();
    		// execute operation
    		executor.doOperation();
    
    	}
    
    
    }
    So don't use wait() because that will stop the current thread as you mentioned. Is this set time you want to wait part of the game? Waiting for a set amount of ticks in a TickHandler can work and it will be concurrent with the rest of the game. When you pause the game and you have a separate Thread sleeping, that thread will keep on going even though the rest of the game is in a paused state. But if you want this to be a separate task, then a TimerTask is a good idea.
    Posted in: Modification Development
  • 1

    posted a message on Query Help
    I've implemented a server ping. I wrote my own TCP/UDP library so some methods and classes you won't recognize. Take a look at the Read and Write methods where I use ByteBuffers. Notice the byte order is Big Endian.The protocol data is here

    http://pastebin.com/XFicDNre

    If you're confused on something just ask here. I take it you know how to use SocketChannels?

    BTW
    You're talking about Java and not python or another language?
    Posted in: Modification Development
  • 0

    posted a message on Very simple java question
    Can I PM you guys directly if I have anymore problems? Its would be much appreciated.
    I probably won't be much of a help now because I've moved on to other stuff, but if it's not too complicated or just another Java or programming question then feel free to PM me. Note I'm usually busy.
    Posted in: Modification Development
  • 1

    posted a message on Very simple java question
    if(mob=="cow" || mob=="pig" || mob=="chicken")
    http://stackoverflow...g-equals-versus explains the problem.Never compare strings with '==', unless they are interned(which is something you shouldn't be worried about). Correct way is
    if(mob.equals("cow") || /*.....*/)
    Posted in: Modification Development
  • To post a comment, please .