Jump to content

Recommended Posts

Posted

Alright i am changing my block status on what time of day it is. i am using metadata for this code i have based this off of the furnace and how it returns its active texture

 

I do have one question. since i am using metadata on the blocks do i have to get and save the the metadata of the block for it to use later because some of the ids are 506, 506:1 .... 509, 509:1 an i think if i did it like this without the world.setBlockMetadataWithNotify(int, int, int, int, int); instead i wouldnt be able to change it to the block it needs to be it would just switch from 506:2 to : 509 to 506 and that would mess up the meaning of the block

 

 

http://pastebin.com/Y6kwxpBc

 

http://pastebin.com/zpdmACmL

Posted

set the metadata how you need it and test it in a tileentity special render


private ResourceLocation texture;

@Override
public void renderTileEntityAt(TileEntity tile, double posX, double posY, double posZ, float partialTick, int damage) {
	YourTileEntity tileEntity = (YourTileEntity)tile;

	if(tileEntity.getBlockMetadata() == 0)
	{
		texture = new ResourceLocation(YourMod.MODID, "textures/blocks/yourTextureFile0.png");
	}

	if(tileEntity.getBlockMetadata() == 1)
	{
		texture = new ResourceLocation(YourMod.MODID, "textures/blocks/yourTextureFile1.png");
	}

}

Posted

and you have to do the tessellating, using the texture afterwards.


this.bindTexture(texture);
Tessellator tess = new Tessellator.getInstance();
//tessellating stuffs
tess.addVertexWithUV(0, 0, 0, 0, 0);
//etc.

Posted

Or you could use the getIcon(World, x, y, z) methods and ask the world what time it is...

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

it would always return  false

 

What.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

This does not work it always returns false @SideOnly(Side.CLIENT)

        @Override

    public IIcon getIcon(int side, int meta)

    {

                if(!Minecraft.getMinecraft().theWorld.isRemote){

                        if(Minecraft.getMinecraft().theWorld.isDaytime() == true){

                        return  unActive;

                }else if (Minecraft.getMinecraft().theWorld.isDaytime() == false){

                        return magic;

                }

                }

                return unActive;

    }

Posted

Idiot.*

 

1) Use the method that has a world passed to it. You should never use Minecraft.getMinecraft(). It happens to be safe here do to the SideOnly annotation, but it is still a bad idea.

public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)

2) "it returns false" makes no sense for a method that returns IIcon. You meant that isDaytime is returning false. You never once mentioned using this method.

3) world.getTotalWorldTime()

 

I would have to look, but isDaytime might not be useful client side. I so know that total world time will work though, as it (or at least the variable that method returns) is used by getMoonPhase, which is a client side method.

 

*sorry, I'm a bit grumpier than usual. I can't sleep and it's 5am. You posted half intelligible gibberish, played the pronoun game, and forced me to ask for clarification rather than posing what you meant (with code!) the first time.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

in this public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){}

 

IBlockAccess does not have access to  getTotalWorldTime

 

all that is in the IBlockAccess is

getBlock

getTileEntity

getLightBrightnessForSkyBlocks

getBlockMetadata

isBlockProvidingPowerTo

isAirBlock

getBiomeGenForCoords

getHeight

extendedLevelsInChunkCache

isSideSolid

 

Posted

i have tried something like this

@SideOnly(Side.CLIENT)

@Override

public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){

if(world instanceof World){

if(((World) world).getWorldTime() >= 0 && ((World) world).getWorldTime() <= 2400){

return iconArray[world.getBlockMetadata(x, y, z)];

}

}

return iconUnactive[world.getBlockMetadata(x, y, z)];

    }

Posted

getWorldTime() returns the total amount of time since the world's creation.  There's a comment buried deep on the

long

that is returned which says that it is clamped 0-23999, but that's wrong.  If you do a project-wide search for where that value is set and modified, you will find no such modulation.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

i have tried something like this

@SideOnly(Side.CLIENT)

@Override

public IIcon getIcon(IBlockAccess iBlockAcess, int x, int y, int z, int side){

if(iBlockAcess instanceof World){

long worldTime = ((World) iBlockAcess).getWorldTime() % 24000;

if(worldTime <= 1200){

return iconArray[iBlockAcess.getBlockMetadata(x, y, z)];

}

}

return iconUnactive[iBlockAcess.getBlockMetadata(x, y, z)];

    }

Posted

i have tried something like this

 

And what happened?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Ah, I have inadvertently mislead you.

The object passed to that getIcon method, the IBlockAccess is not a World at all, but a ChunkCache.

 

While a ChunkCache object has a World property, it is private.  Instead, you will need to do something a little more clever.  You will need to make a TextureAtlas class.  There's a second reason too.  The icon won't update just because it went from "night" to "day."  You'd also have to tell the game to re-render the blocks.  Fortunately a TextureAtlas can solve both of these problems.

 

Here is a TextureAtlas I use.  It does something very similar, but with a different time scale.  It is up to you to rewrite this class for your needs.  It's a simple class, really.

 

package com.draco18s.wildlife.client;

import com.draco18s.wildlife.WildlifeEventHandler;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureUtil;

@SideOnly(Side.CLIENT)
public class TextureCalendar extends TextureAtlasSprite {

    public TextureCalendar(String par1Str) {
        super(par1Str);
    }

    public void updateAnimation() {
        if (!this.framesTextureData.isEmpty()) {
            Minecraft minecraft = Minecraft.getMinecraft();
            
            int i = frameCounter;
            if (minecraft.theWorld != null && minecraft.thePlayer != null) {
            	i = (int) ((minecraft.theWorld.getWorldTime() % WildlifeEventHandler.yearLength)/(WildlifeEventHandler.yearLength/4));
            	i*=2;
            	if(minecraft.theWorld.provider.isHellWorld) {
                	//Hell does not have day or night, you will want to do something else here.
                	//Look at the TextureClock class in vanilla
            		i++;
            	}
            }
            if (i != this.frameCounter) {
                this.frameCounter = i;
                TextureUtil.uploadTextureMipmap((int[][])this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false);
            }
        }
    }
}

 

You will also need to register an event handler:

 

public class ClientEventHandler {
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void registerTextures(TextureStitchEvent.Pre event) {
	if(event.map.getTextureType() == 1 ) {
		//change these to point to your own variables and texture strings.  The two strings should be identical.
		event.map.setTextureEntry("wildlife:season_calendar", ClientProxy.calendar = new TextureCalendar("wildlife:season_calendar"));
	}
}
}

 

Finally, your getIcon and registerIcon methods:

	@SideOnly(Side.CLIENT)
@Override
    public void registerIcons(IIconRegister iconReg) {
	itemIcon = ClientProxy.calendar;
    }

@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int par1) {
	return ClientProxy.calendar;
}

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Draco, you don't need the stitch event. registerIcons method in Blocks / Items class is equivalent to an event handler on that event.

 

Noted.  I wrote that code months ago and whatever reference I had did it that way and I never tried using the registerIcons method for it.

 

Wait if it says if worldhellworld doesnt it only work in the nether ?

 

Sigh.  That check handles a portion of the code.  In my case it makes it select an odd numbered item out of a list, rather than an even one.

Learn 2 Java

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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