Jump to content

Belpois

Members
  • Posts

    128
  • Joined

  • Last visited

Everything posted by Belpois

  1. Follow this tutorial, it should help you on pipes. Also from what I see you need to implement the getCollisionBoundingBoxFromPool() to set your custom collisions. Also add @Override on top of Override methods getCollisionBoundingBoxFromPool() and getCollisionBoundingBoxFromPool() are both overridden methods.
  2. Perform a ray trace from the Mob's forward looking vector, and check if the hit entity is a Living Entity MovingObjectPosition movingObjectPosition = par5EntityPlayer.rayTrace(par1, par2); Entity entity = movingObjectPosition.entityHit; if(entity != null) { // Implement your checks and logic here }
  3. Aaaa crud forgot primed tnt's are entities, I might try to get the repo and run it on my pc when I get home, been through the code on git hub and it seems fine...
  4. This is one of my custom renderers from a mod I'm working on, this is all executed on preInit @Override public void registerCustomBlockRenderers() { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPaintableBlockEntity.class, new TileEntityPaintableBlockRenderer()); GameRegistry.registerTileEntity(TileEntityPaintableBlockEntity.class, "tileEntityPaintableBlock"); Reference.PAINTER_BLOCK_RENDERING_HANDLER_ID = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new PainterBlockRenderingHandler(Reference.PAINTER_BLOCK_RENDERING_HANDLER_ID)); } Try and replace your code with mine, see how it works... I think you need to bind the entity with the bindTileEntitySpecialRenderer
  5. Are you sure it's never called? if this is called RenderingRegistry.registerEntityRenderingHandler(RozNukePrimed.class, new RenderRozNukePrimed()); then the constructor for RenderRozNukePrimed is called, even if the registerEntityRenderingHandler fails the method parameters are executed before. Put a debug line on the "RenderingRegistry.registerEntityRenderingHandler(RozNukePrimed.class, new RenderRozNukePrimed());" line and check if that line is getting executed, because I have a feeling it's not.
  6. Try using this tutorial. https://theancientminecrafter.wordpress.com/2014/05/11/entity-or-mob-tutorial/ I think your missing the data watcher in your code, the client will show that the entity has 300 health but the server would have not updated yet and still think that the entity has the default health.
  7. Hey, not sure if you know this or not but minecraft works on a model that revolves around events, all items and entities are static (All the same instances) what makes them different is either the Item Stack or Tile Entity based on location in world. Having the an instance of a tile entity in an item will cause very strange behavior in minecraft. As coolAlias and Mitchellbrine wrote, use NBT's for those, I suggest reading up on these tutorials: Wuppy29 http://www.wuppy29.com/minecraft/modding-tutorials/forge-modding/#sthash.8TcgkQuu.dpbs Pahimar http://www.pahimar.com/tutorials/lets-mod/ When in doubt I usually check their tutorials out, also you might also be interested in reading up on some Java Best Practices Documentation, just Google "Java Best Coding Practices" and you'll find loads of info on how to make your code optimal, albeit it has nothing to do with Forge or Minecraft, making you code more optimal and neatly layed out using approved practices will make your life easier while debugging especially in a code base that has been decompiled and has loads of obfuscated methods and fields. Lazy Link to Google https://www.google.com/search?q=java+best+coding+practices&ie=utf-8&oe=utf-8 Speaking from experience here, I have written code that after a month I couldn't recognize my self... My way around it is to comment all my classes and some of the complicated methods this way even when you are asking for help people read the comments and instantly know what the particular piece of code is. I hope these will help you in the future as they certainly did for me
  8. Mhmm, ray tracing should work and give you the coordinates but I once saw someone using a little trick to spawn an entity at the players position + n number of blocks used in one of my experimental mods (If i remember correctly it works ). int n = 5; Vec3 playerLookVector = player.getLookVec(); if (EntityList.stringToClassMapping.containsKey("entity_name")) { EntityLiving entityToSpawn = (EntityLiving) EntityList.createEntityByName("entity_name", worldObj); double spawnX = player.posX+n*playerLookVector.xCoord; double spawnZ = player.posZ+n*playerLookVector.zCoord; double spawnY = worldObj.getHeightValue((int)spawnX, (int)spawnZ); entityToSpawn.setLocationAndAngles(spawnX, spawnY, spawnZ, MathHelper.wrapAngleTo180_float(rand.nextFloat() * 360.0F), 0.0F); worldObj.spawnEntityInWorld(entityToSpawn); } It's not precise but got the job done, if you want to go for the Ray Trace route: If you spawn the entity at close range does it spawn at the crosshair? At a distance the ray trace might be hitting something else and it gives you the wrong coordinates. Remember at a distance the pixel the mouse is on might be two blocks or more... Even if the chunk is not loaded it might give you incorrect values.
  9. Thanks man but strangely enough it doesn't print out the errors when registering... must be on a log level that the logger is not printing (Time to mess with the log4j's configs )
  10. Ahh crud, thats why then... Thanks Strangely enough tough the register still works, as each time I register the method is called. Any idea about that?
  11. I Commented it, the code in question is marked with a comment "(Code in Question)" public class GuiInnerScreenContainer extends GuiScreen { // A list with all the inner screens protected ArrayList<GuiInnerScreen> innerScreenList; // The current visible inner screen protected GuiInnerScreen visibleGuiInnerScreen; public GuiInnerScreenContainer() { this.innerScreenList = new ArrayList<GuiInnerScreen>(); this.visibleGuiInnerScreen = null; } @Override public void initGui() { // Calling the gui update method, this will update the sub gui's this.updateInnerGui(); } @Override public void mouseClickMove(int mouseX, int mouseY, int buttonClicked, long timeSinceLastClick) { super.mouseClickMove(mouseX, mouseY, buttonClicked, timeSinceLastClick); if (this.visibleGuiInnerScreen == null) { return; } this.visibleGuiInnerScreen.mouseClickMove(mouseX, mouseY, buttonClicked, timeSinceLastClick); } @Override protected void mouseClicked(int mouseX, int mouseY, int buttonClicked) { super.mouseClicked(mouseX, mouseY, buttonClicked); if (this.visibleGuiInnerScreen == null) { return; } this.visibleGuiInnerScreen.mouseClicked(mouseX, mouseY, buttonClicked); } @Override protected void mouseMovedOrUp(int mouseX, int mouseY, int buttonClicked) { super.mouseMovedOrUp(mouseX, mouseY, buttonClicked); if (this.visibleGuiInnerScreen == null) { return; } this.visibleGuiInnerScreen.mouseMovedOrUp(mouseX, mouseY, buttonClicked); } @Override public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) { this.drawDefaultBackground(); if (this.visibleGuiInnerScreen == null) { return; } this.visibleGuiInnerScreen.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_); } @Override public void onGuiClosed() { super.onGuiClosed(); if (this.visibleGuiInnerScreen == null) { return; } this.visibleGuiInnerScreen.onGuiClosed(); } public void updateInnerGui() { // Check if the current gui is available, if not this is the first time we entered this method. if (this.visibleGuiInnerScreen == null) { // Show the first gui. this.showInnerGui(0); // Return as we already initialized it. return; } // Setting the GUI's inner reference values. this.visibleGuiInnerScreen.mc = this.mc; this.visibleGuiInnerScreen.width = this.width; this.visibleGuiInnerScreen.height = this.height; this.visibleGuiInnerScreen.allowUserInput = this.allowUserInput; // Initializing the GUI's this.visibleGuiInnerScreen.initGui(); } /* * Selects which inner gui to show (Code in question) */ public void showInnerGui(int guiId) { GuiInnerScreen newVisibleGuiScreen = null; for (GuiInnerScreen guiInnerScreen : this.innerScreenList) { // Fetch the requested gui by id. if (guiInnerScreen.guiId != guiId) { // If not found we continue. continue; } // When found we set the gui and break. newVisibleGuiScreen = guiInnerScreen; break; } // This is a check in the case we did not find the GUI. if (newVisibleGuiScreen == null) { return; } // If the a gui is already visible. if (this.visibleGuiInnerScreen != null) { // Call the onHidden this.visibleGuiInnerScreen.onHidden(); // and unregister the instance. FMLCommonHandler.instance().bus().unregister(this.visibleGuiInnerScreen); } // Set up some references. this.visibleGuiInnerScreen = newVisibleGuiScreen; this.visibleGuiInnerScreen.mc = this.mc; this.visibleGuiInnerScreen.width = this.width; this.visibleGuiInnerScreen.height = this.height; this.visibleGuiInnerScreen.allowUserInput = this.allowUserInput; // Usual init this.visibleGuiInnerScreen.initGui(); // Register the gui with the bus. FMLCommonHandler.instance().bus().register(this.visibleGuiInnerScreen); // Call the on visible. this.visibleGuiInnerScreen.onVisible(); } }
  12. EDIT: Solved, never register instances to receive events outside of init methods This is a rather straightforward problem to explain... I registered an instance to receive events and then when the instance is not being used (not destroyed, may be used again in the future) I am unregistering it. FMLCommonHandler.instance().bus().register(instance); FMLCommonHandler.instance().bus().unregister(instance); When unregistering the game crashed, below you can find the crash dump. and yes I am registering it first Any ideas? All the code, with comments public class GuiInnerScreenContainer extends GuiScreen { // A list with all the inner screens protected ArrayList<GuiInnerScreen> innerScreenList; // The current visible inner screen protected GuiInnerScreen visibleGuiInnerScreen; public GuiInnerScreenContainer() { this.innerScreenList = new ArrayList<GuiInnerScreen>(); this.visibleGuiInnerScreen = null; } @Override public void initGui() { // Calling the gui update method, this will update the sub gui's this.updateInnerGui(); } @Override public void mouseClickMove(int mouseX, int mouseY, int buttonClicked, long timeSinceLastClick) { super.mouseClickMove(mouseX, mouseY, buttonClicked, timeSinceLastClick); if (this.visibleGuiInnerScreen == null) { return; } this.visibleGuiInnerScreen.mouseClickMove(mouseX, mouseY, buttonClicked, timeSinceLastClick); } @Override protected void mouseClicked(int mouseX, int mouseY, int buttonClicked) { super.mouseClicked(mouseX, mouseY, buttonClicked); if (this.visibleGuiInnerScreen == null) { return; } this.visibleGuiInnerScreen.mouseClicked(mouseX, mouseY, buttonClicked); } @Override protected void mouseMovedOrUp(int mouseX, int mouseY, int buttonClicked) { super.mouseMovedOrUp(mouseX, mouseY, buttonClicked); if (this.visibleGuiInnerScreen == null) { return; } this.visibleGuiInnerScreen.mouseMovedOrUp(mouseX, mouseY, buttonClicked); } @Override public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) { this.drawDefaultBackground(); if (this.visibleGuiInnerScreen == null) { return; } this.visibleGuiInnerScreen.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_); } @Override public void onGuiClosed() { super.onGuiClosed(); if (this.visibleGuiInnerScreen == null) { return; } this.visibleGuiInnerScreen.onGuiClosed(); } public void updateInnerGui() { // Check if the current gui is available, if not this is the first time we entered this method. if (this.visibleGuiInnerScreen == null) { // Show the first gui. this.showInnerGui(0); // Return as we already initialized it. return; } // Setting the GUI's inner reference values. this.visibleGuiInnerScreen.mc = this.mc; this.visibleGuiInnerScreen.width = this.width; this.visibleGuiInnerScreen.height = this.height; this.visibleGuiInnerScreen.allowUserInput = this.allowUserInput; // Initializing the GUI's this.visibleGuiInnerScreen.initGui(); } /* * Selects which inner gui to show (Code in question) */ public void showInnerGui(int guiId) { GuiInnerScreen newVisibleGuiScreen = null; for (GuiInnerScreen guiInnerScreen : this.innerScreenList) { // Fetch the requested gui by id. if (guiInnerScreen.guiId != guiId) { // If not found we continue. continue; } // When found we set the gui and break. newVisibleGuiScreen = guiInnerScreen; break; } // This is a check in the case we did not find the GUI. if (newVisibleGuiScreen == null) { return; } // If the a gui is already visible. if (this.visibleGuiInnerScreen != null) { // Call the onHidden this.visibleGuiInnerScreen.onHidden(); // and unregister the instance. FMLCommonHandler.instance().bus().unregister(this.visibleGuiInnerScreen); } // Set up some references. this.visibleGuiInnerScreen = newVisibleGuiScreen; this.visibleGuiInnerScreen.mc = this.mc; this.visibleGuiInnerScreen.width = this.width; this.visibleGuiInnerScreen.height = this.height; this.visibleGuiInnerScreen.allowUserInput = this.allowUserInput; // Usual init this.visibleGuiInnerScreen.initGui(); // Register the gui with the bus. FMLCommonHandler.instance().bus().register(this.visibleGuiInnerScreen); // Call the on visible. this.visibleGuiInnerScreen.onVisible(); } }
  13. Minecraft only allows bound boxes as 6 sided cubes and not complicated shapes, even stairs have a protruding bound box, its only the ray tracing that works on the actual rendered object. Try Raytracing http://gamedev.stackexchange.com/questions/59858/how-to-find-the-entity-im-looking-at But the collision box will have to be custom rendered, for it to be a tight fit with the actual object.
  14. As far as I know, minecraft only supports bounds that are in a cube shape and not complicated shapes. Not unless you implement you own bounds processor.
  15. in the Draw method type this.drawTexturedModalRect() and fill in the parameters, dont forget to bind the texture before calling the method. The logic I think you might be looking for is that that you increase the length or height of the displaying texture according to the amount of energy stored.
  16. It's quite simple to use, all you need to do apart from adding the files to you project is implement or extend the provided interfaces and classes on your own tile entities. If implemented correctly any mod that uses this API will work with yours For example, if you implement the "IEnergProvider" the tile entity should be a provider of energy and other tile entities will use it to receive energy from it. Now the actual implementation is in your hands, RFApi only gives you the basic interfaces. P.S. Make sure that the files beginning with "I" are never altered as they are the interfaces between mods, changing them will break compatibility
  17. You could also take a look at some other mods and see how they do it I happen to like using the Mekanism mod as a reference, it has a lot of cool stuff and it also incorporates API's to use all sort of Mod Power (MJ/RF) https://github.com/aidancbrady/Mekanism
  18. So after a bit of variable watching and swearing at my PC for not working, this is what I found. TLDR at the bottom of post I put a watch on these four instances and methods: FMLCommonHandler.instance().getEffectiveSide() FMLCommonHandler.instance().getSide() FMLClientHandler.instance().getClient().isSingleplayer() FMLClientHandler.instance().getServer().isPublic When remote was true (client), getEffectiveSide was "Side.CLIENT" but getSide() was "Side.Server" which messed up the whole channel, even my GUI's where not working as they were trying to execute on the server. This code below is found in the FMLNetworkHandler, checks if client to open the GUI, as it tried to check if its client, theMC internal state was server and it messed up. FMLCommonHandler.instance().getSide().equals(Side.CLIENT) Now obviously the dedicated server was working perfectly as everything is executed server side, and I asked my self what was wrong in the execution path of my Client Debug and my Server Debug Environments? Two words, "Watched List"... I had this expression in the watches list "FMLClientHandler.instance().getServer().isPublic" to check if the current world is open to LAN but "isPublic" is only available when you cast the return of getServer(), which is MinecraftServer to IntegratedServer as the "isPublic" field only exists in IntegratedServer... What I guess is that the exception was causing the debugger to act weirdly and throw an exception that the IDE catches but messed up the MC State, and since the watches where only on the clients debugger the server worked normally. Weird huh! Sorry for the long post. TLDR Had watched expression throwing an exception messing up Minecraft's execution path, at least thats what I think. Can I cry now? :'(
  19. This is the heartbeat class, client and server are the same, the difference is the name: public class ClientHeartbeat implements IMessage { private String name = ""; private int secretNumber = 0; public ClientHeartbeat() { } public ClientHeartbeat(String name, int secretNumber) { this.name = name; this.secretNumber = secretNumber; } @Override public void fromBytes(ByteBuf byteBuf) { this.name = this.readString(byteBuf); this.secretNumber = byteBuf.readInt(); } @Override public void toBytes(ByteBuf byteBuf) { this.writeString(byteBuf, this.name); byteBuf.writeInt(this.secretNumber); } public void writeString(ByteBuf output, String s) { output.writeInt(s.getBytes().length); output.writeBytes(s.getBytes()); } public String readString(ByteBuf byteBuf) { return new String(byteBuf.readBytes(byteBuf.readInt()).array()); } public static class Handler implements IMessageHandler<Heartbeat, IMessage> { @Override public IMessage onMessage(Heartbeat heartbeat, MessageContext messageContext) { LogHelper.info("PP Client Heartbeat"); return null; } } }
  20. Hey, so I am trying to send a packet from the client to the server which contains a simple heartbeat test (Wrote this to debug), note that server to client works Here is the code: Common Proxy NetMgr.channel.registerMessage(ServerHeartbeat.Handler.class, ServerHeartbeat.class, 0, Side.SERVER); NetMgr.channel.registerMessage(ClientHeartbeat.Handler.class, ClientHeartbeat.class, 1, Side.CLIENT); On item right click if (world.isRemote) { // Testing parameters [par1: random string, par2: random number] NetMgr.channel.sendToServer(new Heartbeat("This is client", ); } Heartbeat Class (Same for both Server and Client, the difference is the class name) public class ClientHeartbeat implements IMessage { private String name = ""; private int secretNumber = 0; public ClientHeartbeat() { } public ClientHeartbeat(String name, int secretNumber) { this.name = name; this.secretNumber = secretNumber; } @Override public void fromBytes(ByteBuf byteBuf) { this.name = this.readString(byteBuf); this.secretNumber = byteBuf.readInt(); } @Override public void toBytes(ByteBuf byteBuf) { this.writeString(byteBuf, this.name); byteBuf.writeInt(this.secretNumber); } public void writeString(ByteBuf output, String s) { output.writeInt(s.getBytes().length); output.writeBytes(s.getBytes()); } public String readString(ByteBuf byteBuf) { return new String(byteBuf.readBytes(byteBuf.readInt()).array()); } public static class Handler implements IMessageHandler<Heartbeat, IMessage> { @Override public IMessage onMessage(Heartbeat heartbeat, MessageContext messageContext) { LogHelper.info("PP Client Heartbeat"); return null; } } } Client Error Extra Notes, so I debugged the code and led me to a java class named "FMLCommonHandler" -> "FMLServerHandler", seems that the code is executing to this method: public NetworkManager getClientToServerNetworkManager() { return this.sidedDelegate.getClientToServerNetworkManager(); } public NetworkManager getClientToServerNetworkManager() { throw new RuntimeException("Missing"); } Hope that extra code helps , Thanks!
  21. The code looks fine at first glance, maybe trying to retro fit the IItemRenderer code to work with your GUI this way you use MC pipeline for rendering objects. To better clarify that I am understanding what your are doing, you are trying to render a normal 3D object on the screen to preview it. Correct?
  22. Spelling mistake on actionPerformed method your wrote "actionPreformed", should be Performed P.S. This does not relate with your problem but, the super.initGui call is useless in the initGuid() method as it's super implementation has no body
  23. Yes, that's true the Sides thing can be left out. Unless you are updating your NBT Tag on one of the Minecraft Events, such as OnRightClick or block activated those fire on both the server and the client.
  24. Make sure to set NBT Tags when the server is handling the code. Side side = FMLCommonHandler.instance().getEffectiveSide(); if (side == Side.SERVER) { // Update the NBT Tags } Simply send the key pressed event to the server, update the NBT Tags on the server and the client should be updated automatically. Some pseudo code (Server side): EntityPlayerMP ep = getEntityPlayerMP(); PlayerInventory pi = ep.inventory; ItemStack is = pi.getCurrentItem(); if(!is.hasTagCompound()) { is.stackTagCompound = new NBTTagCompound(); } NBTTagCompound nbttc = is.stackTagCompound; nbttc.setString("somthing", "something"); Hope this helps P.S. Now sending the key event to the server and getting the player from that event is up to you as I do not know how your code looks like, but usually Network Packets send the EntityPlayerMP with them.
×
×
  • Create New...

Important Information

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