Jump to content

Adding items to blockcontainer Inventories created during worldgen


Draco18s

Recommended Posts

I know about ChestGenHooks, but I don't want to add items to chests.  I want to add them to dispensers (actually a custom block, but it uses the Dispenser's TE).

 

If ChestGenHooks can do this, I haven't figured out how.

 

Additionally, I can't seem to get the block to be oriented the way I want...it's weird:

 

world.setBlock(x, y, z, TrapsBase.TrapBlock.blockID, 1, 3); //metadata 1 means it should point up

 

Doing that in worldgen doesn't make it point up, it points south...which is metadata 3...and it doesn't matter what direction I tell it to face, it always faces south.

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.

Link to comment
Share on other sites

((TileEntityMyDispenser) world.getBlockTileEntity(x,y,z)).addItem(stack);

Oddly enough, addItem(ItemStack) is defined by TileEntityDispenser. Feel free to replace with setInventorySlotContents() or whatever.

 

world.getBlockTileEntity(x,y,z) returns null:

 

			world.setBlock((int)c.xCoord, (int)c.yCoord-1, (int)c.zCoord, TrapsBase.arrowSlot.blockID, 1, 3);
		TileEntityDispenser dis = (TileEntityDispenser)world.getBlockTileEntity((int)c.xCoord, (int)c.yCoord, (int)c.zCoord);
		if(dis != null) {
			addTrapItem(dis);
		}
		else {
			System.out.print("Boo."); //this runs
		}

 

Yes, that's the right TE.

 

    public TileEntity createNewTileEntity(World par1World)
    {
        return new TileEntityDispenser();
    }

 

As for the orientation: getIcon() code?

 

getIcon won't help you.  I'm using a custom renderer and yes I checked that it wasn't just rendering wrong.  It was still shooting arrows in the incorrect direction.

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.

Link to comment
Share on other sites

((TileEntityMyDispenser) world.getBlockTileEntity(x,y,z)).addItem(stack);

Oddly enough, addItem(ItemStack) is defined by TileEntityDispenser. Feel free to replace with setInventorySlotContents() or whatever.

 

world.getBlockTileEntity(x,y,z) returns null:

 

			world.setBlock((int)c.xCoord, (int)c.yCoord-1, (int)c.zCoord, TrapsBase.arrowSlot.blockID, 1, 3);
		TileEntityDispenser dis = (TileEntityDispenser)world.getBlockTileEntity((int)c.xCoord, (int)c.yCoord, (int)c.zCoord);
		if(dis != null) {
			addTrapItem(dis);
		}
		else {
			System.out.print("Boo."); //this runs
		}

 

Yes, that's the right TE.

Perhaps you might try removing the "-1"? Or adding one in the next line?

    public TileEntity createNewTileEntity(World par1World)
    {
        return new TileEntityDispenser();
    }

 

As for the orientation: getIcon() code?

 

getIcon won't help you.  I'm using a custom renderer and yes I checked that it wasn't just rendering wrong.  It was still shooting arrows in the incorrect direction.

If you're sure, then I don't know.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

Perhaps you might try removing the "-1"? Or adding one in the next line?

 

Frakking hell.  Thanks for spotting that. >..x

The -1 should actually be on another line entirely.

 

If you're sure, then I don't know.

 

public Icon getIcon(int par1, int par2)
    {
    		if(par2 <= 1)
    			return verticalFront;
	return blockIcon;
    }

 

All it does it determine which overlay to use.  The four horizontal facings have one icon (four "holes") the vertical one has another (two "holes").

 

The renderer is a tad bit more complex.

 

 

package draco18s.traps.client;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import draco18s.traps.TrapsBase;

public class RenderArrowTrap implements ISimpleBlockRenderingHandler {
private int renderType;

public RenderArrowTrap(int r) {
	renderType = r;
}

@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
	renderer.renderBlockAsItem(TrapsBase.pseudoAT, 3, 1.0F);
}

public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	int l = world.getBlockMetadata(x, y, z);
	l = l & 7;
	int i = x;
	int j = y;
	int k = z;
	int xm = 0;
	int zm = 0;
	switch(l) {
		case 0: 
        case 2:
        case 3:
        	xm = 1;
        	break;
        case 1:
        case 4:
        case 5:
        	zm = 1;
        	break;
    }
	int meta = 0;
	int wid1 = world.getBlockId(x+xm, y, z+zm);
	int wid2 = world.getBlockId(x-xm, y, z-zm);
	int wid = 0;
	if(wid1 != block.blockID && Block.blocksList[wid1] != null && Block.blocksList[wid1].isOpaqueCube()) {
		wid = wid1;
		meta = world.getBlockMetadata(x+xm, y, z+zm);
	}
	else if(wid2 != block.blockID && Block.blocksList[wid2] != null && Block.blocksList[wid2].isOpaqueCube()) {
		wid = wid2;
		meta = world.getBlockMetadata(x-xm, y, z-zm);
	}
	else {
		if(l <= 1) {
			wid1 = world.getBlockId(x+zm, y, z+xm);
			wid2 = world.getBlockId(x-zm, y, z-xm);
			if(wid1 != block.blockID && Block.blocksList[wid1] != null && Block.blocksList[wid1].isOpaqueCube()) {
				wid = wid1;
				meta = world.getBlockMetadata(x+zm, y, z+xm);
			}
			else if(wid2 != block.blockID && Block.blocksList[wid2] != null && Block.blocksList[wid2].isOpaqueCube()) {
				wid = wid2;
				meta = world.getBlockMetadata(x-zm, y, z-xm);
			}
			else {
				wid = Block.stoneBrick.blockID;
			}
		}
		else {
			wid = Block.stoneBrick.blockID;
		}
	}
	Icon camo = Block.blocksList[wid].getIcon(l, meta);
	Icon furnace = Block.furnaceIdle.getIcon(2,3);
	Icon top = Block.furnaceIdle.getIcon(1,0);
	Icon self = block.getIcon(0, l);
	renderer.renderBlockUsingTexture(Block.stone, x, y, z, camo);
	switch(l) {
		case 0:
			renderer.renderFaceYNeg(Block.blocksList[wid], (double)x, (double)y, (double)z, self);
			renderer.renderFaceYPos(Block.blocksList[wid], (double)x, (double)y, (double)z, top);
			break;
		case 1:
			renderer.renderFaceYPos(Block.blocksList[wid], (double)x, (double)y, (double)z, self);
			renderer.renderFaceYNeg(Block.blocksList[wid], (double)x, (double)y, (double)z, top);
			break;
		case 2:
			renderer.renderFaceZNeg(Block.blocksList[wid], (double)x, (double)y, (double)z, self);
			renderer.renderFaceZPos(Block.blocksList[wid], (double)x, (double)y, (double)z, furnace);
			renderer.renderFaceYPos(Block.blocksList[wid], (double)x, (double)y, (double)z, top);
			renderer.renderFaceYNeg(Block.blocksList[wid], (double)x, (double)y, (double)z, top);
			break;
		case 3:
			renderer.renderFaceZPos(Block.blocksList[wid], (double)x, (double)y, (double)z, self);
			renderer.renderFaceZNeg(Block.blocksList[wid], (double)x, (double)y, (double)z, furnace);
			renderer.renderFaceYPos(Block.blocksList[wid], (double)x, (double)y, (double)z, top);
			renderer.renderFaceYNeg(Block.blocksList[wid], (double)x, (double)y, (double)z, top);
			break;
		case 4:
			renderer.renderFaceXNeg(Block.blocksList[wid], (double)x, (double)y, (double)z, self);
			renderer.renderFaceXPos(Block.blocksList[wid], (double)x, (double)y, (double)z, furnace);
			renderer.renderFaceYPos(Block.blocksList[wid], (double)x, (double)y, (double)z, top);
			renderer.renderFaceYNeg(Block.blocksList[wid], (double)x, (double)y, (double)z, top);
			break;
		case 5:
			renderer.renderFaceXPos(Block.blocksList[wid], (double)x, (double)y, (double)z, self);
			renderer.renderFaceXNeg(Block.blocksList[wid], (double)x, (double)y, (double)z, furnace);
			renderer.renderFaceYPos(Block.blocksList[wid], (double)x, (double)y, (double)z, top);
			renderer.renderFaceYNeg(Block.blocksList[wid], (double)x, (double)y, (double)z, top);
			break;
	}

	return true;
}

@Override
public boolean shouldRender3DInInventory() {
	return true;
}

@Override
public int getRenderId() {
	return renderType;
}
}

 

 

 

But feel free.

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.

Link to comment
Share on other sites

You'll never believe what fixed it.

 

world.setBlockMetadataWithNotify((int)c.xCoord, (int)c.yCoord-1, (int)c.zCoord, 1, 3);

 

Had to forcibly set the metadata after creating the block.

 

Because dispensers do this:

 

public void onBlockAdded(World par1World, int par2, int par3, int par4)
    {
        super.onBlockAdded(par1World, par2, par3, par4);
        this.setDispenserDefaultDirection(par1World, par2, par3, par4);
    }

 

Even the vanilla dispenser has this "problem."

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.

Link to comment
Share on other sites

You'll never believe what fixed it.

 

world.setBlockMetadataWithNotify((int)c.xCoord, (int)c.yCoord-1, (int)c.zCoord, 1, 3);

 

Had to forcibly set the metadata after creating the block.

 

Because dispensers do this:

 

public void onBlockAdded(World par1World, int par2, int par3, int par4)
    {
        super.onBlockAdded(par1World, par2, par3, par4);
        this.setDispenserDefaultDirection(par1World, par2, par3, par4);
    }

 

Even the vanilla dispenser has this "problem."

Lolz. Well, I'm glad I solved at least half of your problem :)

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

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

    • So i know for a fact this has been asked before but Render stuff troubles me a little and i didnt find any answer for recent version. I have a custom nausea effect. Currently i add both my nausea effect and the vanilla one for the effect. But the problem is that when I open the inventory, both are listed, while I'd only want mine to show up (both in the inv and on the GUI)   I've arrived to the GameRender (on joined/net/minecraft/client) and also found shaders on client-extra/assets/minecraft/shaders/post and client-extra/assets/minecraft/shaders/program but I'm lost. I understand that its like a regular screen, where I'd render stuff "over" the game depending on data on the server, but If someone could point to the right client and server classes that i can read to see how i can manage this or any tip would be apreciated
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
  • Topics

×
×
  • Create New...

Important Information

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