Jump to content

intermediateuser

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by intermediateuser

  1. I just added them, but am I mistaken to think the NBT stuff is for storing and loading the tile entity's inventory? We're only dealing with player inventory here; the tile entity doesn't have an inventory (well, now it might, with the NBT stuff added). New code here, though the problem is unaffected: -snip- *impersonates Dirk Gently* "I believe in the fundamental interconnectedness of all things." ...Actually, I'm just trying various things and hoping something works. I can't find anything wrong. Hahaha alright then. Well, at least I know it is most likely that my logic isn't flawed, and the issue probably has something more to do with Minecraft or Forge. I really do appreciate you at least taking a look. A bit more info that has come to light: it seems that when I click an item in the inventory, the item that gets picked up is the one from the slot above it. I've run the process in a verbose manner, echoing the id's of the slots, and they seem to be placed in the correct order, but maybe this symptom of the problem tells of something you might know more about than a new modder does?
  2. I just added them, but am I mistaken to think the NBT stuff is for storing and loading the tile entity's inventory? We're only dealing with player inventory here; the tile entity doesn't have an inventory (well, now it might, with the NBT stuff added). New code here, though the problem is unaffected: package x.thealphaelement.tileentity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.StringTranslate; public class TileEntityMerchantBlock extends TileEntity implements IInventory { private ItemStack[] inventory = new ItemStack[8]; private boolean hasItem = false; public TileEntityMerchantBlock() { } public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this) { return false; } return par1EntityPlayer.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64D; } @Override public int getSizeInventory(){ return this.inventory.length; } @Override public ItemStack getStackInSlot(int index){ return this.inventory[index]; } @Override public ItemStack decrStackSize(int slot, int num){ if(this.inventory[slot]!=null){ ItemStack stack; if(this.inventory[slot].stackSize<=num){ stack = this.inventory[slot]; this.inventory[slot] = null; return stack; }else{ stack = this.inventory[slot].splitStack(num); if(this.inventory[slot].stackSize==0){ this.inventory[slot] = null; } return stack; } }else return null; } @Override public ItemStack getStackInSlotOnClosing(int index){ if(this.inventory[index]!=null){ ItemStack var2 = this.inventory[index]; this.inventory[index] = null; return var2; }else return null; } @Override public void setInventorySlotContents(int index, ItemStack stack){ this.inventory[index] = stack; if(stack!=null&&stack.stackSize>this.getInventoryStackLimit()){ stack.stackSize = this.getInventoryStackLimit(); } } @Override public String getInvName(){ return StringTranslate.getInstance().translateKey("merchantBlock.name"); } @Override public boolean isInvNameLocalized(){ return true; } @Override public int getInventoryStackLimit(){ return 64; } @Override public void openChest() { // TODO Auto-generated method stub } @Override public void closeChest() { // TODO Auto-generated method stub } @Override public boolean isStackValidForSlot(int i, ItemStack itemstack) { // TODO Auto-generated method stub return true; } @Override public void writeToNBT(NBTTagCompound tagCompound){ super.writeToNBT(tagCompound); NBTTagList tagList = new NBTTagList(); for(int i = 0; i<this.inventory.length; ++i){ if(this.inventory[i]!=null){ NBTTagCompound ntc3 = new NBTTagCompound(); ntc3.setByte("slot",(byte) i); this.inventory[i].writeToNBT(ntc3); tagList.appendTag(ntc3); } } tagCompound.setTag("items",tagList); } @Override public void readFromNBT(NBTTagCompound tagCompound){ super.readFromNBT(tagCompound); NBTTagList var2 = tagCompound.getTagList("items"); for(int i = 0; i<var2.tagCount(); ++i){ NBTTagCompound ntc3 = (NBTTagCompound) var2.tagAt(i); byte slot = ntc3.getByte("slot"); if(slot>=0&&slot<this.inventory.length){ this.inventory[slot] = ItemStack.loadItemStackFromNBT(ntc3); } } } }
  3. I thought that might be the case, so before updating my original post I did change my tile entity to this, but it had no effect: package x.thealphaelement.tileentity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.StringTranslate; public class TileEntityMerchantBlock extends TileEntity implements IInventory { private ItemStack[] inventory = new ItemStack[8]; private boolean hasItem = false; public TileEntityMerchantBlock() { } public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this) { return false; } return par1EntityPlayer.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64D; } @Override public int getSizeInventory(){ return this.inventory.length; } @Override public ItemStack getStackInSlot(int index){ return this.inventory[index]; } @Override public ItemStack decrStackSize(int slot, int num){ if(this.inventory[slot]!=null){ ItemStack stack; if(this.inventory[slot].stackSize<=num){ stack = this.inventory[slot]; this.inventory[slot] = null; return stack; }else{ stack = this.inventory[slot].splitStack(num); if(this.inventory[slot].stackSize==0){ this.inventory[slot] = null; } return stack; } }else return null; } @Override public ItemStack getStackInSlotOnClosing(int index){ if(this.inventory[index]!=null){ ItemStack var2 = this.inventory[index]; this.inventory[index] = null; return var2; }else return null; } @Override public void setInventorySlotContents(int index, ItemStack stack){ this.inventory[index] = stack; if(stack!=null&&stack.stackSize>this.getInventoryStackLimit()){ stack.stackSize = this.getInventoryStackLimit(); } } @Override public String getInvName(){ return StringTranslate.getInstance().translateKey("merchantBlock.name"); } @Override public boolean isInvNameLocalized(){ return true; } @Override public int getInventoryStackLimit(){ return 64; } @Override public void openChest() { // TODO Auto-generated method stub } @Override public void closeChest() { // TODO Auto-generated method stub } @Override public boolean isStackValidForSlot(int i, ItemStack itemstack) { // TODO Auto-generated method stub return true; } } Then I reverted back to my original, barebones tile entity, seeing that the change didn't seem significant. Am I editing the wrong methods in the tile entity? Also, I suppose I'm confused as to how the tile entity can affect this because although the tile entity is called in the block's constructor, the tile entity is never actually used in the code.
  4. Thanks for the help. The problem persists quite stubbornly... as for my tile entity, I've updated the original post with it. But it's mostly empty; I didn't think the tile entity had anything to do with the player's inventory. The gui and block aren't calling for the block's inventory at all; for now, it's just trying to properly bind the player's inventory to the gui/container. But, if you can see something in the mostly barebones tile entity, please let me know.
  5. I've done that; it has no effect. I tried making canInteractWith() always return true again with your code from above too, and the block still does not activate with the proposed change, so I simply changed it back.
  6. Well man, if I come up with a solution I'll post here. I hope you'll do the same!
  7. Thank you so much for the response. I've honestly been working on this sole issue for about 3 days. When I make your change, though, the block simply doesn't activate anymore, lol. This is really confusing.
  8. I have a very simple block. When you right-click that block, there appears a very simple GUI that, currently, only has one placeholder button and the player's inventory. The items in the player's inventory appear to be placed correctly, but when clicked, they hop to the cursor then immediately drop back into the inventory. Sometimes I can pick up an item but it doesn't appear to *actually* be happening when I click again; or the item disappears entirely; or the item is dropped into the world. Edit: added the tile entity and my proxies, for reference. MerchantBlock.java package x.thealphaelement.block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import x.thealphaelement.TheAlphaElement; import x.thealphaelement.tileentity.TileEntityMerchantBlock; public class MerchantBlock extends BlockContainer { private InventoryPlayer playerInventory; public MerchantBlock (int id, int texture, Material material) { super(id, material); setHardness(0.3F); setStepSound(soundWoodFootstep); setUnlocalizedName("merchantBlock"); setCreativeTab(CreativeTabs.tabDecorations); } public void registerIcons(IconRegister iconRegister) { blockIcon = iconRegister.registerIcon("TheAlphaElement:blocktest"); } public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { TileEntityMerchantBlock merchantBlock = (TileEntityMerchantBlock)par1World.getBlockTileEntity(par2, par3, par4); par5EntityPlayer.openGui(TheAlphaElement.instance, 0, par1World, par2, par3, par4); return true; } @Override public TileEntity createNewTileEntity(World world) { return new TileEntityMerchantBlock(); } GuiMerchantBlock.java package x.thealphaelement.client.gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; import org.lwjgl.opengl.GL11; import x.thealphaelement.tileentity.TileEntityMerchantBlock; public class GuiMerchantBlock extends GuiContainer { public final int xSizeOfTexture = 176; public final int ySizeOfTexture = 207; private int inventoryRows = 0; private EntityPlayer player; public GuiMerchantBlock(EntityPlayer player, TileEntityMerchantBlock te) { super(new ContainerMerchantBlock(player.inventory, te)); this.player = player; short short1 = 223; int i = short1 - 108; this.inventoryRows = player.inventory.getSizeInventory() / 9; this.ySize = i + this.inventoryRows * 18; } public void initGui() { super.initGui(); int posX = (this.width - xSizeOfTexture) / 2; int posY = (this.height - ySizeOfTexture) / 2; this.buttonList.clear(); this.buttonList.add(new GuiButton(0, posX+ 40, posY + 40, 100, 20, "no use")); } @Override public boolean doesGuiPauseGame() { return false; } @Override protected void keyTyped(char par1, int par2) { if (par2 == 1 || par2 == this.mc.gameSettings.keyBindInventory.keyCode) { this.mc.thePlayer.closeScreen(); } } public void actionPerformed(GuiButton button) { switch(button.id) { case 0: player.addChatMessage("Good job!"); break; default: } } @Override protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture("/mods/TheAlphaElement/textures/gui/generalMerchant.png"); int posX = (this.width - xSizeOfTexture) / 2; int posY = (this.height - ySizeOfTexture) / 2; drawTexturedModalRect(posX, posY, 0, 0, this.xSize, ySizeOfTexture); } } ContainerMerchantBlock.java package x.thealphaelement.client.gui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import x.thealphaelement.tileentity.TileEntityMerchantBlock; public class ContainerMerchantBlock extends Container { private TileEntityMerchantBlock tileEntity; private int numRows; protected IInventory playerInventory; public ContainerMerchantBlock(InventoryPlayer playerInv, TileEntityMerchantBlock te) { tileEntity = te; playerInventory = playerInv; playerInv.openChest(); this.numRows = playerInv.getSizeInventory() / 9; int i = (this.numRows - 4) * 18; int j; int k; for (j = 0; j < 3; ++j) { for (k = 0; k < 9; ++k) { this.addSlotToContainer(new Slot(playerInv, k + j * 9 + 9, 8 + k * 18, 115 + j * 18 + i)); } } for (j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(playerInv, j, 8 + j * 18, 173 + i)); } } @Override public boolean canInteractWith(EntityPlayer entityplayer) { return playerInventory.isUseableByPlayer(entityplayer); } public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { return null; } } TileEntityMerchantBlock.java package x.thealphaelement.tileentity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; public class TileEntityMerchantBlock extends TileEntity implements IInventory { public TileEntityMerchantBlock() { } public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this) { return false; } return par1EntityPlayer.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64D; } @Override public int getSizeInventory() { // TODO Auto-generated method stub return 0; } @Override public ItemStack getStackInSlot(int i) { // TODO Auto-generated method stub return null; } @Override public ItemStack decrStackSize(int i, int j) { // TODO Auto-generated method stub return null; } @Override public ItemStack getStackInSlotOnClosing(int i) { // TODO Auto-generated method stub return null; } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { // TODO Auto-generated method stub } @Override public String getInvName() { // TODO Auto-generated method stub return null; } @Override public boolean isInvNameLocalized() { // TODO Auto-generated method stub return false; } @Override public int getInventoryStackLimit() { // TODO Auto-generated method stub return 0; } @Override public void openChest() { // TODO Auto-generated method stub } @Override public void closeChest() { // TODO Auto-generated method stub } @Override public boolean isStackValidForSlot(int i, ItemStack itemstack) { // TODO Auto-generated method stub return false; } } ClientProxy.java package x.thealphaelement.client; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import x.thealphaelement.CommonProxy; import x.thealphaelement.client.gui.GuiMerchantBlock; import x.thealphaelement.client.renderer.RenderBlazeModded; import x.thealphaelement.client.renderer.RenderCreeperModded; import x.thealphaelement.client.renderer.RenderEndermanModded; import x.thealphaelement.client.renderer.RenderGhastModded; import x.thealphaelement.client.renderer.RenderSkeletonModded; import x.thealphaelement.client.renderer.RenderSpiderModded; import x.thealphaelement.client.renderer.RenderWitchModded; import x.thealphaelement.client.renderer.RenderZombieModded; import x.thealphaelement.entity.monster.EntityBlazeModded; import x.thealphaelement.entity.monster.EntityBlueSkeleton; import x.thealphaelement.entity.monster.EntityBlueSpider; import x.thealphaelement.entity.monster.EntityBlueZombie; import x.thealphaelement.entity.monster.EntityCaveSpiderModded; import x.thealphaelement.entity.monster.EntityCreeperModded; import x.thealphaelement.entity.monster.EntityEndermanModded; import x.thealphaelement.entity.monster.EntityGhastModded; import x.thealphaelement.entity.monster.EntityPigZombieModded; import x.thealphaelement.entity.monster.EntityRedSkeleton; import x.thealphaelement.entity.monster.EntityRedSpider; import x.thealphaelement.entity.monster.EntityRedZombie; import x.thealphaelement.entity.monster.EntitySkeletonModded; import x.thealphaelement.entity.monster.EntitySpiderModded; import x.thealphaelement.entity.monster.EntitySpiderling; import x.thealphaelement.entity.monster.EntityWitchModded; import x.thealphaelement.entity.monster.EntityZombieModded; import x.thealphaelement.tileentity.TileEntityMerchantBlock; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.EntityRegistry; public class ClientProxy extends CommonProxy { @Override public void registerRenderers() { RenderingRegistry.registerEntityRenderingHandler(EntitySkeletonModded.class, new RenderSkeletonModded()); EntityRegistry.registerGlobalEntityID(EntitySkeletonModded.class, "NormalSkeleton", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityZombieModded.class, new RenderZombieModded()); EntityRegistry.registerGlobalEntityID(EntityZombieModded.class, "NormalZombie", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntitySpiderModded.class, new RenderSpiderModded()); EntityRegistry.registerGlobalEntityID(EntitySpiderModded.class, "NormalSpider", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityCreeperModded.class, new RenderCreeperModded()); EntityRegistry.registerGlobalEntityID(EntityCreeperModded.class, "NormalCreeper", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityEndermanModded.class, new RenderEndermanModded()); EntityRegistry.registerGlobalEntityID(EntityEndermanModded.class, "NormalEnderman", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityCaveSpiderModded.class, new RenderSpiderModded()); EntityRegistry.registerGlobalEntityID(EntityCaveSpiderModded.class, "NormalCaveSpider", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityWitchModded.class, new RenderWitchModded()); EntityRegistry.registerGlobalEntityID(EntityWitchModded.class, "NormalWitch", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityBlazeModded.class, new RenderBlazeModded()); EntityRegistry.registerGlobalEntityID(EntityBlazeModded.class, "NormalBlaze", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityGhastModded.class, new RenderGhastModded()); EntityRegistry.registerGlobalEntityID(EntityGhastModded.class, "NormalGhast", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityPigZombieModded.class, new RenderZombieModded()); EntityRegistry.registerGlobalEntityID(EntityPigZombieModded.class, "NormalPigZombie", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityRedZombie.class, new RenderZombieModded()); EntityRegistry.registerGlobalEntityID(EntityRedZombie.class, "RedZombie", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityBlueZombie.class, new RenderZombieModded()); EntityRegistry.registerGlobalEntityID(EntityBlueZombie.class, "BlueZombie", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityRedSkeleton.class, new RenderSkeletonModded()); EntityRegistry.registerGlobalEntityID(EntityRedSkeleton.class, "RedSkeleton", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityBlueSkeleton.class, new RenderSkeletonModded()); EntityRegistry.registerGlobalEntityID(EntityBlueSkeleton.class, "BlueSkeleton", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityRedSpider.class, new RenderSpiderModded()); EntityRegistry.registerGlobalEntityID(EntityRedSpider.class, "RedSpider", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntityBlueSpider.class, new RenderSpiderModded()); EntityRegistry.registerGlobalEntityID(EntityBlueSpider.class, "BlueSpider", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); RenderingRegistry.registerEntityRenderingHandler(EntitySpiderling.class, new RenderSpiderModded()); EntityRegistry.registerGlobalEntityID(EntitySpiderling.class, "Spiderling", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102); } public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if (tileEntity != null) { switch(ID) { case 0: return new GuiMerchantBlock(player, (TileEntityMerchantBlock)tileEntity); // your GUIs go here } } return null; } } CommonProxy.java package x.thealphaelement; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; public class CommonProxy implements IGuiHandler { // Client stuff public void registerRenderers() { // Nothing here as the server doesn't render graphics! } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // TODO Auto-generated method stub return null; } } I feel like I'm really close here. Any ideas?
  9. I've been checking this post for the past day or so hoping to find a solution to this same problem... can you share how you did it at least, if not your code? Or PM me? there is a little problem. The Container ask very much the tileEntity What is todo. And you have to read the tile entity to understand. And i will not show it until i can released in my mod^^" I am afraid of someone steals my code. What i did was extending only the furnace stacking. I made it modular. Not more. I see, actually I think the issue I'm having is only a bit similar but not the same. Thanks for replying.
  10. I've been checking this post for the past day or so hoping to find a solution to this same problem... can you share how you did it at least, if not your code? Or PM me?
  11. So I have a GUI populated with a player's inventory. In default Minecraft resolution, the inventory icons line up properly. But when I maximize, the items are a bit to the left and too high up on the screen. Any idea why this might be? Also, I can't seem to pick up any of the items... clicking the items seems to drop them on the ground. Relevant code: for (int row = 0; row < 3; row++) { for (int slot = 0; slot < 9; slot++) { addSlotToContainer(new Slot(playerInv, slot + row * 9+9, 133 + slot * 18, 141 + row * 18)); } } for (int slot = 0; slot < 9; slot++) { addSlotToContainer(new Slot(playerInv, slot, 133 + slot * 18, 199)); }
  12. Sorry, the search feature here is clunky at its very best! I did try it. Something like 8 of the top 20 posts returned for "texture" or "textures" direct to a thread where I've posted that image. It's easier when you know precisely what you're looking for! It's frustrating, I know, to answer the same questions from different people over and over again, and I really do appreciate it.
  13. Well, there should be a redirect to some updated tutorials on this board... Gosh I'd love that. Searching for Forge tutorials is rough. Even knowing Java, a new modder gets lost in all this and what makes it so much harder is that there are SO many tutorials that are flat out wrong because they're outdated (but nowhere do they indicate that they are). Time is wasted figuring out exactly where they're wrong, because going through Minecraft's source code all you see are par1, par2, par3 (very nondescript parameters). Trying to decode Minecraft's source after a tutorial has gotten you 90% of the way there isn't easy, even for someone who's not a java newbie. Another problem is that most of these misleading tutorials are the only source for the information a new modder is seeking.
  14. Sorry, the search feature here is clunky at its very best! I did try it. I read that tutorial, it confused me because it talks about "icons," which, to me, imply the icons in inventories and hotbars and such. Thanks for clearing it up!
  15. I have a block mostly set up, I just need to know how to texture it. The "basic" tutorial on the wiki is dated; it tells beginners to use a block's getTextureFile() method and that doesn't seem to exist anymore.
  16. That's exactly what I needed. Thank you!
  17. Is there an easy way to tell how old the game world is? I know entities have a "ticksExisted" variable, but I can't find such a thing for the game world. It's possible I'm not looking in the right places, so if I am, please let me know. Alternatively, if there is no such easy reference, I'd like to use NBT to write to a file the timestamp the world is first generated, and from that point on I can just have methods check against that to determine how old that particular game world is. Is there a file that contains world data like this? If so, how do I write to it and read from it?
  18. Been trying to figure this out for two days. Can anyone help?
  19. Actually now that I have a chance to work on this some more, this whole bit just confuses me. Why do I need a special renderer? Can I just have a block, a tile entity, and have that tile entity called in onBlockActivated()? The whole point is to draw a GUI when a block is right-clicked, and I'm not seeing much information about drawing a gui anywhere really.
  20. Thanks so much. Just understanding the basic structure of what I'm trying to do here will help a good deal. In this example, should MyTileEntityRenderer also implement IMerchant and IInventory? Rendering a gui is still a little confusing to me, but I know I need at least one of those two.
  21. I think more information might help me get an answer while I'm AFK so hopefully when I come back I can progress. I've already made a block, and I've got a tile entity class for it (but I don't know if the tile entity class is functional or even written properly). I've read about "containers" but I don't think the word "container" means the same thing when making a tile entity that it does in game. I think I have a container class, but I don't really know what it does. And I don't know how to draw the gui. The only reason I'm asking such broad questions here is because I can't find any good, up-to-date, and comprehensive information anywhere else. I am not a total noob; I know how to do use Forge and I know intermediate Java. I already have done some significant work on my mod, I just need to know the procedure for making and using tile entities to do what I mentioned in the original post. Any help at all would be appreciated. Thanks
  22. There are bits and pieces of up-to-date information about Tile Entities here, on the wiki, on YouTube videos, and of course in Minecraft's source itself, but while I have been looking through all these things for hours I can't get a clear picture of how I'm supposed to make and use Tile Entities. Can someone tell me the fundamentals of making and using them? As an example, I'd like to make a block that, when right-clicked, will open up a trade window that's essentially identical to a villager's trade window.
  23. I made a new weapon, and mobs can pick it up. Thing is, the weapon should break after one use whether used by a player or a mob. It breaks properly when used by a player, but mobs can keep using it if they pick it up. What's the best way to implement this? The item I created does not show up in Item.itemsList[] so I can't look it up that way for an if statement.
  24. Thanks for the response. I actually already resolved this on my own (I feel the need to mention that because it's significant for me!) and indeed I did do it with an event. I'll update the original post with how to do it so others who might be looking to do this can hopefully find a resolution.
  25. UPDATE - SOLVED So I figured out how to do this. It's actually pretty simple. First, create a new class anywhere in your mod, and call it "EntityJoinWorldHandler" or "SpawnHandler" or "SpawnEvent" or whatever you want, as long as it makes sense to you. The class should look like this: package your.own.package.here; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntitySpider; import net.minecraft.entity.monster.EntityZombie; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.EntityJoinWorldEvent; public class EntityJoinWorldHandler { @ForgeSubscribe public void onEntitySpawn(EntityJoinWorldEvent event) { if(event.entity instanceof EntitySkeleton || event.entity instanceof EntityZombie || event.entity instanceof EntitySpider) { event.setCanceled(true); } } } Note: "onEntitySpawn()" can be named whatever you want, too. The method name does not actually matter. The class above sets up an event listener that listens for EntityJoinWorldEvent events, which means anytime an entity (like a mob) is spawned into the world, this event triggers. The if statement within the class checks if the entity spawning is an EntitySkeleton, EntityZombie, or an EntitySpider, and if it's any of those, it cancels the event. As a result, the mob doesn't spawn in. But you're not done yet. You still have to register this listener with your mod! To do that, go into your mod's base class and, in the load() method (under @Init), add this line: MinecraftForge.EVENT_BUS.register(new EntityJoinWorldHandler()); Note: "EntityJoinWorldHandler()" should be whatever you named the class above. Eclipse will probably ask you to import your new class into your base class. And that's it! When you run your mod, skeletons, zombies, and spiders will no longer spawn. Now you can add your own mobs to replace them if you like, or do whatever else your mod needs. Ciao! Original post below: So in net.minecraft.world.SpawnerAnimals.java there's an array that, I'm guessing, tells the game what mobs to spawn at night. The array is: /** An array of entity classes that spawn at night. */ protected static final Class[] nightSpawnEntities = new Class[] {EntitySpider.class, EntityZombie.class, EntitySkeleton.class}; Is there a way, without editing the base classes, to access and modify this array from within my mod? I do something similar with the Block.blocksList[] array by removing vanilla blocks from it and registering my own blocks in their places. Can I do something like that here, to modify this nightSpawnEntities array? Or, is there a different way to remove vanilla spawns that I haven't considered yet?
×
×
  • Create New...

Important Information

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