Jump to content

Naftoreiclag

Members
  • Posts

    8
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am semi-new!

Naftoreiclag's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. I tested to see if .getItem() for an ItemStack of Blocks returns null, and it does. ItemStack is = new ItemStack(block_multi, 1, 0); System.out.println(is.getItem()); Prints "null." I checked the tutorial, and it looks like it has some sort of ItemBlock to fill that null in. I'll check it to see if it fixes the problem.
  2. Thanks in advance for any help. I'm trying to register a name for my block for each of it's metadatas. (Similar to wool) I'm following the tutorial on the wiki http://www.minecraftforge.net/wiki/Metadata_Based_Subblocks, but can't seem to get past adding names for metadatas on a block. in ModMymod.java LanguageRegistry.addName(new ItemStack(multiBlock, 1, 0), "block zero"); LanguageRegistry.addName(new ItemStack(multiBlock, 1, 1), "block one"); LanguageRegistry.addName(new ItemStack(multiBlock, 1, 2), "block two"); ... GameRegistry.registerBlock(multiBlock, "mymod.multiblock"); However, addName refuses to accept an ItemStack of Blocks. I looked into the code for addName, and I believe the problem is due to it trying to return an Item from the ItemStack, and not checking for Blocks. in LanguageRegistery.java public void addNameForObject(Object objectToName, String lang, String name) { String objectName; if (objectToName instanceof Item) { objectName=((Item)objectToName).getUnlocalizedName(); } else if (objectToName instanceof Block) { objectName=((Block)objectToName).getUnlocalizedName(); } else if (objectToName instanceof ItemStack) { objectName=((ItemStack)objectToName).getItem().getUnlocalizedName((ItemStack)objectToName); <-------- DOES NOT CHECK FOR BLOCKS } else { throw new IllegalArgumentException(String.format("Illegal object for naming %s",objectToName)); } objectName+=".name"; addStringLocalization(objectName, lang, name); } public static void addName(Object objectToName, String name) { instance().addNameForObject(objectToName, "en_US", name); } I tried to find how vanilla minecraft implements it for wool/cloth blocks, but to no success.
  3. Add cases for the other ItemRenderType enums. (i.e. ENTITY, EQUIPPED_FIRST_PERSON, INVENTORY) EDIT: (Yeah, I got confused between EQUIPPED and EQUIPPED_FIRST_PERSON too...)
  4. How about just a simple "thank you"? Anyway, since you didn't provide the code for the model, I couldn't test it, so I just copied and pasted your code. (Like I expected you would have tried on your own...) Add this to the FryerRenderer class I made for you. private ModelFryer aModel; public FryerRenderer() { aModel = new ModelFryer(); } ... private void renderYourModel() { GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 0.0F, 0.0F); // play around with these numbers until you get it where you want it. (should work by itself) GL11.glRotatef(180F, 0F, 0F, 1F); bindTextureByName("/textures/blocks/FryerTexture.png"); aModel.renderAll(0.0625F); GL11.glPopMatrix(); } Also, I don't think you need to do two glPushMatrix()'s since you aren't doing anything special to your model between the second one and the first glPopMatrix(); one pair should be good enough.
  5. I don't know what you mean with insert opengl code Sorry this is first time i made a custom modeled block How are you rendering your "custom modeled block" then? Certainly there is some code you used. Did you use a wavefront (.obj)? Did you code it out yourself using those tedious openGL functions? Can you show me your class for rendering your tile entity? I kind of assumed that you already knew the rendering stuff; sorry if I confused you. I'll be able to help you if you show me your rendering code.
  6. Thanks! I guess I forgot that the code is run on both server and client... how embarrassing For future reference, here is the solution: I was logging the messages from both the server and the client on the same "channel" of messages, which led to confusion. (I believed that it was the server creating two entities, when it was really once for the server and client each.) Here is my code for logging messages to tell whether it's server or client: public static void sideLog(Level level, String msg) { if(FMLCommonHandler.instance().getEffectiveSide().isServer()) { logger.log(level, "Server-side: " + msg); } else if(FMLCommonHandler.instance().getEffectiveSide().isClient()) { logger.log(level, "Client-side: " + msg); } else { logger.log(level, "Unknown-side?: " + msg); } } Now to change the title from "unsolved" to "solved."
  7. Thank you in advance for any help. I'm not new to java (hobby programming in java for over a year and a half), but I'm still new to forge and how minecraft handles certain things. I'm trying to make a simple tile entity, but have run into some trouble. Problem: Whenever I my block is placed or loaded, the createTileEntity() method is called an additional time. (I put a logger in the constructor of my tile entity class to tell me whenever it is created, and I get its message an additional time.) I have already checked out both tutorials on the forge wiki, followed various video tutorials, and scanned through some of the source classes, but I can't figure out why my tile entity is being made multiple times. Examples: - When placing a block, I get the "created" message twice. - When loading a world with the block already placed, I get the "read" message and the "created" message. - When saving the world, I get the "write" message and the "created" message. I have stripped the code down as much as possible to test if any of my other code was interfering, but I still get these tile entity oddities. I am using the latest (as of posting) recommended build of forge. (Recommended-1.5.2 | 7.8.1.737) Code exactly as I compiled it (minus the imports): Mymod.java: package mymodpackage; @Mod(modid = "mymod", name = "My Mod", version = "1.0") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class Mymod { public static Logger logger; public static Block block_myblock; @PreInit public void preInit(FMLPreInitializationEvent event) { // Make a logger logger = Logger.getLogger("mymod"); logger.setParent(FMLLog.getLogger()); } @Init public void load(FMLInitializationEvent event { // Block block_myblock = new BlockMyblock(2000, Material.rock).setUnlocalizedName("myblock"); LanguageRegistry.addName(block_myblock, "Custom Block with Tile Entity"); GameRegistry.registerBlock(block_myblock, "mymod.myblock"); // Tile Entity GameRegistry.registerTileEntity(MyblockTileEntity.class, "mymod.myblockTileEntity"); } } BlockMyblock.java: package mymodpackage; public class BlockMyblock extends Block { public BlockMyblock(int par1, Material par2Material) { super(par1, par2Material); this.setCreativeTab(CreativeTabs.tabFood); } @Override public boolean hasTileEntity(int metadata) { return true; } @Override public TileEntity createTileEntity(World world, int metadata) { return new MyblockTileEntity(); } } MyblockTileEntity.java: package mymodpackage; public class MyblockTileEntity extends TileEntity { public MyblockTileEntity() { Mymod.logger.log(Level.INFO, "Created Tile Entity"); } @Override public void readFromNBT(NBTTagCompound par1NBTTagCompound) { Mymod.logger.log(Level.INFO, "readFromNBT is being called"); super.readFromNBT(par1NBTTagCompound); } @Override public void writeToNBT(NBTTagCompound par1NBTTagCompound) { Mymod.logger.log(Level.INFO, "writeToNBT is being called"); super.writeToNBT(par1NBTTagCompound); } } Could this be a forge bug in a recommended build!? EDIT: It's solved now. See bottom post.
  8. Since you are using a custom rendering method for the block in the overworld, then you also need to use a custom rendering method for the block in other cases, such as in your inventory. To do this, you need to create a IItemRenderer and register it for your block ID. For example, in your new class that implements IItemRenderer: public class FryerRenderer implements IItemRenderer { @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { return true; } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { return true; } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch(type) { case INVENTORY: { renderYourModel(); return; } default: return; } } private void renderYourModel() { // insert OpenGL code here.... } } Then, register it for your blockID in your mod class: MinecraftForgeClient.registerItemRenderer(block_fryer.blockID, new FryerRenderer()); Hope I helped!
×
×
  • Create New...

Important Information

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