Jump to content

Rendering...


Assaru

Recommended Posts

Hi! I am trying to make a streetcar track as a part of my European cities mod (basically the track is a whole block instead of on top of another block). I have tried a LOT of stuff and finally succesfully changed the collision box BUT, It still doesn't render correctly. I use the code I usually use for multi-textured blocks. The issue is just that the game STILL thinks it is a normal track. (I have changed the renderType to zero). The reason I have set isOpaqueCube() and renderAsNormalBlock() false is because otherwise it looks even more messed up. I guess I will just change that back if I get this working.


public class Test extends BlockRailBase {

@SideOnly(Side.CLIENT)
    private Icon theIcon;
@SideOnly(Side.CLIENT)
private int renderType = 0;

@SideOnly(Side.CLIENT) 
    public static Icon topIcon;
    @SideOnly(Side.CLIENT)
    public static Icon bottomIcon;
    @SideOnly(Side.CLIENT)
    public static Icon sideIcon;
    

@Override
@SideOnly(Side.CLIENT)
public void setRenderType(int value)
    {
        setRenderType(0);
    }

public boolean isBlockSolid() {
	return true;
}


@Override
    public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
    {
        int l = par1IBlockAccess.getBlockMetadata(1, 1, 1);
        if (l >= 2 && l <= 5)
        {
            this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        }
        else
        {
            this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        }
    }
protected Test(int par1)
    {
        super(3512, false);
       setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }

public Icon getIcon(int par1, int par2)
    {	
	if(par1 == 0) {
	return bottomIcon;
	} else if(par1 == 1) {
	return topIcon;
	} else {
	return sideIcon;
	}
    }
 public void registerIcons(IconRegister par1IconRegister)
    {
        super.registerIcons(par1IconRegister);
        this.theIcon = par1IconRegister.registerIcon(this.getTextureName() + "curve");
        topIcon = par1IconRegister.registerIcon(Path);
        	bottomIcon = par1IconRegister.registerIcon(Path);
        	sideIcon = par1IconRegister.registerIcon(Path);
    }
   protected void func_94358_a(World par1World, int par2, int par3, int par4, int par5, int par6, int par7)
    {
        if (par7 > 0 && Block.blocksList[par7].canProvidePower() && (new BlockBaseRailLogic(this, par1World, par2, par3, par4)).getNumberOfAdjacentTracks() == 3)
        {
            this.refreshTrackShape(par1World, par2, par3, par4, false);
        }
    }
 public float getRailMaxSpeed(World world, EntityMinecart cart, int y, int x, int z)
    {
        return 0.4f;
    }

@Override 
public boolean isOpaqueCube()
    {
        return false;
    }
  @Override
 public boolean renderAsNormalBlock() 
    {
        return false;
    }
    

}

 

Link to comment
Share on other sites

hi

 

Since I've just started modding I'm not sure how right I am.

 

On the other hand I am coding in java for a long time now my eyes've been catched by the following:

 

public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
    {
        int l = par1IBlockAccess.getBlockMetadata(1, 1, 1);
        if (l >= 2 && l <= 5)

 

Why do you use the blockAccess.getBlockMetadata(1,1,1) since the getBlockMetadata(x,y,z) method returns the metadata of the block at the given coordinates.

 

(Additional tip: if you override a method, you can change the name of each argument, so

getBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)

would be much easier to read, don't you think? )

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

Link to comment
Share on other sites

Hi! I am trying to make a streetcar track as a part of my European cities mod (basically the track is a whole block instead of on top of another block). I have tried a LOT of stuff and finally succesfully changed the collision box BUT, It still doesn't render correctly. I use the code I usually use for multi-textured blocks. The issue is just that the game STILL thinks it is a normal track. (I have changed the renderType to zero). The reason I have set isOpaqueCube() and renderAsNormalBlock() false is because otherwise it looks even more messed up. I guess I will just change that back if I get this working.

Hi

 

A couple of questions that will help us

1) What do you expect to see?

2) What are you actually seeing? (Screenshot?)

 

-TGG

 

Link to comment
Share on other sites

Pictures would be very helpfull. 

 

If you want something very unique here, why don't you just make a custom block model and render using tecne or something else as a basis? 

 

If you really just want a sided block texture, you might need to render for this type of block to the typical one.  That is a guess though.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

For a block?  Generally you don't need to rotate it.

 

In your case, you are making rail, so I assume you need east/west vs north/south.  That is just rotating the 7 90deg.  Easy.

 

Where it gets complicated is deciding on joined tracks but you already need to figure that out.  You would probably need a unique model for a few of those scenarios depending on how you handel.  Then just pass it your variable you decided which 'case' it is.

 

Of course you could just make one model and decide which parts to show based upon the case.  That is what I have done in the past.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

This is less an answer than a suggestion but - given as you are making rail, check out the vanilla handling for minecart rail. If you set the curve rules to be the same as "regular" rail then players will have an idea of how it works. You may even wish to extend the minecart rail class and just overwrite the texture assignment!

Link to comment
Share on other sites

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

    • this is my first time using this website. Im having an issue where if I have EC Apotheosis enabled the game launches but crashes on the loading screen. If I disable the mod the game runs fine. Dont know if it will help but this is the exported curseforge proflie file. https://drive.google.com/file/d/1iDoqIGmiJsTKW5ocru7FBxIdBiKgUr0i/view?usp=sharing
    • How to fix file server-1.20.1-20230612.114412-srg.jar  
    • Just a few months ago I was creating my own plugin for Minecraft 1.20.2 spigot that did the same thing, but the skins were not saved, if you can understand this code that I made a long time ago it may help you.   //This is a class method private static String APIRequest(String value, String url, String toSearch) { try { URL api = new URL(url + value); HttpURLConnection connection = (HttpURLConnection) api.openConnection(); connection.setRequestMethod("GET"); int responseCode = connection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder response = new StringBuilder(); for (String responseChar; (responseChar = reader.readLine()) != null; ) response.append(responseChar); reader.close(); JSONObject responseObject = new JSONObject(response.toString()); if (!toSearch.equals("id")) return responseObject .getJSONArray("properties") .getJSONObject(0) .getString("value"); else return responseObject.getString("id"); } else { AntiGianka.ConsoleMessage(ChatColor.RED, String.format( "Could not get %s. Response code: %s", ((toSearch.equals("id")) ? "UUID" : "texture"), responseCode )); } } catch (MalformedURLException error) { AntiGianka.ConsoleMessage(ChatColor.RED, "An error occurred while trying to access the URL. Error: " + error); } catch (IOException error) { AntiGianka.ConsoleMessage(ChatColor.RED, "An error occurred while attempting to connect to the URL. Error: " + error); } return ""; } //other class method private void SkinGetter() { String uuid; String textureCoded; if ((uuid = APIRequest(args[0], "https://api.mojang.com/users/profiles/minecraft/", "id")).isEmpty() || (textureCoded = APIRequest(uuid, "https://sessionserver.mojang.com/session/minecraft/profile/", "value")).isEmpty() ) sender.sendMessage(ChatColor.RED + String.format( "An error has occurred while trying to obtain the %s player skin, please check if the name %s is spelled correctly or try again later.", args[0], args[0] ) ); else SkinSetter(textureCoded); } //other more private void SkinSetter(String textureCoded) { JSONObject profile = new JSONObject(new String(Base64.getDecoder().decode(textureCoded))); try { URL textureUrl = new URL(profile.getJSONObject("textures"). getJSONObject("SKIN"). getString("url")); if (sender instanceof Player && args.length == 1) { PlayerTextures playerTextures = ((Player) sender).getPlayerProfile().getTextures(); playerTextures.setSkin(textureUrl); ((Player) sender).getPlayerProfile().setTextures(playerTextures); if (((Player) sender).getPlayerProfile().getTextures().getSkin() != null) sender.sendMessage(((Player) sender).getPlayerProfile().getTextures().getSkin().toString()); else sender.sendMessage("Null"); sender.sendMessage("Skin changed successfully.a"); } else { } AntiGianka.ConsoleMessage(ChatColor.GREEN, "Skin command executed successfully."); } catch (MalformedURLException error) { sender.sendMessage(ChatColor.RED + String.format( "An error has occurred while trying to obtain the %s player skin, please check if the name %s is spelled correctly or try again later.", args[0], args[0] ) ); AntiGianka.ConsoleMessage(ChatColor.RED, "An error occurred while trying to access the URL. Error: " + error); } }  
    • Use /locate structure The chat should show all available structures as suggestion For the Ancient City it is /locate structure ancient_city
    • So does it work without this mod? Did you test it with other builds?
  • Topics

×
×
  • Create New...

Important Information

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