Jump to content

TEXHIK

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by TEXHIK

  1. Fixed it, but it didn't fix the bug. And bug only when I shift-click, when taking item in regular way, all is ok. Figured out, that the problem is that on successfull getting item by shift-click, itemStack passed into onTake is empty. What is the right way to change item, before taking it?
  2. updated topic with my copabilities code. Full souce https://bitbucket.org/RedTEXHIK/runewords/src/master/src/main/java/ru/htd/runewords/
  3. Your burntime string is set before you have assigned any bvalue to your integer burntime. Remove this variable, it's unnecessary. And do not name your variables from upper case (google for java naming conventions) tooltip.add(String.valueOf(burnTime));//burnTime is your integer variable
  4. I have an ItemStack, that has only one capability - SocketCapability. When i'm trying to check/get it, i'm getting false/null. But if I call methods right on it's provider, all is fine public void preInit() { CapabilityManager.INSTANCE.register(ISocketCapability.class, new SocketCapabilityStorage(), new SocketCapabilityFactory()); GameRegistry.registerTileEntity(TileInlayTable.class, ModBlocks.INLAY_TABLE.getRegistryName());//TODO universal tileEntity registing } public class SocketCapabilityFactory implements Callable<SocketCapability> { @Override public SocketCapability call() throws Exception { return new SocketCapability(); } } public class SocketCapabilityProvider implements ICapabilitySerializable<NBTBase> { @CapabilityInject(ISocketCapability.class) public static final Capability<ISocketCapability> SOCKET_CAPABILITY = null; private ISocketCapability instance = SOCKET_CAPABILITY.getDefaultInstance(); @Override public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) { return capability == SOCKET_CAPABILITY; } @Nullable @Override public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) { return capability == SOCKET_CAPABILITY ? SOCKET_CAPABILITY.cast(instance) : null; } @Override public NBTBase serializeNBT() { return SOCKET_CAPABILITY.getStorage().writeNBT(SOCKET_CAPABILITY, instance, null); } @Override public void deserializeNBT(NBTBase nbt) { SOCKET_CAPABILITY.getStorage().readNBT(SOCKET_CAPABILITY, instance, null, nbt); } } public class SocketCapabilityStorage implements Capability.IStorage<ISocketCapability> { @Nullable @Override public NBTBase writeNBT(Capability<ISocketCapability> capability, ISocketCapability instance, EnumFacing side) { NBTTagCompound compound = new NBTTagCompound(); NBTTagList list = new NBTTagList(); if (instance.getSocketsCount() > 0) { for (Socket socket : instance.getSockets()) { list.appendTag(socket.serializeNBT()); } } compound.setTag("sockets", list); return compound; } @Override public void readNBT(Capability<ISocketCapability> capability, ISocketCapability instance, EnumFacing side, NBTBase nbt) { NBTTagList list = ((NBTTagCompound) nbt).getTagList("sockets", 10); if (list.isEmpty()) { instance.setSockets(new Socket[0]); } else { Socket[] sockets = new Socket[list.tagCount()]; for (int i = 0; i < list.tagCount(); i++) { sockets[i] = new Socket(list.getCompoundTagAt(i)); } instance.setSockets(sockets); } }
  5. But how I access setting nbt tags?... And looks like I missed, that I should change ItemStack instead of actually Item?.. So I can do something like this: ItemSocketArmor extends Armor implements Socketable{ SocketBehaviour sb; onInsert(ItemStack target, ItemsStack insertion){ sb.Insert(target, insertion); } And I can do SocketBehavoiur abstract. And create implementation for each base i want. That's make sense, yes. Now I'm starting to understand the idea and feel that whole structure begins to form in my head. I'll go working on it now. Come here for report later, thanks!
  6. private int genSockets() { //solution for y=1.5; For values below it return one, otherwise round up double singleSocketThreshold = pow(E, -maxSockets - 0.5d) * (pow(E, maxSockets) - sqrt(E)); double seed = random(); return seed > singleSocketThreshold ? 1 : (int) (2 - log(seed + pow(E, 1 - maxSockets))); } This code, I already have - it uses maxSockets property. which is defined in item class and depend on base of the item - sword/bow/helmet/chest/etc. It should be calculated in constructor, as I think for now...
  7. I want to change some item attributes, or give some player buffs. So, as I understand, the main way is to do it through NBT. In otherhand, i want, for example, change base armor toughness, sword damage or bow drawspeed. public void onSocketInsert(ItemStack inserted){ if(!isInsertable(inserted)){ return; } NBTTagCompound nbt = new NBTTagCompound(); //calculate properties for inserted item updateItemStackNBT(nbt); setMaxDamage(100); }
  8. I think, that second will be better. But how to add socket mechanics into both ItemSocketArmor extends ItemArmor and ItemSocketSword extends Item ? I tried using behaviour, SocketsBehaviour, but it can't change Item properties? A feel I'm missing something here, and there is a way to do it over MycCass { SocketsBehaviour sb;} , but can't figure out, how.
  9. I'm making my own, but for now I only having vanilla copies with cockets. Anyway, will I create my custom armor or not, I will create vanilla copy with sockets. And I of course will do it as a copy, because of possible usings of vanilla armor in other mods. What you mean by not need to extend ItemArmor? If i extend from Item, I have to duplicate most ItemArmor code, didn't I?
  10. I' working on sockets mod, allowing items to have sockets and players to put gems in it. Like in Diablo 2 or Path of Exile or any oother RPG with sockets. The problem is that sockets behaviour should be the same for weapoon/tools and armor. But how to avoid code duplication? Multiple inheritence is not allowed in java, but actially what a'm doing is just it. I need to extend from item/armor AND my sockets class. Adding field with socketsBehaviour won't work, because I need access to item/armour fields. For Setting attributes, etc. question on stack with some code samples.
  11. Works fine, thanks! Should I change it back or reset after my renders?
  12. I'm trying to display some additional texture near the tooltip, when player hovering an item in his iinventory: @SubscribeEvent public static void beforeTooltipRender(RenderTooltipEvent.Pre event) { if (event.getStack().getItem() instanceof ItemSocketedArmor) { Minecraft mc = Minecraft.getMinecraft(); int x = event.getX() - 20; int y = event.getY() - 20; mc.getTextureManager().bindTexture(new ResourceLocation(Runewords.MODID, "gui/sockets.png")); mc.currentScreen.drawTexturedModalRect(x + 2, y + 2, 0, 0, 16, 16); } } sockets.png is 256*256, texture is in the top left corner, but in game it is much darker, than in file. This is example with white texture (all file is just #fff): And one more moment: if I change filename, so the game cannot find it (and there is an exception about it in console), the mising texture square have veeery dark color instead of common purple.
  13. Is there any way to handle pickup on client except of checking inventory every tick? Both pickup events are fired on the server-side, but I'm working on some gui-mod, so it should work whithout server-installation.
×
×
  • Create New...

Important Information

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