Everything posted by SSslimer
-
[1.7.10] [SOLVED] Problem with list for tasks.
Thats why the same list had two versions I will remember it for future project works. Now I am working on getting task from list by id. I have done sth like this: public EntityAIBaseOrder getOrderById(int par) { switch(par) { case 0: return new EntityAIStayHere(villager, 0); default: return null; } } this.orders.add(j, orderSystem.getOrderById(buffer.readInt())); That code adds to my empty list(its on client) object returned from method up with par as a id get from toBytes(). @Edit, I think everythink works as I wanted. Code is correct, no errors. Last question in that topic. How to make gui actionPerformed() wait for a moment to run some method(I want to refresh screen, but it refreshes before tasks are synchronized)
-
[1.7.10] [SOLVED] Problem with list for tasks.
So toBytes() and fromBytes() are for diferent sides?? In both I used this.orders I will try to code what you sugested.
-
[1.7.10] [SOLVED] Problem with list for tasks.
Again very strange error. Below are two methods. In first this.orders isnt null, but in second is null. When I put print method in first met. it shows size, in second met. I get an error. Why it happens when it should not?? public void toBytes(ByteBuf buffer) { buffer.writeInt(this.entityId); System.out.println(this.orders.size()); for (int i = 0; i < this.orders.size(); i++) { buffer.writeInt(((EntityAIBaseOrder) this.orders.get(i)).getId()); } } public void fromBytes(ByteBuf buffer) { this.entityId = buffer.readInt(); if(this.orders != null) { for (int j = 0; j < this.orders.size(); j++) { this.orders.add(j, this.orderSystem.getOrderById(buffer.readInt())); } } }
-
[1.7.10] [SOLVED] Problem with list for tasks.
Notfing has changed. Still the same error. for (int i = 0; i < this.orders.size(); i++) { System.out.println(this.orders.size()); buffer.writeInt(((EntityAIBaseOrder) this.orders.get(i)).getId()); } Ups, I forgot to add .get(i) I wanted to get an object from list and get grom it and id. Adding it solved the error.
-
[1.7.10] [SOLVED] Problem with list for tasks.
Done, sth has changed. Now I get errors. io.netty.handler.codec.EncoderException: java.lang.ClassCastException: java.util.ArrayList cannot be cast to BetterWorld.ai.EntityAIBaseOrder this.taskEntries() is an arraylist with stored EntityAIBaseOrder objects. public void syncOrders() { ModBetterWorld.packets.sendToAll(new GuiRequestPacketSendOrders(this.villager.getEntityId(), this.taskEntries)); } There objects should be copied and stored in List orders. private List orders = new ArrayList(); public GuiRequestPacketSendOrders(int id, List orders) { this.entityId = id; this.orders = orders; } And here I get and error. The list should store correct object but it doesnt and gets error. buffer.writeInt(((EntityAIBaseOrder) this.orders).getId());
-
[1.7.10] [SOLVED] Problem with list for tasks.
Hm, I made class for sending packets form server to client but still both sides arent the same. Where I should call my method to send packets? Right now its in general order class and I call it in entity class each second.
-
[1.7.10] [SOLVED] Problem with list for tasks.
General order class: public abstract class EntityAIBaseOrder { private int id; public EntityAIBaseOrder(int par) { this.id = par; } public int getId() { return id; } //Zwraca czy rozkaz powinien zostac wykonany, cos co od razu dziala to true, jesli musi byc cos spelnione to dac warunki public abstract boolean shouldExecute(); //To jest wykonywane tylko raz podczas zaczecia polecenia, tutaj powinny byc cele poczatkowe public void startExecuting() {} //Wykonywane, gdy zadanie jest przerwane. public void resetTask() {} //Wykowywane jest za kazdym tickiem systemu public void updateTask() {} //Zwraca czy rozkaz zostal rozpoczety public abstract boolean hasStarted(); //Zwraca czy cele rozkazu zostaly osiagniete public abstract boolean isDone(); } My exaple of order to look does the system work. public class EntityAIStayHere extends EntityAIBaseOrder { private EntityBetterVillager villager; private boolean isStarted; private boolean isDone; public EntityAIStayHere(EntityBetterVillager villager, int par) { super(par); this.villager = villager; } public boolean shouldExecute() { return true; } public void startExecuting() { this.isStarted = true; this.villager.getNavigator().tryMoveToXYZ(this.villager.posX, this.villager.posY, this.villager.posZ, 0.6D); } public void resetTask() { this.isStarted = false; this.villager.getNavigator().clearPathEntity(); } public void updateTask() { } @Override public boolean hasStarted() { return isStarted; } @Override public boolean isDone() { return false; } That order might not work, but its set to not be removed. Tell me how do you want to get from it primitives types without using id or sth like this.
-
[1.7.10] [SOLVED] Problem with list for tasks.
I know the same is with ItemStack, it can be sended as primitives. But my orders arent made in that way. I think the easiest will be writing the order id and other settings and that reading it and combining into order object. I am not sure will it work.
-
[1.7.10] [SOLVED] Problem with list for tasks.
Ok, I have that but how to send an element which is an object like all class?
-
[1.7.10] [SOLVED] Problem with list for tasks.
Is any good way to write and read an object like ArrayList?? I can try to make an id for each order and write only int and than read that id and set a order maching to that id. I dont know is my way quite good so I am waiting for your sugestions.
-
[1.7.10] [SOLVED] Problem with list for tasks.
I think I found a solution. Few weeks earlier I have similar problem with inventory. I will try to refresh(send packet from server to client) each time my gui changes Now I need to make new packet class and I will post later if I managed to do that.
-
[1.7.10] [SOLVED] Problem with list for tasks.
Using system.out.print I have noticed that list of tasks is null only in one side. So the size on client and server isnt synchronized. Only the server side list is changing. I dont know more but I think that I need to get my list from server not from client as I have in gui.
-
[1.7.10] [SOLVED] Problem with list for tasks.
When the button is activated it sends a packet. Than system add task using data from the packet. So I think its correct with what you have said.
-
[1.7.10] [SOLVED] Problem with list for tasks.
Ok but are any way to get tasks on clinent side? I need it to my gui, because clicling another buttons will remove tasks.
-
[1.7.10]Light value?
In earlier versions there was but now I cant find it. Maybe they us sth with OpenGL.
-
[1.7.10]Light value?
Sorry for offtopic but where we can find texture file with ligh, if it exists.
-
[1.7.10] [SOLVED] Problem with list for tasks.
Ok, I will post all code for better explanation. In method actionPerformed(). ModBetterWorld.packets.sendToServer(new GuiRequestPacketAddOrder(this.villager.getEntityId(), guiButton.id)); That code adds tasks to list, entity is set by id system and task by my other list with possible tasks to add. In that part of code, system prints that my taskEntries(I need to change the name) is growing on each button click so system adds tasks to list. @Override public IMessage onMessage(GuiRequestPacketAddOrder message, MessageContext ctx) { EntityPlayer player = ctx.getServerHandler().playerEntity; World world = player.worldObj; EntityBetterVillager entity = (EntityBetterVillager) world.getEntityByID(message.entityID); entity.order.addTask((EntityAIBaseOrder) entity.possibleOrders.get(message.buttonID - 3)); System.out.println(entity.order.taskEntries.size()); return null; } Code for adding tasks to list using method. public List taskEntries = new ArrayList(); public void addTask(EntityAIBaseOrder p_75776_2_) { this.taskEntries.add(p_75776_2_); } That code is in initGui(). It should return the same size as in packet class but it doesnt. System.out.println(this.villager.order.taskEntries.size());
-
[1.7.10] [SOLVED] Problem with list for tasks.
Hey, in my gui when button is activated it send packet to server. By data send to server it adds task to mob tasks list. In packet sender class I can see that size of the list is growing up correctly, but when I try to get data from my list by entity class system tells that list size is 0. I will post some code if it helps.
-
[1.7.10] What is Profiler.class
Ok, thanks. I think I dont need this. Maybe somewhen in futer.
-
[1.7.10] What is Profiler.class
Hey, I have no idea what is it and to what is it needed in the game code. Forge description tells me nothing. Can somebody tell me more about its application?
-
[1.7.10] Adding and removing tasks from GUI.
So I must create packet which sends the button id andon message method put my stuff for adding or removing tasks? @Edit I think that I did it properly, removing tasks is easier(in my system I need only to remove task from list without any parameters) But to be sure that adding works good too I will need to make some upgrades in my code to allow customisation of tasks and of course I need to make tasks to add sth
-
[1.7.10] Adding and removing tasks from GUI.
Thats not good, thats very bad. I will need to make a lot of things. Despite sending tasks objects I will need to send their configuration. Thanks for help. I will post back if I have a problem.
-
[1.7.10] Adding and removing tasks from GUI.
I need the change tasks of one mob on which I opend GUI.
-
[1.7.10] Adding and removing tasks from GUI.
Hey, I want to add and remove tasks why button in my gui is activated. Need I to send packets or it would work without it??
-
[1.7.10] Help needed with understanding EntityArrowObject
Greate idea. I will try and reply. I was wrong. That par3 is strange. If I put there 2F speed seems to be 4m/tick When 4F it seems to be from 4 to 6. Can sb tries to get know what are those par3 and how to set correctly speed?? Mayby I have too much lags and speed isnt corectly shown in console. @Edit Ok, now I am 100% sure that par3 is speed par3 is preaty strange argument. The unit of it is meter per tick, but we must / our speed by 1.5 to make it correct in the balistic code.
IPS spam blocked by CleanTalk.