
Thornack
Members-
Posts
629 -
Joined
-
Last visited
Everything posted by Thornack
-
I guess the reason why I am asking is because I already have a method of sending a packet to all players around me using public static final void sendToAllAround(IMessage message, EntityPlayer player, double range) { PacketOverlord.sendToAllAround(message,player.worldObj.provider.dimensionId, player.posX, player.posY,player.posZ, range); }
-
I have a question, my packet handler class does not have the .getInstance() and .getPacketFrom methods. Instead I send my packets in the following way PacketOverlord.sendToServer(new Packet()); where I have the following methods in my handler, should I create a get instance method and a getPacketFrom method? /** * Contains instance of SimpleNetworkWrapper and provides wrapper methods for * sending packets. */ public class PacketOverlord { private static byte packetId = 0; private static final SimpleNetworkWrapper dispatcher = NetworkRegistry.INSTANCE .newSimpleChannel(CustomMod.CHANNEL); /** * Register all packets and handlers here - this should be called during * {@link FMLPreInitializationEvent} */ public static final void preInit() { registerMessage(Packet.class); } /** * Register an {@link AbstractMessageOverlord} to the correct side */ private static final <T extends AbstractMessageOverlord<T> & IMessageHandler<T, IMessage>> void registerMessage( Class<T> clazz) { if (AbstractMessageOverlord.AbstractClientMessage.class.isAssignableFrom(clazz)) { PacketOverlord.dispatcher.registerMessage(clazz, clazz, packetId++, Side.CLIENT); } else if (AbstractMessageOverlord.AbstractServerMessage.class .isAssignableFrom(clazz)) { PacketOverlord.dispatcher.registerMessage(clazz, clazz, packetId++, Side.SERVER); } else { PacketOverlord.dispatcher.registerMessage(clazz, clazz, packetId, Side.CLIENT); PacketOverlord.dispatcher.registerMessage(clazz, clazz, packetId++, Side.SERVER); } } public static final void sendTo(IMessage message, EntityPlayerMP player) { PacketOverlord.dispatcher.sendTo(message, player); } public static void sendToAll(IMessage message) { PacketOverlord.dispatcher.sendToAll(message); } public static final void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { PacketOverlord.dispatcher.sendToAllAround(message, point); } public static final void sendToAllAround(IMessage message, int dimension, double x, double y, double z, double range) { PacketOverlord.sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range)); } public static final void sendToAllAround(IMessage message, EntityPlayer player, double range) { PacketOverlord.sendToAllAround(message, player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, range); } public static final void sendToDimension(IMessage message, int dimensionId) { PacketOverlord.dispatcher.sendToDimension(message, dimensionId); } public static final void sendToServer(IMessage message) { PacketOverlord.dispatcher.sendToServer(message); } }
-
Changing this CustomIEEPClass cIEEP = CustomIEEPClass.get(pre.entityPlayer); to CustomIEEPClass cIEEP = CustomIEEPClass.get(pre.entityPlayer); fixed the using one object to define all behaviour issue I believe, at least it did fix the other players model rendering on top of mine haha so thats great, Ya I was wondering about the dynamic updating and how to do that thanks for the event, ill definitely use that.
-
Hi Everyone, So I have a working method for changing the players model. I have a key binding event that allows for a player HUD element to be clicked on (it gets the client player and changes a couple of variables inside this players IEEP instance(on Client side) and frees up the mouse so that the player can click on the hud button). My event that changes the players model is triggered when the client player clicks a button in his HUD. This HUD button gets the client player and changes a variable inside this players IEEP that is used by my event to conditionally trigger changing the model. depending on which booleans are true and what the values are of my variables the players model changes to a different one. When I am on Single Player, everything works perfectly the models change I can scroll through the models I want, they render properly etc etc. When I am on Multiplayer and one player is in the world that player can see his/her own model just fine and can change it to be whatever they want just as in single player The problem arises when a second or third or any additional players join the server, from the perspective of one player looking at another when the second player changes his/her model nothing happens and you see default steve, when I change my model the second player disappears and becomes invisible and my model shows up but his model renders on top of mine (but not exactly) as it is always the same model (my default model with ID=25) no matter what he selects (but I think I know why). The weird bit is that when the other player moves or changes direction and I stay still. I can see his model animate, turn, move legs, arms, etc... and when I do damage to the other player his model changes texture to display the hurt texture (that reddish tinge). I realize this isnt a simple bug and am working to solve the issue but I am pretty sure its due to the following code @SubscribeEvent public void onRenderPlayerPre(RenderPlayerEvent.Pre pre) { CustomIEEPClass cIEEP = CustomIEEPClass.get(this.mc.thePlayer); // Client Side Player if (cIEEP == null) { return; } if(cIEEP.isInBattle == true){ pre.setCanceled(true); // this stops the player from rendering float modelYOffset = -1.625F; CustomIEEPClass playerProperties = CustomIEEPClass.get(pre.entityPlayer); int modelId = playerProperties.getModelId(); //default model is model with ID = 25 this is the model that always renders on top of your model in multiplayer when additional players join world Render renderCustomModel = PlayerRenderingRegistry.getRendererByModelId(modelId); //get the chosen models renderer using its id renderCustomModel.doRender(pre.entity, 0F, modelYOffset, 0F, 0F, 0.0625F); } } Now I think I know why I am always getting the default model rendering on top of my players model when an additional player changes models no matter what model he changes into, it is because my players IEEP instance has no way of knowing currently which model ID the other player chose and as such with the way this is currently set up I get the default model rendering on top of mine. This shouldnt happen though, I want the additional players model to render at their position and not my players position. So I have a couple of questions, Does anyone know why the other players default Steve model gets cancelled when I change my model? Does anyone know why their new model renders at my players position? Does anyone have any ideas as to how to provide a structure for ensuring the correct models rendering for each player? Id assume using a packet system and somehow storing my model id for each player somehow and updating all players with the packet within a range to have the correct models render. But im not sure
-
[1.7.10] Testing mod on server - with other players
Thornack replied to Thornack's topic in Modder Support
I set it to offline mode and I have my router port forwarded but cant seem to find the server not sure why, Im not sure how to use a username with a password in the dev environment, currently each time I run the client I get a random username and dont require a password -
[1.7.10] Testing mod on server - with other players
Thornack replied to Thornack's topic in Modder Support
I want to run the server and the client from my dev environment on one computer and connect from this computer to this server. Then from my other computer I want to run my mod and connect to that same server (both dev environments have the same code) -
Ok so I can run my mod on a dedicated server in eclipse but I was wondering if there is a way to connect to this server from multiple computers that have the same dev environment to test things. Has anyone tried this? I know that the only way I can connect to my server from my dev environment is to set the server properties to offline mode and the eula to true.
-
This is the last of it I commented out my event and the server loaded the world (I cant seem to be able to join it though i get a Failed to login: Invalid session (Try restarting your game) message when I click join local host server after I start up my mod from eclipse on server then on client (and try to join the server it shows up with a green checkmark though). the consol reads the following [14:45:04] [server thread/INFO]: com.mojang.authlib.GameProfile@250f0723[id=<null>,name=Player303,properties={},legacy=false] (/(AN IP ADDRESS IS PRINTED HERE) lost connection: Disconnected [14:45:11] [server thread/INFO]: com.mojang.authlib.GameProfile@4e119084[id=<null>,name=Player303,properties={},legacy=false] (/AN IP ADDRESS IS PRINTED HERE) lost connection: Disconnected [14:46:16] [server thread/INFO]: com.mojang.authlib.GameProfile@6067de8[id=<null>,name=Player941,properties={},legacy=false] (/AN IP ADDRESS IS PRINTED HERE) lost connection: Disconnected
-
Ok I have found the EULA bit and fixed that but I do have another question. I have an event handler that is crashing the server. how would I get around this. I believe it does have to be Client side only but am not positive the event handler in question @SideOnly(Side.CLIENT) public class EventPlayerInBatlle extends GuiScreen { private Minecraft mc; private static final ResourceLocation customTexture = new ResourceLocation("custommod:textures/gui/custom.png"); private static final ResourceLocation custom2Texture = new ResourceLocation("custommod:textures/gui/custom2.png"); public EventPlayerInBatlle(Minecraft mc) { super(); this.mc = mc; } // here I include the following events @SubscribeEvent(priority=EventPriority.NORMAL) public void onRenderPre(RenderGameOverlayEvent.Pre event) { } @SubscribeEvent(priority=EventPriority.NORMAL) public void RenderHUD(RenderGameOverlayEvent.Post event) { } @SubscribeEvent public void onRenderPlayerPre(RenderPlayerEvent.Pre pre) { } @SubscribeEvent public void hurt (LivingHurtEvent event){ { [EDIT] This handler is registered in a registerEvents method inside my CommonpProxy where the registerEvents Method is called inside Common Proxies Init method and Init() is called from MainModClass.java inside its @EventHandler public void init(FMLInitializationEvent event) {} method
-
I get the following crash [14:07:03] [main/WARN] [FML]: MOD HAS DIRECT REFERENCE System.exit() THIS IS NOT ALLOWED REROUTING TO FML! [14:07:03] [main/WARN] [FML]: Offendor: net/minecraft/server/gui/MinecraftServerGui$1.windowClosing(Ljava/awt/event/WindowEvent;)V [14:07:03] [main/WARN] [FML]: Use FMLCommonHandler.exitJava instead [14:07:03] [main/WARN] [FML]: ============================================================= [14:07:03] [server thread/INFO]: Starting minecraft server version 1.7.10 [14:07:03] [server thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization [14:07:03] [server thread/INFO] [FML]: MinecraftForge v10.13.2.1230 Initialized [14:07:03] [server thread/INFO] [FML]: Replaced 182 ore recipies [14:07:03] [server thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization [14:07:04] [server thread/INFO] [FML]: Searching C:\Users\{Lukasz\Desktop\modding\CustomMod_1.7.10\eclipse\mods for mods [14:07:09] [server thread/INFO] [FML]: Forge Mod Loader has identified 6 mods to load [14:07:10] [server thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, custommod] at CLIENT [14:07:10] [server thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, custommod] at SERVER [14:07:10] [server thread/INFO] [FML]: Processing ObjectHolder annotations [14:07:10] [server thread/INFO] [FML]: Found 341 ObjectHolder annotations [14:07:10] [server thread/INFO] [FML]: Configured a dormant chunk cache size of 0 [14:07:11] [server thread/INFO] [FML]: Applying holder lookups [14:07:11] [server thread/INFO] [FML]: Holder lookups applied [14:07:11] [server thread/INFO]: Loading properties [14:07:11] [server thread/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info. [14:07:11] [server thread/WARN] [FML]: Can't revert to frozen GameData state without freezing first. [14:07:11] [server thread/INFO] [FML]: Applying holder lookups [14:07:11] [server thread/INFO] [FML]: Holder lookups applied [14:07:11] [server thread/INFO] [FML]: The state engine was in incorrect state POSTINITIALIZATION and forced into state SERVER_STOPPED. Errors may have been discarded.
-
my Abstract Message Class I do have a reference to client side in my abstract message class public abstract class CustomModAbstractMessage<T extends IMessage> implements IMessage, IMessageHandler<T, IMessage>{ @Override public IMessage onMessage(T message, MessageContext ctx) { if (ctx.side == Side.CLIENT) { return handleClientMessage(Minecraft.getMinecraft().thePlayer, message, ctx); } else { return handleServerMessage(ctx.getServerHandler().playerEntity, message, ctx); } } public void sendToServer(){ PWNetworkRegistry.getNetwork().sendToServer(this); } public void sendTo(EntityPlayerMP player){ PWNetworkRegistry.getNetwork().sendTo(this, player); } public void sendToAll(){ PWNetworkRegistry.getNetwork().sendToAll(this); } public void sendToDimension(int dimensionId){ PWNetworkRegistry.getNetwork().sendToDimension(this, dimensionId); } public abstract void fromBytes(ByteBuf buf); public abstract void toBytes(ByteBuf buf); public abstract IMessage handleClientMessage(EntityPlayer player, T message, MessageContext ctx); public abstract IMessage handleServerMessage(EntityPlayer player, T message, MessageContext ctx); }
-
Hi everyone, I want to try to run my mod on a server then join the server from a client to test whether everything works. The IDE I am using is Eclipse Luna, (ive never tried this before so I may be doing something wrong) but when I hit the Run Server I get a java.lang.ClassNotFoundException: net.minecraft.client.entity.EntityClientPlayerMP The crash Report (ive included the code snippets and their methods that are found in the crash report)
-
I assume youd need packets to update the players client and posting code and what version you are on helps solve problems a lot faster
-
I know far more than what the difference is from a basic int and string... but if youre here to harass and insult me then please refrain from commenting. I may not be as good or experienced as you but I have somehow managed to recreate skyrims lockpicking, I have several highly advanced and highly optimized rendering systems, I have a very complex persistent data saving structure where i transfer an entity from log on to player to living entity to tile entity to living entity to item to another entity to holder entity and conditionally create an itemstack based on a complex animation and calculations... I dont really want to go on. There is no secret I am learning JAVA but so are you, hence why you are on these forums. You have more experience and I very much appreciate your advice and help, especially given how helpful you have been for some of the issues I have posted here. I have already complained about people harassing the less experienced on this forum. I have already asked respectfully that people like that refrain from insulting people, and instead if they notice an issue they should direct them to the appropriate source of information. Anyways I simply didnt notice that field you mentioned and now have my class working. So thanks alot, I really do appreciate it. But keep in mind this forums title, "Modder Support" discouraging people from modding just because they have made a mistake (and mistakes happen to everyone) doesnt live up to this forums name. Oh and FYI if I rearrange my ItemPickupEvent to the following - The item persists not sure why it is probably something I am doing up top but both classes have the exact same code above this so I dont know what the issue is but it doesnt matter. I found my solution. @SubscribeEvent public void OnItemPickup(ItemPickupEvent e){ NBTTagCompound caughtEntityNBT = itemStack.stackTagCompound.getCompoundTag("caughtEntity"); String playerName = itemStack.stackTagCompound.getString("playerName"); String mobName = caughtEntityNBT.getString("mobName"); if (!player.worldObj.isRemote){ tryToAddMobToParty(caughtEntityNBT); e.pickedUp.setDead(); itemStack = null; e.isCanceled(); } }
-
However this does work @SubscribeEvent public void OnItemPickup(EntityItemPickupEvent e){ NBTTagCompound caughtEntityNBT = itemStack.stackTagCompound.getCompoundTag("caughtEntity"); String playerName = itemStack.stackTagCompound.getString("playerName"); String mobName = caughtEntityNBT.getString("mobName"); if (!player.worldObj.isRemote){ tryToAddMobToParty(caughtEntityNBT); e.item.setDead(); itemStack = null; e.setCanceled(true); } } now why would that be? all other lines of code above this are exactly the same (i omitted some cause this is pretty complicated stuff and there is a lot of lines)... the only difference between this and the other post is I subscribe EntityItemPickupEvent rather than ItemPickupEvent (both are registered to their appropriate buses n both fire) and I do e.item.setDead(); itemStack = null; e.setCanceled(true); rather than e.isCanceled(); itemStack = null; e.pickedUp.setDead();
-
that is the itemstack that I generated when my entity impacted my target entity. it exists it has NBT data, the data is added to the player but i cannot set it to dead