Jump to content

Casual Dutchman

Members
  • Posts

    98
  • Joined

  • Last visited

Everything posted by Casual Dutchman

  1. I dont want to make an overlay like the leather armor, but an overlay of textures.
  2. Guys you're not really helping him, you're just judging him on his use of characters. That is not why we are here right?
  3. When making an API, you MUST use it in your own mod! Your mod need to refer to the API methodes. so when other modders are using your API, your mod will also refer to their's
  4. I want to make a armor (with custom model), check! I want to have the custom model texture to be drawn on the custom model, check! Now, this is the part, were it goes wrong. I want to make another armor, but with the different overlays. ItemRenderPass(), I got that, but the texture drawn on the armor model is not working. I want the vanilla armor textures to be drawn as an overlay on the armor. How do I do this?
  5. Where is the regiserTileEntity called? it must be in the perInit of Init methode in your main class. Or, in your case, in the RegBlock.somthing() methode.
  6. seems like my EntityTest does not like the world.getEntitybyID(int i) My other, let's say 'real' entity, likes it a lot. Thanks for helping!
  7. Now, I have a very diferent problem. Caused by: java.lang.NullPointerException at net.minecraft.item.ItemStack.getAttributeModifiers(ItemStack.java:884) ~[itemStack.class:?] at net.minecraft.entity.EntityLivingBase.writeEntityToNBT(EntityLivingBase.java:503) ~[EntityLivingBase.class:?] at net.minecraft.entity.EntityLiving.writeEntityToNBT(EntityLiving.java:313) ~[EntityLiving.class:?] at mefa.Entities.EntityTest.writeEntityToNBT(EntityTest.java:94) ~[EntityTest.class:?] at net.minecraft.entity.Entity.writeToNBT(Entity.java:1562) ~[Entity.class:?] // //OR // java.lang.NullPointerException: Ticking entity at net.minecraft.item.ItemStack.getAttributeModifiers(ItemStack.java:884) at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1812) at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:250) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2254) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:697) at net.minecraft.world.World.updateEntity(World.java:2214) at net.minecraft.world.World.updateEntities(World.java:2064) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:528)
  8. Okay, I will say ´this´ in the interact methode. I know how to get the entityID. But how do I pass the entityID?
  9. Okay, so I saw your tutorial of the simple network wrapper. http://www.minecraftforge.net/forum/index.php/topic,20135.0.html Can I use this to get the container to work? What kind of packets do I need to use?
  10. Broken? How do you mean? I can just use it. When the outcome entity of the methode is not null, it'll print out text. and it did. Why is it broken?
  11. I made a Container, but it does not do what i want it to do. When I place an item in a slot, quit the world and then load the world, The item in that slot is gone. It will not take it either. When I place the item inside, The cursor will still have the item, but the slot too. Container and Gui are not different then my other containers and GUIs, those work perfectly! Only the Guihandler is slightly different. btw, it is a container for a mob. public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { switch(id){ case 6: EntityTest test = getUnitMouseOver2(5, 0, player); System.out.println("calling Container"); return new ContainerTest(player.inventory, test.inventory, test); } return null; } @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { switch(id){ case 6: EntityTest test = getUnitMouseOver2(5, 0, player); System.out.println("calling Gui"); return new GuiTest(player.inventory, test.inventory, test); } return null; } public static MovingObjectPosition getMouseOver(double distance, float f) { Minecraft mc = FMLClientHandler.instance().getClient(); if (mc.renderViewEntity != null) { if (mc.theWorld != null) { double var2 = distance; MovingObjectPosition mouseOver = mc.renderViewEntity.rayTrace(var2, f); Vec3 var6 = mc.renderViewEntity.getPosition(f); double var4 = var2; if (mouseOver != null) { var4 = mouseOver.hitVec.distanceTo(var6); } Vec3 var7 = mc.renderViewEntity.getLook(f); Vec3 var8 = var6.addVector(var7.xCoord * var2, var7.yCoord * var2, var7.zCoord * var2); Entity pointedEntity = null; float var9 = 1.0F; List var10 = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.renderViewEntity, mc.renderViewEntity.boundingBox.addCoord(var7.xCoord * var2, var7.yCoord * var2, var7.zCoord * var2).expand((double)var9, (double)var9, (double)var9)); double var11 = var4; Iterator var13 = var10.iterator(); while (var13.hasNext()) { Entity var14 = (Entity)var13.next(); if (var14.canBeCollidedWith()) { float var15 = var14.getCollisionBorderSize(); AxisAlignedBB var16 = var14.boundingBox.expand((double)var15, (double)var15, (double)var15); MovingObjectPosition var17 = var16.calculateIntercept(var6, var8); if (var16.isVecInside(var6)) { if (0.0D < var11 || var11 == 0.0D) { pointedEntity = var14; var11 = 0.0D; } } else if (var17 != null) { double var18 = var6.distanceTo(var17.hitVec); if (var18 < var11 || var11 == 0.0D) { pointedEntity = var14; var11 = var18; } } } } if (pointedEntity != null && (var11 < var4 || mouseOver == null)) { mouseOver = new MovingObjectPosition(pointedEntity); } return mouseOver; } } return null; } public static EntityTest getUnitMouseOver2(double distance, float f, EntityPlayer player){ MovingObjectPosition mouseOver = getMouseOver(distance, f); if(mouseOver != null && mouseOver.entityHit != null && mouseOver.entityHit instanceof EntityTest){ return (EntityTest) mouseOver.entityHit; }else return null; } Interact part of the entity: public boolean interact(EntityPlayer par1EntityPlayer) { if(par1EntityPlayer.isSneaking() && !this.worldObj.isRemote) { par1EntityPlayer.openGui(Core.instance, 6, par1EntityPlayer.worldObj, (int)par1EntityPlayer.posX, (int)par1EntityPlayer.posY, (int)par1EntityPlayer.posZ); } return super.interact(par1EntityPlayer); }
  12. I have no idea why you guys are all watching these 'tutorials' and then be sad. These 'tutorials' basicly are copies of the normal, vanilla code. It might be a little bit modified, but not a whole lot. Why don't you just take a loot at the vanilla code and try to modify it with that information.
  13. Let me be clear with the different slot I created, It basicly is the normal slot, but then modified to change the EntityHireable's equipment. It works fine, but it does not save it to the entity. When I quit en open the world again, the entity has not changed equipment. Code here: package mefa.client.Gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mefa.Entities.EntityHireable; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; public class slotInv extends Slot { /** The index of the slot in the inventory. */ private final int slotIndex; /** The inventory we want to extract a slot from. */ public final IInventory inventory; public final EntityHireable hireable; /** the id of the slot(also the index in the inventory arraylist) */ public int slotNumber; /** display position of the inventory slot on the screen x axis */ public int xDisplayPosition; /** display position of the inventory slot on the screen y axis */ public int yDisplayPosition; private static final String __OBFID = "CL_00001762"; /** Position within background texture file, normally -1 which causes no background to be drawn. */ protected IIcon backgroundIcon = null; /** Background texture file assigned to this slot, if any. Vanilla "/gui/items.png" is used if this is null. */ @SideOnly(Side.CLIENT) protected ResourceLocation texture; public slotInv(IInventory par1IInventory, int par2, int par3, int par4) { super(par1IInventory, par2, par3, par4); this.inventory = par1IInventory; this.hireable = null; this.slotIndex = par2; this.xDisplayPosition = par3; this.yDisplayPosition = par4; } public slotInv(EntityHireable par1IInventory, int par2, int par3, int par4) { super(null, par2, par3, par4); this.hireable = par1IInventory; this.inventory = null; this.slotIndex = par2; this.xDisplayPosition = par3; this.yDisplayPosition = par4; } public void onSlotChange(ItemStack par1ItemStack, ItemStack par2ItemStack) { if (par1ItemStack != null && par2ItemStack != null) { if (par1ItemStack.getItem() == par2ItemStack.getItem()) { int i = par2ItemStack.stackSize - par1ItemStack.stackSize; if (i > 0) { this.onCrafting(par1ItemStack, i); } } } } protected void onCrafting(ItemStack par1ItemStack, int par2) {} protected void onCrafting(ItemStack par1ItemStack) {} public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) { this.onSlotChanged(); } public boolean isItemValid(ItemStack par1ItemStack) { return true; } public ItemStack getStack() { if(this.inventory != null){ return this.inventory.getStackInSlot(this.slotIndex); }else{ return this.hireable.getEquipmentInSlot(this.slotIndex); } } public boolean getHasStack() { return this.getStack() != null; } public void putStack(ItemStack par1ItemStack) { if(this.inventory != null){ this.inventory.setInventorySlotContents(slotIndex, par1ItemStack); }else{ this.hireable.setCurrentItemOrArmor(slotIndex, par1ItemStack); } this.onSlotChanged(); } public void onSlotChanged() { if(this.inventory != null){ this.inventory.markDirty();; } } public int getSlotStackLimit() { if(this.inventory != null){ return this.inventory.getInventoryStackLimit(); }else{ return 5; } } public ItemStack decrStackSize(int par1) { int i = this.hireable.getEquipmentInSlot(this.slotIndex).stackSize; ItemStack item = this.hireable.getEquipmentInSlot(this.slotIndex); boolean Size = item.stackSize - par1 > 0; ItemStack item2 = new ItemStack(item.getItem(), item.getItemDamage(), item.stackSize - par1); if(this.inventory != null){ return this.inventory.decrStackSize(this.slotIndex, par1); }else{ return Size ? item2 : (ItemStack)null; } } public boolean isSlotInInventory(IInventory par1IInventory, int par2) { return par1IInventory == this.inventory && par2 == this.slotIndex; } public boolean canTakeStack(EntityPlayer par1EntityPlayer) { return true; } @SideOnly(Side.CLIENT) public IIcon getBackgroundIconIndex() { return backgroundIcon; } @SideOnly(Side.CLIENT) public boolean func_111238_b() { return true; } @SideOnly(Side.CLIENT) public ResourceLocation getBackgroundIconTexture() { return (texture == null ? TextureMap.locationItemsTexture : texture); } public void setBackgroundIcon(IIcon icon) { backgroundIcon = icon; } @SideOnly(Side.CLIENT) public void setBackgroundIconTexture(ResourceLocation texture) { this.texture = texture; } public int getSlotIndex() { /** The index of the slot in the inventory. */ return slotIndex; } }[code]
  14. Alright, but that does not answer my question about the container. It is nog called by the server. everytime I change something in the container, it will not save. when i quit and load again, it does not load the changed stuff.
  15. public class KeyHandler { public static final int W= 0; private static final String[] desc = {"key"}; private static final int[] keyValues = {Keyboard.KEY_W}; private final KeyBinding[] keys; public KeyHandler() { keys = new KeyBinding[desc.length]; for (int i = 0; i < desc.length; ++i) { keys[i] = new KeyBinding("modid.key." + desc[i], keyValues[i], "modid.key.category"); ClientRegistry.registerKeyBinding(keys[i]); } } @SubscribeEvent public void onKeyInput(KeyInputEvent event) { if (!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) { if (keys[W].isPressed()) { "Event" } } } } dont forget to register the event!
  16. It will still find it's own path, you need to set the path to null this.aiSit.setSitting(!this.isSitting()); this.isJumping = false; this.setPathToEntity((PathEntity)null); this.setTarget((Entity)null); this.setAttackTarget((EntityLivingBase)null); Also, use a simple methode to check if it is called, that could be a problem too. System.out.println("test message"); if the methode is called, your console will say "test message" if it is not called, well you need to change some things.
  17. Okay, I got things running now. I'm using a methode that will detect a mob in front of you. When the mob is in front of you, it will open the gui. EntityPlayer.opengui(more stuff); It is working, Im also using a Container, it looks great. The only downside -> the container does not do its job. When I place a ItemStack in a Slot and I quit and open the world again, all the changes I made are gone. I have Guihandler and I Know that the server part for the container is called. just like the client side, GUI. Why is it still not behaving properly? code: Gui: private static final ResourceLocation tex = new ResourceLocation(Core.getModID(), "textures/gui/hireable.png"); EntityHireable hireable; public GuiHireable(EntityPlayer player, EntityHireable entity) { super(new ContainerHireable(player, entity)); hireable = entity; } protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { //TODO } @Override protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(tex); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); } Container: extends Container{ EntityHireable Hire; public ContainerHireable(EntityPlayer player, EntityHireable entity){ Hire = entity; int i; this.addSlotToContainer(new slotInv(entity, 0, 80, 62) { private static final String __OBFID = "CL_00001755"; public int getSlotStackLimit() { return 1; } public boolean isItemValid(ItemStack par1ItemStack) { if (par1ItemStack == null) return false; return par1ItemStack.getItem() instanceof ItemSword; } }); for (i = 0; i < 4; ++i) { final int k = i; this.addSlotToContainer(new slotInv(entity, 4 - i, 8, 8 + i * 18) { private static final String __OBFID = "CL_00001755"; public int getSlotStackLimit() { return 1; } public boolean isItemValid(ItemStack par1ItemStack) { if (par1ItemStack == null) return false; return par1ItemStack.getItem().isValidArmor(par1ItemStack, k, Hire); } @SideOnly(Side.CLIENT) public IIcon getBackgroundIconIndex() { return ItemArmor.func_94602_b(k); } }); } for (i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); } } @Override public boolean canInteractWith(EntityPlayer par1EntityPlayer) { return this.Hire.isEntityAlive() && this.Hire.getDistanceToEntity(par1EntityPlayer) < 8.0F; } //TODO public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(par2); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (par2 == 0) { if (!this.mergeItemStack(itemstack1, 0, 39, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } else if (par2 != 1 && par2 != 0) { if (par2 >= 3 && par2 < 30) { if (!this.mergeItemStack(itemstack1, 30, 39, false)) { return null; } } else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) { return null; } } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } if (itemstack1.stackSize == itemstack.stackSize) { return null; } slot.onPickupFromSlot(par1EntityPlayer, itemstack1); } return itemstack; } } Interact part of the EntityHireable: public boolean interact(EntityPlayer par1EntityPlayer) { EntityHireable hire = GuiHandler.getUnitMouseOver(5, 0, par1EntityPlayer); if(hire != null && hire.isTamed() && !hire.isAngry() && par1EntityPlayer.getCommandSenderName() == hire.getOwnerName()) { System.out.println("wohoo"); par1EntityPlayer.openGui(Core.instance, 5, par1EntityPlayer.worldObj, 0, 0, 0); } return super.interact(par1EntityPlayer); } GuiHandler.getUnitMouseOver is a methode that will retun a EntityHireable in this case. I can use this in the GuiHandler class to get the entity of which I want to get information Trust me the MouseOver methode works. @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { switch(id){ case 5: EntityHireable hire = getUnitMouseOver(5, 0, player); System.out.println("calling Container"); return new ContainerHireable(player, hire); } return null; } @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { switch(id){ case 5: EntityHireable hire = getUnitMouseOver(5, 0, player); System.out.println("calling Gui"); return new GuiHireable(player, hire); } return null; }
  18. I made a mob and a GUI. When I right-click the mob, it will open the GUI, just as I wanted. There is a button on the gui, when I click the event is called, just as I wanted. But when I quit the game and open the world again, The event is cancelled. lets say a block would appear above its head, when the button is clicked. It will happen and it will stay there until the session is ended. When I quit and open the world again, the block is gone. What is the solution? Here is the interact code I use: public boolean interact(EntityPlayer par1EntityPlayer) { if(par1EntityPlayer.isSneaking() && par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && this.isTamed() && par1EntityPlayer.inventory.getCurrentItem() == null) { Minecraft mc = Minecraft.getMinecraft(); mc.displayGuiScreen(new Gui(this)); } else{ } return super.interact(par1EntityPlayer); } This is the GUI code: private static final ResourceLocation tex = new ResourceLocation(Core.getModID(), "textures/gui/hireable.png"); public final int xSizeOfTexture = 128; public final int ySizeOfTexture = 166; EntityHireable hireable; public GuiHireable(EntityHireable entity) { hireable = entity; } @Override public void drawScreen(int x, int y, float f) { if(hireable.worldObj.isRemote){ drawDefaultBackground(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture(tex); int posX = (this.width - xSizeOfTexture) / 2; int posY = (this.height - ySizeOfTexture) / 2; this.drawTexturedModalRect(posX, posY, 0, 0, this.xSizeOfTexture, this.ySizeOfTexture); String s = this.hireable.hasCustomNameTag() ? this.hireable.getCustomNameTag() : I18n.format("entity." + Core.getModID() + "." + hireable.getName() + ".name", new Object[0]); this.fontRendererObj.drawString(s + " " + I18n.format("entity.gui.stat", new Object[0]), (this.width / 2) - this.fontRendererObj.getStringWidth(s + " " + I18n.format("entity.gui.stat", new Object[0])) / 2, posY + 7, 4210752); this.fontRendererObj.drawString(I18n.format("entity.gui.level", new Object[0]) + " = " + hireable.getLevel(), posX + 6, posY + 7 + 9, 4210752); this.fontRendererObj.drawString(I18n.format("entity.gui.health", new Object[0]) + " = " + hireable.getHealth() + " / " + hireable.getMaxHealth(), posX + 6, posY + 7 + (9 * 2), 4210752); super.drawScreen(x, y, f); } } public void initGui() { this.buttonList.clear(); int posX = (this.width - xSizeOfTexture) / 2; int posY = (this.height - ySizeOfTexture) / 2; this.buttonList.add(new GuiButton(0, posX+ 6, posY + 10 + (9 * 11), 100, 20, "level up")); } public void actionPerformed(GuiButton button) { int i = hireable.getLevel(); switch(button.id) { case 0: hireable.setLevel(i + 1); break; default: } } private String EquipmentDamage(int i){ if(hireable.getEquipmentInSlot(i) != null){ return "" + (hireable.getEquipmentInSlot(i).getMaxDamage() - hireable.getEquipmentInSlot(i).getItemDamage()); }else{ return I18n.format("entity.gui.none", new Object[0]); } } }
  19. Simple Your onArmorTick methode will assign the potion to the player for 90 ticks, about 9 seconds. Before the nightvision potion has runned out of time, it will flash. Raise the number of ticks even more and it will be gone!
  20. I found it! Just use the same methode as normal minecraft uses, it will also use the custom language file. "[" + I18n.format("entity.modid.mobname.name", new Object[0]) + "] " + I18n.format("entity.go", new Object[0]))); Now my mob says: [Name] Let's go! It Worked
  21. Ik want some words to be translate-able, (if that's a word) but they language file does not let me. I used the container.customname and than put that in the en_US.lang file container.customname=Custom Name item.things.name=Things That is working! But now i tried something different. I wanted my entity to say something in the chat on interaction. so I typed this: par1EntityPlayer.addChatMessage(new ChatComponentText("[" + entity.modid.mobname.name + "] " + "entity.go")); When I run the game my mob will tell me: [entity.modid.mobname.name] entity.go. This is not what I wanted, I wanted it to be: [Name] Go Name is the name of the mob, the name is located in the language file. Go is the string I wanted the mob to say, this is located in my language file too. What do I need to have or do? There is nothing strange in my class.
  22. Is there a way to edit minecraft classes? I want to add a other leveling function in the EntityPlayer.class not only a regular xp leveling thingy. I can only store the nbt tag in the entityplayer for it to work. Or is there a other way I could add a other leveling system to the player?
  23. I know, I did that. I followed the tutorial and it worked. only when I enter the overworld again, it will spawn me at the same coordinates as the portal in my custom dimension. I can spawn really high or in the ground, even with an existing portal in the overworld. I dont get it!
×
×
  • Create New...

Important Information

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