lol you cange the color using hex codes I.e black is 0xffffff, white is 0x000000, green is 0x00ff00
Actually, black is 0x000000 and white is 0xffffff lol Green is 0x00ff00 though
Either way, mine is set for 0xffffff, and it usually shows up white, but when I pick up the item in my first clickbar slot, it changes to a gray color. When I put the item back down it changes back to white. Basically, as long as that slot has something in it, it's white, but when the slot is empty, it turns gray.
EDIT: Definitely getting darker. It goes from 0xffffff to 0xd6d6d6.
And it does the same thing (gets darker) no matter what color I put in. Here's my code:
Does anyone have an idea how to make a custom textured block faces everytime the player when placing the block?
I got an Tile Entity with custom textures and I want that for example the texture index 3 is the side the player looks at after placing the block right in front of him.
Hello, i have a small question, if i make a furnance type of block, how can i get where the player is facing and set a custom texture for that?
Thanks,
Andrei.
This tutorial explains that It's mostly in the "Finish the TileEntity***" section. Basically, you have to find which direction the player is facing in relation to the world, and texture the block accordingly.
Bear in mind that that tutorial is for ModLoader, but most of the code should still work in the Forge context.
Rollback Post to RevisionRollBack
Learn some Java before you mod, and skip over the chapter on ModLoader, straight to MinecraftForge. It's better. Trust me.
Just a note on the container. If you are only storing one ItemStack, you don't have to box it in an array.
private ItemStack[] inventory;
becomes
private ItemStack inventory;
And when accessing it, you drop the [0].
Of course, if you have more than one inventory, this doesn't apply.
Its better to do make it an array because if your going to change the amount of slots in the inventory then all you have to do is change the number that you registered when its declared, if you just go with ItemStack then it requires you to change more code than unnecessary. Not that you had a bad suggestion but I did put it like that for a reason, and btw I didn't know that the inventory would register like that never tried it, just used ItemStack[1] (and you can't register ItemStack[0] because its technically registering it as nothing lol) but still I get it)
Can someone please help me? I've tried to make a custom crafting table with unique recipes that only work on it. Using ModLoader's method of opening GUI's gave me syncing issues between client and server, so I hit the forums looking for an answer and someone said that using Forge's GUI opening method would fix this. So I wrote the code out and hopped into the game to test, and on the console part of Eclipse it said:
[ForgeModLoader] A mod tried to open a gui on the server without being a NetworkMod
So I hopped on the forums again to see what I could do to resolve this issue (note that I DO have @NetworkMod in my code) and I was told to come to this tutorial and follow it. Now I wrote the code out EXACTLY like Leah had on the OP, still had the issue. Is there anything I can do to fix this issue.
If you need any additional info just say so. Thanks.
Code:
Main mod class:
package jcm2606.industrize.common;
import jcm2606.industrize.client.ClientPacketHandler;
import jcm2606.industrize.client.GuiHandler;
import jcm2606.industrize.client.gui.GUIAnvil;
import jcm2606.industrize.common.blocks.BlockAnvil;
import jcm2606.industrize.common.blocks.BlockPlexiGlass;
import jcm2606.industrize.common.handlers.PacketHandler;
import jcm2606.industrize.common.items.ItemAnvilPlacer;
import jcm2606.industrize.common.tiles.TileEntityAnvil;
import jcm2606.industrize.common.tiles.TileEntityAnvilRenderer;
import jcm2606.vertbase.core.ControllerParts;
import jcm2606.vertbase.core.VertInterface;
import net.minecraft.src.Block;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.EntityClientPlayerMP;
import net.minecraft.src.GuiContainer;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material;
import net.minecraft.src.ModLoader;
import net.minecraft.src.RenderBlocks;
import net.minecraft.src.TileEntityRenderer;
import net.minecraft.src.World;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
@Mod(modid = "JC_Indu", name = "Industrize", version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false, clientPacketHandlerSpec =
@SidedPacketHandler(channels = {"JC_Indu" }, packetHandler = ClientPacketHandler.class)
,serverPacketHandlerSpec =
@SidedPacketHandler(channels = {"JC_Indu" }, packetHandler = PacketHandler.class))
public class IndustrizeBase {
@SidedProxy(clientSide = "jcm2606.industrize.client.ClientProxy", serverSide = "jcm2606.industrize.common.CommonProxy")
public static CommonProxy proxy;
@Instance("Industrize")
public static IndustrizeBase instance = new IndustrizeBase();
public static GuiHandler guihandler = new GuiHandler();
@Init
public void load(FMLInitializationEvent event)
{
VertInterface.registerMod("industrize");
VertInterface.preloadModTextures("industrize");
addNames();
addRecipes();
addSmelting();
registerBlocks();
registerTileEntities();
//ModLoader.registerContainerID(basemod, 0);
NetworkRegistry.instance().registerGuiHandler(this, guihandler);
}
public void addNames()
{
ModLoader.addName(alloy, "Alloy Ingot");
ModLoader.addName(alloyplate, "Alloy Plate");
ModLoader.addName(anvilPlacer, "Anvil");
ModLoader.addName(steelingot, "Steel Ingot");
ModLoader.addName(steelplate, "Steel Plate");
ModLoader.addName(steelblock, "Block of Solid Steel");
}
public void addRecipes()
{
ModLoader.addRecipe(new ItemStack(plexiglass,1), new Object []{
"ABA",
"BCB",
"ABA",
'A', Item.flint,
'B', alloyplate,
'C', Block.glass
});
//AlloyPlate
ModLoader.addRecipe(new ItemStack(alloyplate,1), new Object []{
"AAA",
"BBB",
"AAA",
'A', alloy,
'B', ControllerParts.metalrod
});
//SteelAnvil
ModLoader.addRecipe(new ItemStack(anvil,1), new Object []{
"AAA",
"BCB",
"BBB",
'A',ControllerParts.aluminum,
'B',ControllerParts.scorchedaluminum,
'C',Block.workbench
});
//SteelBlock>SteelIngot
ModLoader.addShapelessRecipe(new ItemStack(steelingot,9), new Object []{
steelblock
});
//SteelPlate
ModLoader.addRecipe(new ItemStack(steelplate,1), new Object []{
"AAA",
"BBB",
"AAA",
'A',steelingot,
'B',ControllerParts.metalrod
});
}
public void addSmelting()
{
}
public void registerBlocks()
{
ModLoader.registerBlock(plexiglass);
ModLoader.registerBlock(steelblock);
ModLoader.registerBlock(anvil);
}
public void registerTileEntities()
{
ModLoader.registerTileEntity(TileEntityAnvil.class, "anvil", tileent1);
}
public void renderInvBlock(RenderBlocks renderblocks, Block block, int i, int j)
{
if(block instanceof BlockAnvil)
{
block.setBlockBoundsForItemRender();
TileEntityRenderer.instance.renderTileEntityAt(new TileEntityAnvil(), 0.0D, 0.0D, 0.0D, 0.0F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
}
}
public boolean renderWorldBlock(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l)
{
if(block instanceof BlockAnvil)
{
renderInvBlock(renderblocks, block, i, j);
return true;
}
return false;
}
/*public GuiContainer getContainerGUI(EntityClientPlayerMP player, int guiID, int i, int j, int k)
{
TileEntityAnvil t = (TileEntityAnvil)ModLoader.getMinecraftInstance().theWorld.getBlockTileEntity(i, j, k);
if(guiID == 0) return new GUIAnvil(player.inventory, world, i, j, k);
return null;
}*/
TileEntityAnvilRenderer tileent1 = new TileEntityAnvilRenderer();
BlockAnvil blockanvil;
World world;
//Blocks
public static final Block plexiglass = (new BlockPlexiGlass(2624, 1, Material.glass).setBlockName("plexiGlass"));
public static final Block anvil = (new BlockAnvil(2623, 1,TileEntityAnvilRenderer.class).setBlockName("blockGUIAnvil"));
public static final Block steelblock = (new NewBlock(2622, 0, Material.iron).setBlockName("blockIngotSteel"));
//Items
public static final Item alloyplate = (new NewItem(516).setIconIndex(4).setTabToDisplayOn(CreativeTabs.tabMaterials).setItemName("plateAlloy"));
public static final Item alloy = (new NewItem(515).setIconIndex(3).setTabToDisplayOn(CreativeTabs.tabMaterials).setItemName("ingotAlloy"));
public static final Item anvilPlacer = (new ItemAnvilPlacer(514, anvil).setIconIndex(2).setTabToDisplayOn(CreativeTabs.tabBlock).setItemName("placerAnvil"));
public static final Item steelplate = (new NewItem(513).setIconIndex(1).setTabToDisplayOn(CreativeTabs.tabMaterials).setItemName("plateSteel"));
public static final Item steelingot = (new NewItem(512).setIconIndex(0).setTabToDisplayOn(CreativeTabs.tabMaterials).setItemName("ingotSteel"));
//Tools
}
If your wondering about the VertBase, it is a custom API I'm writing that aids me in developing more than 1 mod. This has NOTHING to do with the error.
Block class:
package jcm2606.industrize.common.blocks;
import java.util.Random;
import jcm2606.industrize.common.Handler;
import jcm2606.industrize.common.IndustrizeBase;
import jcm2606.industrize.common.tiles.TileEntityAnvil;
import net.minecraft.src.BlockContainer;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.Material;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
public class BlockAnvil extends BlockContainer
{
IndustrizeBase base;
public BlockAnvil(int i, int j, Class class1)
{
super(i, j, Material.iron);
anEntityClass = class1;
}
public int idDropped(int i, Random random)
{
return IndustrizeBase.anvilPlacer.shiftedIndex;
}
public int quantityDropped(Random random)
{
return 1;
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return -1;
}
public TileEntity getBlockEntity()
{
try
{
return (TileEntity)anEntityClass.newInstance();
}
catch(Exception exception)
{
throw new RuntimeException(exception);
}
}
public void playBlock(World world, int i, int j, int k, int l, int i1)
{
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
//player.openGui(IndustrizeBase.instance, 0, world, x, y, z);
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
if(tile_entity == null || player.isSneaking()){
return false;
}
player.openGui(IndustrizeBase.instance, Handler.ANVIL, world, x, y, z);
return true;
}
@Override
public int getBlockTextureFromSide(int par1) {
return 1;
}
private Class anEntityClass;
public TileEntity createNewTileEntity(World var1) {
return new TileEntityAnvil();
}
}
Rollback Post to RevisionRollBack
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
ummm Thats all I can really say, I had this error for the longest time I never really figured out what I did to make it work but after a while of messing with things I finally got it to work
@Drinfernoo I had just changed that, and my GUI flashed up for a second, but then I received an Internal Server Error. But I looked at the error log and found the error was in my GUI handler, knew instantly it wasn't calling the right thing. Turned out that the reason why I was getting an Internal Server Error was because I was calling my GUI in the server element method, instead of the container, changed it and now it works! Thanks. I will give credit to you in my mod.
@Leah Yeah, it is a bit of an annoying error but I now know what the problem was. Thanks for trying anyway, hope to see more tut's posted.
Rollback Post to RevisionRollBack
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
I've been working through the tutorial, and so far it all seems to be working properly. The only problem I'm having is that my game will crash if I try to shift+click an item.
I'm guessing shift+click should work and that I'm just missing a mistake in my code somewhere, but I wanted to check before I continue trying to find it. Any help would be greatly appreciated.
Actually, black is 0x000000 and white is 0xffffff lol Green is 0x00ff00 though
Either way, mine is set for 0xffffff, and it usually shows up white, but when I pick up the item in my first clickbar slot, it changes to a gray color. When I put the item back down it changes back to white. Basically, as long as that slot has something in it, it's white, but when the slot is empty, it turns gray.
EDIT: Definitely getting darker. It goes from 0xffffff to 0xd6d6d6.
And it does the same thing (gets darker) no matter what color I put in. Here's my code:
You have to increase the second parameter in the Slot constructor for each slot you add.
So my code looks like so:
Still haven't figured out the color thing yet :/
lol I thought you knew that thats why I didn't suggest? that lol, and I get black and white confused all the time
Noo
This tutorial explains that It's mostly in the "Finish the TileEntity***" section. Basically, you have to find which direction the player is facing in relation to the world, and texture the block accordingly.
Bear in mind that that tutorial is for ModLoader, but most of the code should still work in the Forge context.
private ItemStack[] inventory;
becomes
private ItemStack inventory;
And when accessing it, you drop the [0].
Of course, if you have more than one inventory, this doesn't apply.
Its better to do make it an array because if your going to change the amount of slots in the inventory then all you have to do is change the number that you registered when its declared, if you just go with ItemStack then it requires you to change more code than unnecessary. Not that you had a bad suggestion but I did put it like that for a reason, and btw I didn't know that the inventory would register like that never tried it, just used ItemStack[1] (and you can't register ItemStack[0] because its technically registering it as nothing lol) but still I get it)
This is true, but what type of container only holds one stack? lol
So I hopped on the forums again to see what I could do to resolve this issue (note that I DO have @NetworkMod in my code) and I was told to come to this tutorial and follow it. Now I wrote the code out EXACTLY like Leah had on the OP, still had the issue. Is there anything I can do to fix this issue.
If you need any additional info just say so. Thanks.
Code:
Main mod class:
If your wondering about the VertBase, it is a custom API I'm writing that aids me in developing more than 1 mod. This has NOTHING to do with the error.
Block class:
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
My Github page.
The entire Minecraft shader development community now has its own Discord server! Feel free to join and chat with all the developers!
Already tried that, I actually put the identifier there to see whether it would change anything.
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
My Github page.
The entire Minecraft shader development community now has its own Discord server! Feel free to join and chat with all the developers!
@Leah Yeah, it is a bit of an annoying error but I now know what the problem was. Thanks for trying anyway, hope to see more tut's posted.
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
My Github page.
The entire Minecraft shader development community now has its own Discord server! Feel free to join and chat with all the developers!
I'm guessing shift+click should work and that I'm just missing a mistake in my code somewhere, but I wanted to check before I continue trying to find it. Any help would be greatly appreciated.
Check out my Youtube Channel: http://www.youtube.com/user/Barodas22
I found it!
I had my if/else statements nested incorrectly in the transferStackInSlot() function.
Check out my Youtube Channel: http://www.youtube.com/user/Barodas22
Are you extending Container? And you have to define inventorySlots.