Jump to content

hugo_the_dwarf

Members
  • Posts

    334
  • Joined

  • Last visited

Everything posted by hugo_the_dwarf

  1. so what is null? expansionLevel? player? world? what if you make expansion level start at 1? use some System.out.println() for each variable that goes into that line (before it is called) should help you see what is null. if they all check out fine it could be that somewhere that method is returning null or getting something that is null.
  2. no it would be: "yc:Side0" but I reeaaaaaly suggest making a public static String in your Main class called MODID and is set as ="yc" so you'd use Side0 = icon.registerIcon(Main.MODID +":" +"Side0");
  3. You talking about how someone uses "main.MODID + ":"+"textureName""? if you know your project's name like my Mod is Rise of Tristram but I shortened it to "rot" so the file format looks like "src\main\resources\assets\rot\textures" rot is my MODID so really you could use: "rot:textureName" but I just made a public static String in my main file to save the ID so if I decide to rename it, or change "rot" to "dcrot" dc being Diablocraft Rise of Tristram I can just update the String MODID to be "dcrot" hope this helps, also since you watched a tutorial I'd figure you understand how to return a texture/icon based on the block's side.
  4. Thanks that pointed me in the right direction, fussed around with different ways until it worked @Override public IMessage onMessage(CustomItemPacket message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; InventoryPlayer ip = player.inventory; ip.setInventorySlotContents(ip.currentItem, message.item); return null; } I should probably do some checks to make sure that the item classes match up but I figure it's hard to change the item when the GUI only opens for WeaponCustom and you can't change items in the GUI. Thanks
  5. Ok it seems the itemstack will save if I make changes, and then open up the player inventory "E" anyway I can have it save from the GUI that alters it? I'd like to have that GUI add more effects that actually do more then look pretty, and don't want players to spend the resources on something that *might* not save if they don't check their inventory after. So any help? Ideas? EDIT: seems only the creative mode inventory will save the item. survival mode doesn't.
  6. It crashes but with what error? And also you can use List because it's just a List waiting to be declared, and getEntitiesWithinAABB returns a list of the target type. is the error a null pointer? index out of bounds? cannot cast the list? (like memcallen suggested, and I blindly said no worries) was gonna say the expansionLevel would cause an issue, but I think the only issue is when 2 or more players wear it that value will be flying all over the place. Best to make it a method scope variable, than a class one.
  7. yeah I didn't want to give copy paste ready code (which i'm bad for) because I was hoping you'd see the error and go "maybe it just takes a world object/instance" but the expand(3,3,3) can be any numbers you want it to be. I just used 3's as a placeholder to show you how to use it. PreEdit: you might want to use an Iterator and a while loop, or some kindof loop to go through the list for each entry. you can also refactor the "players" to something like "entities" or "targets" idk whatever you want to call it. I used it for a block that would store mana, and recharge nearby mages. but yeah looks a bit better, altho since it's an "onArmorTick" it should have a world param that you can toss in. like par2World.getEntitiesWithin..... and if it doesn't it should at least reference the player or entity wearing it (since zombies and skeletons can wear armor) and you can get the world object from there too.
  8. List players = getWorldObj().getEntitiesWithinAABB(EntityPlayer.class,player.getBoundingBox().expand(3, 3, 3); this will get all players around the player (and probably the origin player too) just change what class to find to something else or use the base class, I think EntityLiving? EntitiyLivingBase? then when spawning lightening just make sure you're not spawning one on whoever created the bounding box.
  9. Right now my luck finally ran out, I have a class, well a few. WeaponCustom and two extensions of it WeaponSlash(sword) and WeaponHack(Axe) and most of their values are NBT (so it is unique for each instance of it) well up until a few mins ago, The GUI would let you change the blades, guards, and handles and even color each piece (was about to move onto size and special upgrades) and it saved (no packets, just changing the NBT clientside with a GUI) but now it stopped. No biggy I will just make a packet to send from client to update server. Made it, registered it, and used it. Still no saving. Idk why it worked without and Idk why it won't work at all now. [spoiler=GUI] public class GuiItemCustom extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation( Rot.MODID .toLowerCase(), "textures/gui/base.png"); private int[] colors = new int[]{0xFFFFFF,0x999999,0x666666,0x333333, 0xD9D100,0x918b00, 0xb36000,0x7C4300, 0x619b00,0x4D6D17, 0x47C0FF,0x21489C, 0xe40004,0xaa0003}; private int[] selectedColors = new int[]{0,0,0}; private EntityPlayer player; private ItemStack item; private int pad = 4; private int ch = 20; private int selectedBladeHead = 0; private int selectedGuard = 0; private int selectedHandle = 0; private int weaponStyles = 1; private boolean swordStaff = false; public GuiItemCustom(EntityPlayer player) { super(new ContainerNull()); this.player = player; this.item = player.getHeldItem(); this.xSize = 176; this.ySize = 166; this.selectedBladeHead = UtilityNBTHelper.getInt(this.item, UtilityWeaponNBTKeyNames.bladeHead); this.selectedGuard = UtilityNBTHelper.getInt(this.item, UtilityWeaponNBTKeyNames.guard); this.selectedHandle = UtilityNBTHelper.getInt(this.item, UtilityWeaponNBTKeyNames.handle); if (this.item.getItem() instanceof WeaponCustom) { weaponStyles = ((WeaponCustom) this.item.getItem()).getNumberOfTypes(); } if ((this.item.getItem() instanceof WeaponSlash) || (this.item.getItem() instanceof WeaponStaff)) { swordStaff = true; } for (int i = 0; i < colors.length;i++) { if (UtilityNBTHelper.getInt(item, UtilityWeaponNBTKeyNames.layerColor+0) == colors[i]) selectedColors[2] = i; if (UtilityNBTHelper.getInt(item, UtilityWeaponNBTKeyNames.layerColor+2) == colors[i]) selectedColors[0] = i; if (UtilityNBTHelper.getInt(item, UtilityWeaponNBTKeyNames.layerColor+4) == colors[i]) selectedColors[1] = i; } } /** Button Clicks **/ @Override protected void actionPerformed(GuiButton button) { switch (button.id) { case 0 : // Class Forward if (button.displayString.contains("Blade") || button.displayString.contains("Head")) { if (this.selectedBladeHead < (this.weaponStyles - 1)) { this.selectedBladeHead++; } else { this.selectedBladeHead = 0; } } else if (button.displayString.contains("Guard")) { if (this.selectedGuard < (this.weaponStyles - 1)) { this.selectedGuard++; } else { this.selectedGuard = 0; } } else if (button.displayString.contains("Extra")) { UtilityNBTHelper.setBoolean(item, UtilityWeaponNBTKeyNames.showExtra, !UtilityNBTHelper.getBoolean(item, UtilityWeaponNBTKeyNames.showExtra)); }else if (button.displayString.contains("Handle")) { if (this.selectedHandle < (this.weaponStyles - 1)) { this.selectedHandle++; } else { this.selectedHandle = 0; } } UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.bladeHead, this.selectedBladeHead); UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.handle, this.selectedHandle); UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.guard, this.selectedGuard); break; case 1 : // Class Back if (button.displayString.contains("Blade") || button.displayString.contains("Head")) { if (this.selectedBladeHead > 0) { this.selectedBladeHead--; } else { this.selectedBladeHead = this.weaponStyles - 1; } } else if (button.displayString.contains("Guard")) { if (this.selectedGuard > 0) { this.selectedGuard--; } else { this.selectedGuard = this.weaponStyles - 1; } } else if (button.displayString.contains("Extra")) { UtilityNBTHelper.setBoolean(item, UtilityWeaponNBTKeyNames.showExtra, !UtilityNBTHelper.getBoolean(item, UtilityWeaponNBTKeyNames.showExtra)); } else if (button.displayString.contains("Handle")) { if (this.selectedHandle > 0) { this.selectedHandle--; } else { this.selectedHandle = this.weaponStyles - 1; } } UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.bladeHead, this.selectedBladeHead); UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.handle, this.selectedHandle); UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.guard, this.selectedGuard); break; case 2 : if (button.displayString.contains("CB")) { if (selectedColors[0] < colors.length - 1) selectedColors[0]++; else selectedColors[0] = 0; } else if (button.displayString.contains("CG")) { if (selectedColors[1] < colors.length - 1) selectedColors[1]++; else selectedColors[1] = 0; } else if (button.displayString.contains("CH")) { if (selectedColors[2] < colors.length - 1) selectedColors[2]++; else selectedColors[2] = 0; } if (swordStaff) { UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.layerColor+0, colors[selectedColors[2]]);//handle UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.layerColor+2, colors[selectedColors[0]]);//blade UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.layerColor+4, colors[selectedColors[1]]);//guard } else { UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.layerColor+0, colors[selectedColors[2]]);//handle UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.layerColor+2, colors[selectedColors[0]]);//blade UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.layerColor+4, colors[selectedColors[0]]);//guard } break; case 3 : if (button.displayString.contains("CB")) { if (selectedColors[0] > 0) selectedColors[0]--; else selectedColors[0] = colors.length - 1; } else if (button.displayString.contains("CG")) { if (selectedColors[1] > 0) selectedColors[1]--; else selectedColors[1] = colors.length - 1; } else if (button.displayString.contains("CH")) { if (selectedColors[2] > 0) selectedColors[2]--; else selectedColors[2] = colors.length - 1; } if (swordStaff) { UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.layerColor+0, colors[selectedColors[2]]);//handle UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.layerColor+2, colors[selectedColors[0]]);//blade UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.layerColor+4, colors[selectedColors[1]]);//guard } else { UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.layerColor+0, colors[selectedColors[2]]);//handle UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.layerColor+2, colors[selectedColors[0]]);//blade UtilityNBTHelper.setInteger(this.item, UtilityWeaponNBTKeyNames.layerColor+4, colors[selectedColors[0]]);//guard } break; case 4 : Rot.net.sendToServer(new CustomItemPacket(item)); break; } } @Override protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1F, 1F, 1F, 1F); Minecraft.getMinecraft().renderEngine.bindTexture(texture); drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); TextureManager manager = Minecraft.getMinecraft().renderEngine; this.buttonList.clear(); // Start with main control buttons int x1 = this.guiLeft + this.pad; int x2 = (this.guiLeft + this.xSize) - (50 + this.pad); this.buttonList.add(new GuiButton(0, x2, this.guiTop + this.pad, 50, this.ch, (swordStaff ? "Blade" : "Head") + " ->")); this.buttonList.add(new GuiButton(2, x2 - 20, this.guiTop + this.pad, 20, this.ch, "CB>")/*.packedFGColour = colors[selectedColors[0]]*/); this.drawCenteredString(this.fontRendererObj, "" + this.selectedBladeHead, (x1 + 50 + x2) / 2, this.guiTop + this.pad + 5, colors[selectedColors[0]]); this.buttonList.add(new GuiButton(1, x1, this.guiTop + this.pad, 50, this.ch, "<- " + (swordStaff ? "Blade" : "Head"))); this.buttonList.add(new GuiButton(3, x1 + 50, this.guiTop + this.pad, 20, this.ch, "<CB")/*.packedFGColour = colors[selectedColors[0]]*/); if (swordStaff) { this.buttonList.add(new GuiButton(0, x2, this.guiTop + this.pad + 20, 50, this.ch, "Guard ->")); this.buttonList.add(new GuiButton(2, x2 - 20, this.guiTop + this.pad + 20, 20, this.ch, "CG>")/*.packedFGColour = colors[selectedColors[1]]*/); this.drawCenteredString(this.fontRendererObj, "" + this.selectedGuard, (x1 + 50 + x2) / 2, this.guiTop + this.pad + 5 + 20, colors[selectedColors[1]]); this.buttonList.add(new GuiButton(1, x1, this.guiTop + this.pad + 20, 50, this.ch, "<- Guard")); this.buttonList.add(new GuiButton(3, x1 + 50, this.guiTop + this.pad + 20, 20, this.ch, "<CG")/*.packedFGColour = colors[selectedColors[1]]*/); } else { this.buttonList.add(new GuiButton(0, x2, this.guiTop + this.pad + 20, 50, this.ch, "Extra ->")); this.drawCenteredString(this.fontRendererObj, "" + UtilityNBTHelper.getBoolean(item, UtilityWeaponNBTKeyNames.showExtra), (x1 + 50 + x2) / 2, this.guiTop + this.pad + 5 + 20, colors[selectedColors[0]]); this.buttonList.add(new GuiButton(1, x1, this.guiTop + this.pad + 20, 50, this.ch, "<- Extra")); } this.buttonList.add(new GuiButton(0, x2, this.guiTop + this.pad + (20 * 2), 50, this.ch, "Handle ->")); this.buttonList.add(new GuiButton(2, x2 - 20, this.guiTop + this.pad + (20 * 2), 20, this.ch, "CH>")/*.packedFGColour = colors[selectedColors[2]]*/); this.drawCenteredString(this.fontRendererObj, "" + this.selectedHandle, (x1 + 50 + x2) / 2, this.guiTop + this.pad + 5 + (20 * 2), colors[selectedColors[2]]); this.buttonList.add(new GuiButton(1, x1, this.guiTop + this.pad + (20 * 2), 50, this.ch, "<- Handle")); this.buttonList.add(new GuiButton(3, x1 + 50, this.guiTop + this.pad + (20 * 2), 20, this.ch, "<CH")/*.packedFGColour = */); this.buttonList.add(new GuiButton(4, x1, this.guiTop + this.pad + (20 * 3), 50, this.ch, "Save")); manager.bindTexture(manager.getResourceLocation(1)); // RENDER ITEMS IIcon displayItem; for (int l = 0; l < 3; l++) { displayItem = this.item.getItem().getIcon(this.item, l); if (displayItem != null) { drawTexturedModelRectFromIcon(x2, this.guiTop + this.pad + (20 * 3), displayItem, 16, 16); } } } /** Keyboard Clicks **/ @Override protected void keyTyped(char par1, int par2) { if ((par2 == 1) || (par2 == this.mc.gameSettings.keyBindInventory.getKeyCode())) { this.mc.thePlayer.closeScreen(); } } } [spoiler=WeaponCustom] public class WeaponCustom extends ItemSword { private int numberOfLayers = 6; private int numberOfTypes; public WeaponCustom(ToolMaterial p_i45356_1_) { super(p_i45356_1_); } @Override public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); String size = UtilityNBTHelper.getString(par1ItemStack, UtilityWeaponNBTKeyNames.size); String name = (String) par3List.get(0); if ((size != "normal") && (size != "")) { par3List.set(0, size.substring(0, 1).toUpperCase() + size.substring(1) + " " + name); } } public IIcon[] getIcons(ItemStack stack) { return null; } public int[] getLayerColors(ItemStack is) { int[] colorList = new int[this.numberOfLayers]; for (int c = 0; c < this.numberOfLayers; c++) { int color = UtilityNBTHelper.getInt(is, UtilityWeaponNBTKeyNames.layerColor + c); colorList[c] = (color == 0 ? 0xFFFFFF : color); } return colorList; } public int getNumberOfTypes() { return numberOfTypes; } public void setNumberOfTypes(int num) { numberOfTypes = num; } } [spoiler=WeaponSlash (Hack is pretty much a direct copy, only a few different NBT values)] public class WeaponSlash extends WeaponCustom { private int numOfTypes = 8; IIcon[] blades = new IIcon[numOfTypes]; IIcon[] bladeEffectsFrost = new IIcon[numOfTypes]; IIcon[] bladeEffectsBleed = new IIcon[numOfTypes]; IIcon[] bladeEffectsVamp = new IIcon[numOfTypes]; IIcon[] guards = new IIcon[numOfTypes]; IIcon[] guardEffects0 = new IIcon[numOfTypes]; IIcon[] handles = new IIcon[numOfTypes]; IIcon[] handleEffects0 = new IIcon[numOfTypes]; IIcon nullIcon; IIcon defaultIcon; public WeaponSlash(ToolMaterial mat) { super(mat); setNumberOfTypes(numOfTypes); } @Override public IIcon getIcon(ItemStack stack, int pass) { switch (pass) { case 0 : return this.handles[utilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.handle)]; case 1 : return this.blades[utilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.bladeHead)]; case 2 : return this.guards[utilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.guard)]; default : break; } return this.defaultIcon; } @Override public IIcon[] getIcons(ItemStack stack) { //0 is handle, 2 is blade, 4 is guard //1 he, 3 be, and 5 ge; are effects IIcon[] icons = new IIcon[6]; icons[0] = this.handles[utilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.handle)]; icons[2] = this.blades[utilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.bladeHead)]; icons[4] = this.guards[utilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.guard)]; switch(UtilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.bladeHeadEffect)) { case 1: icons[3] = this.bladeEffectsFrost[utilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.bladeHead)]; break; case 2: icons[3] = this.bladeEffectsBleed[utilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.bladeHead)]; break; case 3: icons[3] = this.bladeEffectsVamp[utilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.bladeHead)]; break; default: icons[3] = nullIcon; break; } switch(UtilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.handleEffect)) { case 1: icons[1] = this.handleEffects0[utilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.handle)]; break; default: icons[1] = nullIcon; break; } switch(UtilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.guardEffect)) { case 1: icons[5] = this.guardEffects0[utilityNBTHelper.getInt(stack, UtilityWeaponNBTKeyNames.guard)]; break; default: icons[5] = nullIcon; break; } return icons; } @Override @SideOnly(Side.CLIENT) public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) { ItemStack[] swords = new ItemStack[numOfTypes]; for (int i = 0; i < numOfTypes; i++) { swords[i] = new ItemStack(p_150895_1_, 1, 0); UtilityNBTHelper.setString(swords[i], UtilityWeaponNBTKeyNames.type, "slash"); UtilityNBTHelper .setString(swords[i], UtilityWeaponNBTKeyNames.size, "large"); UtilityNBTHelper.setInteger(swords[i], UtilityWeaponNBTKeyNames.handle, i); UtilityNBTHelper.setInteger(swords[i], UtilityWeaponNBTKeyNames.bladeHead, i); UtilityNBTHelper.setInteger(swords[i], UtilityWeaponNBTKeyNames.guard, i); p_150895_3_.add(swords[i]); } } @Override public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { UtilityNBTHelper.setString(par1ItemStack, UtilityWeaponNBTKeyNames.type, "slash"); UtilityNBTHelper .setString(par1ItemStack, UtilityWeaponNBTKeyNames.size, "normal"); UtilityNBTHelper.setInteger(par1ItemStack, UtilityWeaponNBTKeyNames.bladeHead, 3); UtilityNBTHelper.setInteger(par1ItemStack, UtilityWeaponNBTKeyNames.guard, 3); UtilityNBTHelper.setInteger(par1ItemStack, UtilityWeaponNBTKeyNames.handle, 3); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister ir) { for (int i = 0; i < numOfTypes; i++) { this.blades[i] = ir.registerIcon(Rot.MODID + ":" + "weapons/blades/blade_" + i); this.bladeEffectsFrost[i] = ir.registerIcon(Rot.MODID+":"+"weapons/blades/effects/blade_" + i +"_e_0"); this.bladeEffectsBleed[i] = ir.registerIcon(Rot.MODID+":"+"weapons/blades/effects/blade_" + i +"_e_1"); this.bladeEffectsVamp[i] = ir.registerIcon(Rot.MODID+":"+"weapons/blades/effects/blade_" + i +"_e_2"); this.guards[i] = ir.registerIcon(Rot.MODID + ":" + "weapons/guards/guard_" + i); this.guardEffects0[i] = ir.registerIcon(Rot.MODID+":"+"weapons/guards/effects/guard_" + i +"_e_0"); this.handles[i] = ir.registerIcon(Rot.MODID + ":" + "weapons/handles/handle_" + i); this.handleEffects0[i] = ir.registerIcon(Rot.MODID+":"+"weapons/handles/effects/handle_" + i +"_e_0"); } this.defaultIcon = ir .registerIcon(Rot.MODID + ":" + "weapons/fighter_slash_icon"); this.nullIcon = ir.registerIcon(Rot.MODID + ":" + "weapons/32x32Null"); } } [spoiler=CustomItemPacket] public class CustomItemPacket implements IMessage { public static class CustomItemPacketHandler implements IMessageHandler<CustomItemPacket, IMessage> { @Override public IMessage onMessage(CustomItemPacket message, MessageContext ctx) { ItemStack equippedItem = ctx.getServerHandler().playerEntity.getCurrentEquippedItem(); equippedItem = message.item; return null; } } public ItemStack item; public CustomItemPacket() { } public CustomItemPacket(ItemStack item) { this.item = item; } @Override public void fromBytes(ByteBuf buf) { this.item = ByteBufUtils.readItemStack(buf); // this class is very // useful in general for // writing more complex // objects } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeItemStack(buf, this.item); } } EDIT: ok I had it save a customized sword *once* then it failed and stopped saving again.
  10. do you have your project on git? Or somewhere I can view all of your code? my only suggestion would be maybe making your ID lowercase and your mod's package to be lowercase as well Newt => newt don't think that is the issue but at this moment I'm spitballin' at little things that might be an issue even if they don't seem like it. EDIT: you have redcoal saved as a png that is 16x16 correct?
  11. Have you saved, and refreshed your project (I found with eclipse Luna I need to manually refresh my project for it to find resources I just added) Other than that you are setting the texture path correctly.
  12. that or make your salt have sub items, and one of them is "bucket of salt" which has an onUpdate function that when it's in a player's inventory will turn into salt, and give an empty bucket. So smelt water bucket -> salt bucket -> salt + bucket salt is damage value of 0 salt bucket is damage value of 1 onUpdate() if (itemstack.getitemDamage == 1) { consume salt bucket, add salt, and add bucket } EDIT: Thinking about it now, no need to consume the salt bucket, just set it's damage to 0, which is salt. so if (itemstack.getItemDamage() == 1) { itemstack.setitemdamage(0); player.inventory.addItemStackToInventory(new itemstack(items.bucket)); } that is the rough idea.
  13. Since you cloned it can't you override the getTexture to return a new texture? Now of course why make new textures when you can just tell a renderer to change the RGB so I hope someone mentions the way to do this. I am interested.
  14. also might want to move that "return super.onItemRightClick(s, w, p);" below your getter code, since returns always exit out of a method
  15. Alright so following this tutorial http://docs.oracle.com/javase/tutorial/reflect/member/fieldValues.html and I go this code: if (props.getAgility() != (agiMod - props.getClassModifers()[1])) { props.setAgility(agiMod); //ExtendPlayer.get(player).updateMoveSpeed(); /*player.capabilities.setPlayerWalkSpeed(MathHelper.clamp_float( 0.1F + ((float) props.getAgility() / 142), 0.04f, 0.3f));*/ Class<?> pc = player.capabilities.getClass(); try { Field walkSpeed = pc.getDeclaredField("walkSpeed"); walkSpeed.setAccessible(true); walkSpeed.set(pc, 6.6f); } catch (IllegalArgumentException | IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } } I literally have no idea what I'm doing but this snippet is in my livingUpdateEvent, and works with: player.capabilities.setPlayerWalkSpeed(MathHelper.clamp_float(0.1F + ((float) props.getAgility() / 142), 0.04f, 0.3f)); So I *think* I have the basic understanding on how to use reflection now, just how do I use it properly with MC? Do I need to do some more sorcery? EDIT: We are not suppose to post vanilla code right? Would me posting my reflection code be violating this? EDIT2: Ok I forgot that my code only does any changes if something has changed. So added something that gave me more agi and it works. So this won't effect *all* players just the one with more or less agility? EDIT3: yup each player has their own Move Speed, excellent, Also fixed the Server to Server packet sending issue. So no crashes. Thanks for all the help. I have a feeling more will pop up when I test my mod out more with the other features.
  16. Ok so googled reflection and had a look at it, it does seem rather easy, never used it yet but I get the idea of it and how to use it. I will give it a try, so what do you suggest I do? I'm also looking up how to get and set private fields. So would I simply get Field playerWalkSpeed = capabilities.class.getDeclaredField(walkSpeed)? Probably when I finish reading up on this I'll know how to do it. But is that what I do? use reflection to set the walkSpeed manually because the method is clientonly? As for the syncing would I just check "if (entity instanceof EntityPlayer){ if (!entity.getWorld.isRemote){ EntityPlayerMP player = (EntityPlayerMP)((EntityPlayer)entity); //Get Values sendTo(responsePacket(values),player); } } Thanks for the help btw, and sorry if this feels like I'm asking for all the help to make this. I really just want to understand the correct way of doing this.
  17. 1. Alright, so I guess will have to read each event carefully when I'm using them just to see where each one is called (one side or both) 2. I noticed that even when I use NBT to save and load Extended Properties when a client connects all their stuff (except data Watched values) are all reset to the defaults. So I used the "EntityJoinWorldEvent " to have the server update the clients info so both server and client data is sync'd. So I guess really I could have just said "To Sync server and client data" 3. Linked to number 2. But still good to know, thank you. 4. *facepalm* guess if I hovered over it eclipse could have told me that, as for reflection I'm not that advanced with Java to understand it or use it (have read other topics on here about people using it or being told to use it) so I guess I am stuck with adding speed/slow potion effects? which kinda sucks I liked the setWalkSpeed did what I wanted it to do. Guess will have to scrap Agility stat. (due to lack of understanding and experience) 5.Thanks that is a pretty good explanation. Clears up the use there. So I guess the only thing that still needs answering atm is 2. (3 is kind of a child of 2) How do I properly keep the client sync'd with the server.
  18. This helped me understand NBT greatly " But the issue is you are forgetting to check to see if the itemstack has a NBTTagCompound if (itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } you are probably getting a crash of something being null right? Watch the video and all will be revealed to you. (also the posted code snippet is how you make sure not to get a crash trying to add to a null object)
  19. oh, that makes sense, since events run both server and client (probably wrong as fk with that assumption) So should I more or less have that event get the properties from the player and just send a reponsePacket? Not player send request to server, get response. If so I think sendTo takes EntityPlayerMP and I'm not sure how I get that to use, I think that is why I have the event send the request and response back. But in this case it's "EntityJoinWorldEvent" and I check to see if it is the player... My understanding of this is limited. But at least I know it's server to server that is causing the exception. (Talking to yourself normally causes problems) EDIT: for the crash this is the error I believe "Caused by: java.lang.NoSuchMethodError: net.minecraft.entity.player.PlayerCapabilities.setPlayerWalkSpeed(F)V" EDIT2: Also may I request a link to a good or a few good Proxy tutorials, seems like I should get a better understanding of them and when to use them.
  20. Ok so that helped that out, Also had to move my FML bus instance into my proxy for keybindings, and it runs (yay) but has some errors when I log in (also had to find where it made my server, good thing it outputs that in the console, to make it offline) But I get this error when I join [spoiler=Stopped my copy paste at where my mod showed up] [spoiler=Code snippet that that line] @SubscribeEvent public void onPlayerJoin(EntityJoinWorldEvent e) { if (e.entity instanceof EntityPlayer) { Rot.net.sendToServer(new ClassRequestPacket("whatAmI")); } } It still worked despite these errors so I tryied changing my class and got a crash on the playerTick event at this line of code: player.capabilities.setPlayerWalkSpeed(MathHelper.clamp_float( 0.1F + ((float) props.getAgility() / 142), 0.04f, 0.3f)); The mod lets you move faster or slower based on the agility stat, and the class I picked changes agility. So do I need to move everything that has to do with a player to the clientProxy? Because I'm sure the server needs to know that the player can move faster.
  21. Well the way I do it is this: @Override public String getItemStackDisplayName(ItemStack par1ItemStack) { String size = UtilityNBTHelper.getString(par1ItemStack, UtilityWeaponNBTKeyNames.size); if ((size == "normal") || (size == "")) { return ("" + StatCollector.translateToLocal(this .getUnlocalizedNameInefficiently(par1ItemStack) + ".name")).trim(); } else { return (size.substring(0, 1).toUpperCase() + size.substring(1) + " " + StatCollector .translateToLocal(this.getUnlocalizedNameInefficiently(par1ItemStack) + ".name")).trim(); } } but I don't add color, maybe you just need an extra "space" to seperate the color and the name? EDIT: Tested it with my weapons that use this, by placing "EnumChatFormatting.RED" just before the " " and I get "Large Sword" EDIT2: Also seems I jumped the gun as was not a very favorable person. David was correct, I think you just need to alter the first entry of the List in addInformation() method. Either way mine works, but seems to require more work then necessary.
  22. close david, he wanted the "Item Name" not "Tool Tip" I'd say overwrite the Item's "getItemStackDisplayName" method and have it return: return this.getUnlocalizedName(par1ItemStack) == null ? "" : EnumChatFormatting.RED+StatCollector.translateToLocal(this.getUnlocalizedName(par1ItemStack)); and pick a color. give that a shot.
  23. After working on my mod for almost a month now, using the client to test my changes and work. Anyways my mod is based around PvP so not only is it going to be a solo but a server mod. And running it with the dedicated server is giving me crashes for well client related items, The keybindings where a no brainer moved them into the clientProxy. Crash fixed, next one is crashing at my classResponsePacket because it can't find "EntityClientPlayerMP" and I'm not sure I can just move that into the client proxy because this is something the server needs to send to the player (keeps class values updated for the client to see) I'm just understanding the proxies, and the packets I have only a limited grasp on. But enough I know how to use them, but that is not the question at hand. I want a dedicated server to run fine just like the client to (even the client server has no issues) but also work as intended. Also here is my repo if there is code you need to see that I haven't posted https://github.com/GRM-Group/Rise-of-Tristram PS. I have only been modding for the same time I started this mod, so if you see things done wrong or could be better, that is my excuse for it.
  24. Only time I ever override registerIcons is when I have more than one texture for something (mainly items that have subtypes) like diesieben and strum have been saying, just fix this.setTextureName(mymod.main.Main.MODID + "mymod:"); I will give an example of how I set a texture: weaponSwordSoul = new ItemSwordSoul(ToolMaterial.EMERALD) .setCreativeTab(Rot.tabRoT).setUnlocalizedName("weaponSwordSoul") .setTextureName(Rot.MODID + ":" + "weapons/soul_sword"); my folder path looks like "src\main\resources\assets\rot\textures\items" the bolded letters being my MODID now when I'm setting this texture I have a folder called "weapons" in my "textures/items" path. Do you need to do that, No. how you would do it: pulseRifle = new mymod.items.pulseRifle(0, "pulseRifle").setCreativeTab(MyCreativeTab_1).setMaxStackSize(1).setTextureName(mymod.main.Main.MODID +":"+"pulseRifle.png"); I am quite sure every other modder on here is looking at me, and my post going Don't do it for him. I have followed those tutorials and all my items work fine, and if doing the right way is not working for you, you have your resources in the "wrong" place
  25. I was almost thinking that nearby fuseBoxes idk radius of 20 blocks? maybe less, (just so close together fuseBoxes don't remake the same network they more or less say "fuseBox number one will be the leader, we will merely reference him" and as for network collision.. hmm. Maybe since you say the range of your longest cable is 60 blocks, it will look for other fuseboxes twice that range? Idk this was not something I had thought of, good call. I was hoping (andyes I still understand you can never hop that another human being will do what they are suppose to do) that players would have one fuseBox and have something like Room A is the power generation and storage room, and Room B is the machine room with a FuseBox inbetween the two rooms. Cables in, cables out.
×
×
  • Create New...

Important Information

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