Jump to content

Samalot

Members
  • Posts

    23
  • Joined

  • Last visited

Posts posted by Samalot

  1. I would have thought this would have been quite a simple problem to find the answer to online, but after a couple hours of searching... I can't find a single thing.

     

    Image:

     

    sKXr6Tq.png

     

     

    Upon drawing multiple textures, the shading of the later does not match the source file.

     

    Code:

     

     

    /*--------------- Background ---------------*/
    @Override
    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
    {		
    
    	//Variables
    	int marginHorizontal = (width - xSize) / 2;
    	int marginVertical = (height - ySize) / 2;
    	GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    
    	//Draw main gui
    	mc.getTextureManager().bindTexture(infusatronGuiTextures);
    
    
    	drawTexturedModalRect(marginHorizontal, marginVertical, 0, 0, xSize, ySize);
    
    	//If search mode, draw catalogue
    	if(searchMode)
    	{
    		mc.getTextureManager().bindTexture(infusatronSearchTextures);
    		drawTexturedModalRect(marginHorizontal, marginVertical, 0, 0, xSize, ySize);
    		searchTextField.drawTextBox();
    	}
    }
    

     

     

     

    I am presuming I just need to refresh something in the frontrenderer? or GL11? But I can't find (or figure out) what.

     

    Any idea?

     

    Thanks in advance.

  2. I feel like I am being a moron...

     

    is the location that each Slot is drawn in a custom GUI determined from the custom container?

    I have dug through the source code and the only mention of coordinates I can find about drawing the slots is from the container class.

     


     

    With that being said:

     

    • What exactly are the coordinates measured in? I presume pixels, but where from - the origin?
    • In the GUI class, it is possible to reference width and height, so that you can draw each box relative to the screen size... however, if you aren't drawing the slots relative to this, there isn't much point
    • Is there a way to draw slots onto a gui respective to the size of the clients screen?

     

    Essentially, I have multiple GUI components that have different widths/heights and would like them all (and their corresponding slot spaces) to be in the centre of the clients screen. This is easy for the GUI components (width / height), but I cant figure out how to achieve it with slots. 

     

    Thanks in advance.

     


     

    From CustomContainer (extends Container.class)

     

     

    for (int i = 0; i < 3; ++i)
            {
                for (int j = 0; j < 9; ++j)
                {
                    addSlotToContainer(new Slot(parInventoryPlayer, j+i*9+9, 
                    8+j*18, 184+i*18));
                }
            }
    

     

     

     

    From Container.class:

     

     

    protected Slot addSlotToContainer(Slot slotIn)
        {
            slotIn.slotNumber = this.inventorySlots.size();
            this.inventorySlots.add(slotIn);
            this.inventoryItemStacks.add((Object)null);
            return slotIn;
        }
    

     

     

     

    From Slot.class:

     

     

    public Slot(IInventory inventoryIn, int index, int xPosition, int yPosition)
        {
            this.inventory = inventoryIn;
            this.slotIndex = index;
            this.xDisplayPosition = xPosition;
            this.yDisplayPosition = yPosition;
        }
    

     

     

     

     

     

  3. Somehow it is now working:

     

    J4FO2Qf.png

     

    current code:

     

     

    {
        "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
        "textures": {
            
            "texture0": "lazarus:blocks/infusatron/bn",
            "texture1": "lazarus:blocks/infusatron/be",
            "texture2": "lazarus:blocks/infusatron/bs",
            "texture3": "lazarus:blocks/infusatron/bw",                  
            "texture4": "lazarus:blocks/infusatron/bu",
            "texture5": "lazarus:blocks/infusatron/bd",     
            "texture6": "lazarus:blocks/infusatron/un",
            "texture7": "lazarus:blocks/infusatron/ue",
            "texture8": "lazarus:blocks/infusatron/us",
            "texture9": "lazarus:blocks/infusatron/uw",
            "texture10": "lazarus:blocks/infusatron/uu",
            "texture11": "lazarus:blocks/infusatron/ud"
        },
        "elements": [
            {
                "name": "Bottom",
                "from": [ 1.0, 0.0, 4.0 ], 
                "to": [ 14.0, 12.0, 12.0 ], 
                "faces": {
                    "north": { "texture": "#texture0", "uv": [ 0.0, 0.0, 14.0, 12.0 ]},
                    "east": { "texture": "#texture1", "uv": [ 0.0, 0.0, 8.0, 12.0 ] },
                    "south": { "texture": "#texture2", "uv": [ 0.0, 0.0, 14.0, 12.0 ] },
                    "west": { "texture": "#texture3", "uv": [ 0.0, 0.0, 8.0, 12.0 ] },
                    "up": { "texture": "#texture4", "uv": [ 0.0, 0.0, 14.0, 8.0 ] },
                    "down": { "texture": "#texture5", "uv": [ 0.0, 0.0, 14.0, 8.0 ] }
                }
            },
            
            {
                "name": "Screen",
                "from": [ 0.0, 12.0, 3.0 ], 
                "to": [ 10.0, 26.0, 13.0 ], 
                "faces": {
                    "north": { "texture": "#texture6", "uv": [ 0.0, 0.0, 10.0, 14.0 ] },
                    "east": { "texture": "#texture7", "uv": [ 0.0, 0.0, 10.0, 14.0 ] },
                    "south": { "texture": "#texture8", "uv": [ 0.0, 0.0, 10.0, 14.0 ] },
                    "west": { "texture": "#texture9", "uv": [ 0.0, 0.0, 10.0, 14.0 ] },
                    "up": { "texture": "#texture10", "uv": [ 0.0, 0.0, 10.0, 10.0 ] },
                    "down": { "texture": "#texture11", "uv": [ 0.0, 0.0, 10.0, 10.0 ] }
                }
            }
        ]
    }
    

     

     

    I can see Zero difference between that and what I had before

  4. I am having trouble loading in images to a JSON model, the files are there, but they are not loading. I get the following error:

     

    error

     

     

    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]: +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]: The following texture errors were found.
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]: ==================================================
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]:   DOMAIN lazraus
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]: --------------------------------------------------
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]:   domain lazraus is missing 7 textures
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]:     domain lazraus is missing a resource manager - it is probably a side-effect of automatic texture processing
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]: -------------------------
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]:     The missing resources for domain lazraus are:
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/un.png
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/us.png
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/bd.png
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/uu.png
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/ue.png
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/ud.png
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/uw.png
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]: -------------------------
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]:     No other errors exist for domain lazraus
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]: ==================================================
    [16:33:40] [Client thread/ERROR] [TEXTURE ERRORS]: +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
    

     

     


    Here is the JSON file:

     

     

    {
        "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
        "textures": {
            
            "texture0": "lazarus:blocks/infusatron/bn",
            "texture1": "lazarus:blocks/infusatron/be",
            "texture2": "lazarus:blocks/infusatron/bs",
            "texture3": "lazarus:blocks/infusatron/bw",                  
            "texture4": "lazarus:blocks/infusatron/bu",
            "texture5": "lazraus:blocks/infusatron/bd",     
            "texture6": "lazraus:blocks/infusatron/un",
            "texture7": "lazraus:blocks/infusatron/ue",
            "texture8": "lazraus:blocks/infusatron/us",
            "texture9": "lazraus:blocks/infusatron/uw",
            "texture10": "lazraus:blocks/infusatron/uu",
            "texture11": "lazraus:blocks/infusatron/ud"
        },
        "elements": [
            {
                "name": "Bottom",
                "from": [ 1.0, 0.0, 4.0 ], 
                "to": [ 14.0, 12.0, 12.0 ], 
                "faces": {
                    "north": { "texture": "#texture0", "uv": [ 0.0, 0.0, 14.0, 12.0 ]},
                    "east": { "texture": "#texture1", "uv": [ 0.0, 0.0, 8.0, 12.0 ] },
                    "south": { "texture": "#texture2", "uv": [ 0.0, 0.0, 14.0, 12.0 ] },
                    "west": { "texture": "#texture3", "uv": [ 0.0, 0.0, 8.0, 12.0 ] },
                    "up": { "texture": "#texture4", "uv": [ 0.0, 0.0, 14.0, 8.0 ] },
                    "down": { "texture": "#texture5", "uv": [ 0.0, 0.0, 14.0, 8.0 ] }
                }
            },
            
            {
                "name": "Screen",
                "from": [ 0.0, 12.0, 3.0 ], 
                "to": [ 10.0, 26.0, 13.0 ], 
                "faces": {
                    "north": { "texture": "#texture6", "uv": [ 0.0, 0.0, 10.0, 14.0 ] },
                    "east": { "texture": "#texture7", "uv": [ 0.0, 0.0, 10.0, 14.0 ] },
                    "south": { "texture": "#texture8", "uv": [ 0.0, 0.0, 10.0, 14.0 ] },
                    "west": { "texture": "#texture9", "uv": [ 0.0, 0.0, 10.0, 14.0 ] },
                    "up": { "texture": "#texture10", "uv": [ 0.0, 0.0, 10.0, 10.0 ] },
                    "down": { "texture": "#texture11", "uv": [ 0.0, 0.0, 10.0, 10.0 ] }
                }
            }
        ]
    }
    

     

     


    Here is a screenshot of the current situation

     

     

    nJW0QDn.png

     

     

    (I know it is called 'bd1.png' when it should be 'bd' this is not the problem, I have since switched it back - it was from a debug attempt.)


     

    • As you can see in the screenshot in exhibit (A) - 'un.png' does not load BUT 'bn.png' does.
    • As you can see in exhibit (B) - both the code for 'un' and 'bn' are exactly the same (except for the file name) - the path to the image area is the same
    • As you can see in the screenshot in exhibit © - All the files are there, so they should not be 'missing'
    • If you replace all of the rendering images with 'bn' the shapes do load - so it is not like the elements are incorrect, just the loading of the textures

     

    I have no idea what to do, any help would be greatly appreciated!

     

    Thanks,

     

    Sam

     


    EDIT #1:

     

    When I delete all the images from the directory I get the following error:

     

     

    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: The following texture errors were found.
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: ==================================================
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:   DOMAIN lazraus
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: --------------------------------------------------
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:   domain lazraus is missing 7 textures
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:     domain lazraus is missing a resource manager - it is probably a side-effect of automatic texture processing
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: -------------------------
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:     The missing resources for domain lazraus are:
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/bd.png
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/un.png
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/us.png
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/uu.png
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/ue.png
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/ud.png
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/uw.png
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: -------------------------
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:     No other errors exist for domain lazraus
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: ==================================================
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: ==================================================
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:   DOMAIN lazarus
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: --------------------------------------------------
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:   domain lazarus is missing 5 textures
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:     domain lazarus has 1 location:
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       mod lazarus resources at C:\Users\Sam Humby\Desktop\Minecraft Mod\Git\Lazarus\bin
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: -------------------------
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:     The missing resources for domain lazarus are:
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/bw.png
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/bn.png
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/bs.png
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/be.png
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:       textures/blocks/infusatron/bu.png
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: -------------------------
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]:     No other errors exist for domain lazarus
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: ==================================================
    [16:54:46] [Client thread/ERROR] [TEXTURE ERRORS]: +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
    

     

     

     

    Is there a reason why the images would be split into two blocks like that? they correspond with the textures that fail to load..

  5. I am creating a vending machine, which I would like to have a model that extends two blocks high.

     

     

     

    I have done some research on this, and initially built code which split the  block up into two sub blocks - the idea being that I would texture each. However - I am interested in exploring the option of doing it within one block.

     

     

     

    I am fairly sure I understand how the JSON block model works - here is my potential code:

     

     

    {
        "textures": {
            "texture0": "lazarus:blocks/infusatron/infusatron"
        },
        "elements": [
            {
                "from": [ 1.0, 0.0, 4.0 ],
                "to": [ 15.0, 12.0, 12.0 ],
                "faces": {
                    "down": { "uv": [ 0, 0, 55, 31   ], "texture": "#texture0"},
                    "up":   { "uv": [ 0, 32, 55, 63  ], "texture": "#texture0"},
                    "north":{ "uv": [ 56, 0, 111, 31  ], "texture": "#texture0"},
                    "south":{ "uv": [ 112, 0, 167, 31  ], "texture": "#texture0"},
                    "west": { "uv": [ 168, 0, 200, 31  ], "texture": "#texture0"},
                    "east": { "uv": [ 201, 0, 9, 232  ], "texture": "#texture0"}
                }
            }
        ]
    }
    

     

     

     

    I would like to map this image onto the model:

     

     

    Vr9dDm8.png

     

     

     

    But - I get this rendering error:

     

     

    wq5IIpQ.png

     

     

     

    From what I understand, this is likely due to 'UV' extending 0-16, but I need my textures to have more detail than 16x16 pixels and would ideally like to avoid having to split the model up into 100 different cubes.

     

    Is there a way to achieve what I desire? Have I (like usual) completely missed the obvious?

     

    Thanks for your time,

     

    Sam

  6. I removed the restriction and received an error, seems I interpreted it wrong! Thanks for the help.

     

    The reason I cannot just use the onUpdate method is that the item has to also work from inside a 'token pouch'.

    (I could always just write a bunch of if statements inside of the pouch code, but I thought this approach might be cleaner.)

     

    EDIT:

     

    Error = "java.lang.NoClassDefFoundError: net/minecraft/client/multiplayer/WorldClient"

  7. So, this is more of a brainstorm - I have some general idea about how I could accomplish some implementation of this. However, I am always keen to hear what people think and if they have any better/more sophisticated methods!

     

    Item: A token which applies the swiftness potion buff when in close proximity (4 blocks) from a Mob.

     

    player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 50, 1));

     

    Issues: The event I was going to use onPlayerUpdate(PlayerTickEvent event) is @SideOnly(Side.CLIENT)

     

    My initial thought would be to just do the logic client-side and send a flag to the server (via a packet?) to apply the potion effect?

     

    Or, maybe have an event which runs server-side? I can't seem to find a 'tick event' from the forge bus, but some research shows there may be one on the FML Bus (however most of this info is from around 2012, so it could be out-dated).

     

    So my real question is - Do you think this is the right approach? Is sending a packet potentially tens of times every tick an issue? Or is there some other way I have completely missed?

     

    Thanks in advance! 

     

    Edit: Upon reflection, I realise that the title is pretty poor - my apologies.

  8. Thanks for all of that! :)

     

    (and for being patient, I get the impression there must be 10 people like my asking similar questions each day)

    I'll have a read through the recourses you linked!

     

    As, for why I don't just check the players inventory each time - ill start doing that now!

     

    The issues was that these tokens are not just stored in the players inventory, but in other inventories too - such as a token pouch! (however, the more I think about it, the more I realise it is a non-issue)

     

  9.  

    First and foremost, I have been criticized in the past for not researching enough before posting; this is not the case – my question may seem simple to some, but I can assure you that my misunderstanding is no because I can’t be bothered to search for an answer (I have been all day). My problems usually stem from having no idea what to search for - feel free to give me any points and be as harsh as you want! I want to learn!

     

     

    From what I understand, certain blocks of code (in my case - onEntityGetHurt event) should be run on the server only and vise versa. You essentially have the code for the server/client in one and control access with @Side or Remote world.

     

    But how does the client interact with the server? - I am aware of packets, but have been avoiding them somewhat. Is a packet sent over the web? from the client's pc to the server?

     

    I chose to share information between Client/Server sections of code using NBT data stored on the player.

     

    Here is my problem

    I have a mod:

    • Adds a suite of tokens to the game.
    • Tokens provide a passive effect to the player, you just need to have them on your inventory to get the effect.
    • The effects are not necessarily potion effects, for example - prevent block damage from explosions (tapping into the event bus).

     

    The game (client and server) has to know which tokens the player currently has - I opted to do this by adding a new NBT Tag to the player for each token:

     

    EntityPlayer player = (EntityPlayer) event.entityLiving; /*Get player*/
    
    tags = player.getEntityData(); /*Get tag cloud*/
    
    tags.setBoolean("amplifyingToken", false); /*Create a new tag*/
    
    ...
    
    player.writeToNBT(tags); /*Save the tag cloud*/
    

     

    Every tick (on player update event), the players NBT tags are updated to match the inventory - this is done CLIENT SIDE only.

     

    @SubscribeEvent
    @SideOnly(Side.CLIENT)
    public void onPlayerUpdate(PlayerTickEvent event) 
    {	
    	/*Collect the world.*/
    	World world = Minecraft.getMinecraft().theWorld;
    	/*Token stuff*/
    	if(event.phase == Phase.START){Profile.scan(event.player);}/*Update Inventory*/			
    }
    

     

     

    Scan code (for those interested)

     

     

    /*Update inventory*/
    public static void scan(EntityPlayer player) {
    	tags = player.getEntityData();
    
    	/*Create temp values*/
    	boolean amplifyingTokenTemp = false;
    
    	/*Iterate over inventory*/
    	for(int i=0; i<39; i++)
    	{
    		if(player.inventory.getStackInSlot(i) != null)
    		{
    			/*Check item*/
    			ItemStack currentItemStack = player.inventory.getStackInSlot(i);
    			Item currentItem = currentItemStack.getItem();
    			if(currentItem instanceof AmplifyingToken){amplifyingTokenTemp = true;}
    		}
    	}
    	/*Evaluate*/
    	if(amplifyingTokenTemp != tags.getBoolean("amplifyingToken")){tags.setBoolean("amplifyingToken", amplifyingTokenTemp);}
    
    	player.writeToNBT(tags);
    }
    

     

     

     

    However, if the server then tries to read the players NBT Data - it does not show the updated version.

     

    • Is NBT data suitable for sharing information client-to-server?
    • Am I correctly writing and saving the NBT data? - player.writeToNBT(tags);

     

     

    Sorry if this is trivial. If you need more info, please let me know - I am painfully aware how how vague some of this may seem.

     

    Thanks in advance!

  10. Thanks!

     

    I knew it was going to be something stupid, I do feel small now. I do check code (spent the whole of yesterday digging through Entity just to find that the parameters I needed use are private and hardcoded...).

     

    I try to only post on here as a last resort. I was so convinced it was something to do with Server/Client in my event handler. It didn't even cross my mind that there would be two methods for playing sound..

  11. Unless I misunderstood you, I think they must have broke it out. This is what is inside of TickEvent:

     

    public static class WorldTickEvent extends TickEvent {
            public final World world;
            public WorldTickEvent(Side side, Phase phase, World world)
            {
                super(Type.WORLD, side, phase);
                this.world = world;
            }
        }
    

     

    Either way, I tried TickEvent.WorldTickEvent and no dice.

     

    I'm paranoid that I am missing something simple. Playing sounds server side is definitely a thing right?...

  12. Hello, I am having trouble getting a sound to play server side. I have looked all over the internet without avail:

     

    @SubscribeEvent
    public void testTest(WorldTickEvent event) 
    {
    	//Word object from event.
    	World world = event.world;	
    	if(!world.isRemote)
    	{
    		System.out.println("Server");
    		event.world.playSound(0, 0, 0, "random.explode", 10.0F, 1.0F, false);	
    	}
    }
    

     

    Here are a few points:

    • The console does NOT print any errors, including 'unable to play sound'.
    • I have tried many different sound files, ones which have worked elsewhere.
    • The console does print 'server', so it is entering the if block
    • The event handler is registered properly, the rest of the event works fine, just not the sound.

     

    Furthermore, The 'WorldTickEvent' seems to only yield remote worlds, I had a catch for client worlds but it never entered it.

     

    @SubscribeEvent
    public void testTest(WorldTickEvent event) 
    {
    	//Word object from event.
    	World world = event.world;	
    	if(world.isRemote)
    	{
    		System.out.println("Client");
    	}
    }
    

     

    Nothing was printed.

     

    Thanks in advance,

    Sam

  13. Hello, this may sound like a basic question, but I would love to hear about how you optimise your mods performance?

     

    For example, I may be paranoid, but something about using event handlers that are called every tick does not sit right with me... does firing 10-20 different events cause much lag? even if there is very little to no logic happening every time?

     

    I have a 'token' which amplifies the damage you do to mobs and the damage you take from mobs. The only way I could work out how to do this is to subscribe to the 'onEntityGetHurt' event and check if the player is holding the token. This means that  the actual logic for the item is in the event handler class and not in the item class. Is this bad? My code works, but sometimes I can't shake the feeling that my solution is... hacky.

     

    Essentially my main questions are:

    • Does using events that fire every tick cause much lag? even if you have if statements so it only does something under certain circumstances.
    • Is it bad to have the bulk of item logic in the event handler and not in the corresponding item class?

    However, I am also interested in hearing any other tips you have? I don't want my mod to cause unnecessary performance drops.

     

    Thanks in advance,

    Sam

  14. EDIT 2: I SOLVED IT!!!  (changed the title of the post, so as not to mislead people. The original 'problem' was not the problem at all.. )

     

    The problem was in my eventhandler, I had this:

     
            @SubscribeEvent
    public void openGui(GuiOpenEvent event)
    {	
    		/*No GUI*/
    		if(event.gui == null)
    		{
    			globalFlag_Token_Pouch_Open = 0;
    		}
    		/*Token Pouch opened*/
    		else if(event.gui.toString().contains("lazarus.container.token_pouch.GuiTokenPouch"))
    		{globalFlag_Token_Pouch_Open = 1;}		
    }
    

     

    I added @SideOnly(Side.CLIENT) and it works! (well, it doesn't crash..)

     

     
            @SubscribeEvent
    @SideOnly(Side.CLIENT)
    public void openGui(GuiOpenEvent event)
    {	
    		/*No GUI*/
    		if(event.gui == null){globalFlag_Token_Pouch_Open = 0;}
    
    		/*Token Pouch opened*/
    		else if(event.gui.toString().contains("lazarus.container.token_pouch.GuiTokenPouch"))
    		{globalFlag_Token_Pouch_Open = 1;}		
    }
    

     

     

    EDIT:

     

    I have narrowed the problem down, it seems that it is my event handler that is causing the issue, NOT the proxies.

     

    java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen 

     

    /*Imports*/
    package lazarus.utils.handlers;
    import lazarus.main.LazarusItems;
    import lazarus.utils.whispers.AmsollionWhispers;
    import lazarus.utils.whispers.ImbrasWhispers;
    import lazarus.utils.whispers.OsmodeusWhispers;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.util.ChatComponentText;
    import net.minecraft.util.IChatComponent;
    import net.minecraftforge.client.event.GuiOpenEvent;
    import net.minecraftforge.event.entity.living.LivingHurtEvent;
    import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
    import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
    
    /*Main*/
    public class LazarusEventHandler {
    /*---------------------------------------- Global variables ----------------------------------------*/
    public static int globalFlag_Token_Pouch_Open = 0;
    
    /*---------------------------------------- Listen for guiOpens ----------------------------------------*/
    @SubscribeEvent
    public void openGui(GuiOpenEvent event)
    {	
    		/*No GUI*/
    		if(event.gui == null)
    		{
    			globalFlag_Token_Pouch_Open = 0;
    		}
    		/*Token Pouch opened*/
    		else if(event.gui.toString().contains("lazarus.container.token_pouch.GuiTokenPouch"))
    		{globalFlag_Token_Pouch_Open = 1;}		
    }
    
    /*---------------------------------------- Listen for item pickup ----------------------------------------*/
    @SubscribeEvent
    public void onItemPickup(EntityItemPickupEvent event){
    	/*Amsollions Token*/
    	String whisperTextTemp = "";
    	boolean trigger = false;
    
    	if(event.item.getDisplayName().toString().contains("item.item.gilded_token")){whisperTextTemp = AmsollionWhispers.randomWhsiper();trigger = true;}
    	if(event.item.getDisplayName().toString().contains("item.item.waning_token")){whisperTextTemp = OsmodeusWhispers.randomWhsiper();trigger = true;}
    	if(event.item.getDisplayName().toString().contains("item.item.amplifying_token")){whisperTextTemp = ImbrasWhispers.randomWhsiper();trigger = true;}
    
    	if(trigger)
    	{
    		String whisperText = "";
    		String[] whisperTextSplit = whisperTextTemp.split(" ");
    		for(String element : whisperTextSplit){whisperText += "§8§o";whisperText += element;whisperText+=" ";}
    		IChatComponent whisper = new ChatComponentText(whisperText);
    		SoundHandler.lazarusPlaySound("mob.wither.idle", 0.1F, 0.1F);
    		event.entityPlayer.addChatMessage(whisper);
    	}	
    }
    
    /*---------------------------------------- Listen entity taking damage ----------------------------------------*/
    @SubscribeEvent
    public void onEntityGetHurt(LivingHurtEvent event)
    {
    	if(event.entity instanceof EntityPlayer)
    	{
    		/*Multiplied damgage taken by the player*/
    		EntityPlayer player = (EntityPlayer) event.entityLiving;
    		if(player.inventory.hasItem(LazarusItems.amplifying_token)){event.ammount *= 100;}
    	}
    	else if(event.source.getEntity() instanceof EntityPlayer)
    	{
    		/*Multiplied damgage dealt by the player*/
    		EntityPlayer player = (EntityPlayer) event.source.getEntity();
    		if(player.inventory.hasItem(LazarusItems.amplifying_token)){event.ammount *= 100;}
    	}	
    }	
    }
    
    

     

    -----------------------------------------------------------------------------------------------------------------

    Original message:

    -----------------------------------------------------------------------------------------------------------------

     

    Hello, I am making a mod that adds an item with an inventory.  I struggled for a while, and still do not completely know what all the code does, however I was able to (following tutorials) make an item that does work in singleplayer!

     

    ...However, running a server instance crashes.

     

    java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen

     

    After doing some digging, I was able to find that despite what the tutorial showed me, I should not be trying to access getClientGuiElement from my CommonProxy

     

    I can understand, to some extent, why my code is crashing... but I have zero idea how I can fix it:

    • My common proxy extends IGuiHandler
    • When I try to remove getClientGuiElement from the code, it throws an error
    • As far as I can tell, I have to include getClientGuiElement in my Common proxy or it does not compile, however this is what causes my multiplayer server to crash?

     

    Here is my code:

    (GitHub link to full project - https://github.com/Samalot/Lazarus)

     

    item class relevant code: (not relevant, but if someone could explain to me why it is important to check if the player is not sneaking, I would be very thankful!)

    /*---------------------------------------- On right click ----------------------------------------*/
    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer player)
    {	
    	if (!par2World.isRemote) 
    	{
    		if (!player.isSneaking()) 
    		{
    			player.openGui(LazarusMain.instance, LazarusMain.GUI_ITEM_INV, player.worldObj, 0, 0, 0);
    			System.out.println(par1ItemStack.getTagCompound());
    
    		} 
    		else {new InventoryTokenPouch(player.getHeldItem());}
    	}
    	return par1ItemStack;
    }
    

     

    Common Proxy:

    /*Main*/
    public class CommonProxy implements IGuiHandler{
    	/*Register the renders*/
    	public void registerRenders(){}
    
    	@Override
    	public Object getServerGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) {
    		if (guiId == LazarusMain.GUI_ITEM_INV)  {
    			return new ContainerTokenPouch(player, player.inventory, new InventoryTokenPouch(player.getHeldItem()));
    		} else {
    			return null;
    		}
    	}
    
    	@Override
    	public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    		return null;
    	}
    

     

    Client Proxy

    /*Main*/
    public class ClientProxy extends CommonProxy{
    /*Register the renders*/
    @Override
    public void registerRenders(){
    	LazarusItems.registerRenders();
    }
    
    @Override
    public Object getClientGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) {
    	if (guiId == LazarusMain.GUI_ITEM_INV)  {
    		return new GuiTokenPouch(player, player.inventory, new InventoryTokenPouch(player.getHeldItem()));
    	} else {
    		return null;
    	}
    }	
    
    }
    
    

     

    Any help on this matter would be hugely appreciated!

  15. Found a mod that does EXACTLY what I want AND MORE.

     

    After slaving away for the past 24 hours trying to make my own mod to do this and getting not very far, it is so good to find a mod that achieves what I thought was going to be impossible.

     

    More Player Models - By Noppes

    http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1291730-more-player-models-2-adds-a-character-creation

     

    Lets you choose a skin via URL, and it works SMP... it is exactly what I needed.

     

    <3 Noppes, I didnt think I could like your mods any more after CustomNPCs... but this is fantastic.

     

  16. Hey, I have been trying to figure out how to do this for hours, but no luck. I could really do with some help, so I am hoping that putting my problem here might yield some solutions :)

     

    My Mod: An item that when you right click a mob/player, you can choose a new texture for them.

     

    I am using:

    public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer Player, EntityLivingBase Target){}

    in my item class to target the entity.

     

    (I also have a JFileChooser set up, and working correctly, to select a file path which I can then pass into RecourseLocation.)

     

    So:

    [*]I have a targeted EntityLivingBase

    [*]I have a texture file path

    how can I apply the new texture to the target ?

     

    Also:

    • If it is too difficult to make this work for all entities, then it can just be for players.
    • It only needs to update on the players screen, not the target. So, if it is used in SMP and I try to change the skin of a different player, it should only change it in my view and NOT theirs.

     

    Thanks for taking the time to read this and I hope somebody can help me out a little :S

    Thanks in advance,

     

    Sam

     

    EDIT: I am not sure how much help my code will be, but if you need it for whatever reason, here it is:

     

     

    public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer Player, EntityLivingBase Target){

     

    Minecraft mc= Minecraft.getMinecraft();

     

    //File Chooser

    JFrame frame = new JFrame("Skin Tool");

    File skinFile = new File ("C:\\Users\\Sam Humby\\Desktop\\SamalotPlays\\Graphics\\Skins");

    JFileChooser chooser = new JFileChooser(skinFile);

    int result = chooser.showOpenDialog(frame);

    if (result == JFileChooser.APPROVE_OPTION) {

    File selectedFile = chooser.getSelectedFile();

    System.out.println("Selected file: " + selectedFile.getAbsolutePath());

    ResourceLocation location = new ResourceLocation(selectedFile.getAbsolutePath()); 

    System.out.println(location.toString());

    }

    return false;

    }

     

     

    note: this is a private/personal mod that wont be published, which is why the directories are static.

     

  17. First of all, I am sorry if this is in the wrong section. Was not quite sure where it fitted best.

     

    I make videos, machinimas, I tend to work alone with my brothers account as the 'actor', which means I am constantly closing the client and changing the skins. It is probably one of the most annoying parts of filming.

     

    I am looking for a way to make this easier, I am hoping that there exists a mod already that will let me change how other players look, but I am prepared to code one if I need to.

     

    It does not need to change how the player looks on their screen, since I understand if both players dont have the image file, it would be difficult to pull off. So, it only needs to change how the actor looks on the cameraman's client.

     

    I did find a 'closet' mod, but it has not been updated since 1.5 :(

     

    Does anyone know of any mod that will help me ? and if not, does anyone have any advice on how to make such a mod ? I have some experience with forge coding, but I am a novice.

     

    I should probably mention that I am working in 1.7.2.

     

    Thanks in advance!

  18. Hello,

    I am fairly new to modding, but do have a basic understanding of Java, although my knowledge on Events inst great.

     

    I am trying to change the Villager trading option on interaction with an object (Shift right click.)

     

    I am struggling to change the trade.

     

    From my understanding, of reading every Villager entity file... they have a 'buyinglist' which is their collection of recipes that they are willing to trade.

     

    Is there any way I can reset buyinglist so it is empty ?

     

    Or does anyone have a better solution to this ?

     

    thanks in advance!

     

    (Just to clarify, I am not trying to add now trades to the villagers, I just want to refresh/change their trade upon interaction)

×
×
  • Create New...

Important Information

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