
TesterTesting135
Members-
Posts
105 -
Joined
-
Last visited
Everything posted by TesterTesting135
-
Title says it all. There doesn't seem to be a float value for the config. Can anybody help me?
-
[SOLVED] Help with NBT crash.
TesterTesting135 replied to TesterTesting135's topic in Modder Support
Woops, thank you so much! -
Hello, so I am trying to make an item lock that prevents you from dropping items so you don't accidentally lose them. I save NBT data to it, but I have a problem. If I try to save data to a block I've already made, which saves the NBT when you break it and shows it in the tooltip, it gives a null pointer exception. Add information and getItemCount methods in my block class: @Override public void addInformation(ItemStack itemstack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { tooltip.add("Makes cobblestone and compressed cobblestone with upgrades at a stack per tick. Uses LOADS of power when upgraded."); tooltip.add("Will auto-eject items."); NBTTagCompound tagCompound = itemstack.getTagCompound(); if (tagCompound != null) { int energy = tagCompound.getInteger("energy"); //Crashing Line int sizeIn = getItemCount(tagCompound, "itemsIn"); int sizeOut = getItemCount(tagCompound, "itemsOut"); String translated = I18n.format("message.tm.cobble_generator", energy, sizeIn, sizeOut); translated = COMPILE.matcher(translated).replaceAll("\u00a7"); Collections.addAll(tooltip, StringUtils.split(translated, "\n")); } } private int getItemCount(NBTTagCompound tagCompound, String itemsIn2) { int sizeIn = 0; NBTTagCompound compoundIn = (NBTTagCompound) tagCompound.getTag(itemsIn2); //Crashing line NBTTagList itemsIn = compoundIn.getTagList("Items", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < itemsIn.tagCount(); i++) { NBTTagCompound itemTags = itemsIn.getCompoundTagAt(i); if (!new ItemStack(itemTags).isEmpty()) { sizeIn++; } } return sizeIn; } I think this is because of the "NBTTagCompound tagCompound = itemstack.getTagCompound();" line which gets all the NBT data, including the locking NBT boolean. Is there anything I can do to fix this? Note: This is a duplicate because I posted this in the wrong place. Sorry.
-
Hello, so I am trying to make an item lock that prevents you from dropping items so you don't accidentally lose them. I save NBT data to it, but I have a problem. If I try to save data to a block I've already made, which saves the NBT when you break it and shows it in the tooltip, it gives a null pointer exception. Add information and getItemCount methods in my block class: @Override public void addInformation(ItemStack itemstack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { tooltip.add("Makes cobblestone and compressed cobblestone with upgrades at a stack per tick. Uses LOADS of power when upgraded."); tooltip.add("Will auto-eject items."); NBTTagCompound tagCompound = itemstack.getTagCompound(); if (tagCompound != null) { int energy = tagCompound.getInteger("energy"); //Crashing Line int sizeIn = getItemCount(tagCompound, "itemsIn"); int sizeOut = getItemCount(tagCompound, "itemsOut"); String translated = I18n.format("message.tm.cobble_generator", energy, sizeIn, sizeOut); translated = COMPILE.matcher(translated).replaceAll("\u00a7"); Collections.addAll(tooltip, StringUtils.split(translated, "\n")); } } private int getItemCount(NBTTagCompound tagCompound, String itemsIn2) { int sizeIn = 0; NBTTagCompound compoundIn = (NBTTagCompound) tagCompound.getTag(itemsIn2); //Crashing line NBTTagList itemsIn = compoundIn.getTagList("Items", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < itemsIn.tagCount(); i++) { NBTTagCompound itemTags = itemsIn.getCompoundTagAt(i); if (!new ItemStack(itemTags).isEmpty()) { sizeIn++; } } return sizeIn; } I think this is because of the "NBTTagCompound tagCompound = itemstack.getTagCompound();" line which gets all the NBT data, including the locking NBT boolean. Is there anything I can do to fix this?
-
Ok, I will try that out now and let you know if i have any problems. Thank you for your help.
-
What method would i use to get the ItemStack in the Item class? EDIT: I've tried creating an instance of the item class in the GUI and then doing this: ItemStack stack = new ItemStack(capacityCard); and then setting the NBT in the setEnergyCapacity method but that isn't working.
-
Bump
-
Hello, so i'm trying to make a GUI for a item that allows you to type in the amount of energy you want a machine to store. However, whenever it saves the NBT, it saves it for ALL of the items, not just that 1 instance. Here is my code for my GUI and item class: Item Class: private int energy; public CapacityCard(String name) { setTranslationKey(name); setRegistryName(name); setCreativeTab(CreativeTabs.MATERIALS); ModItems.ITEMS.add(this); } public static final String ENERGYCAPACITY = "energyCapacity"; @Override public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag advanced) { if (stack.getItem() == ModItems.ENERGY_CAPACITY_CARD) { NBTTagCompound nbt; if (stack.hasTagCompound()) { nbt = stack.getTagCompound(); } else { nbt = new NBTTagCompound(); } nbt.setInteger(ENERGYCAPACITY, energy); if (nbt.hasKey(ENERGYCAPACITY)) { tooltip.add(TextFormatting.GREEN + "Energy Capacity: " + nbt.getInteger(ENERGYCAPACITY)); } stack.setTagCompound(nbt); } } @Override public void registerModels() { Main.proxy.registerItemRenderer(this, 0, "inventory"); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if (worldIn.isRemote) { if (!playerIn.isSneaking()) { Minecraft.getMinecraft().displayGuiScreen(new GuiCapacityCard(this)); } } return super.onItemRightClick(worldIn, playerIn, handIn); } @Override public boolean updateItemStackNBT(NBTTagCompound nbt) { return true; } public void setEnergyCapacity(int energy) { this.energy = energy; } Gui Class: private CapacityCard capacityCard; private final ResourceLocation gui = new ResourceLocation(Reference.MOD_ID, "textures/gui/link_card.png"); private static final int WIDTH = 180; private static final int HEIGHT = 180; @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { drawDefaultBackground(); super.drawScreen(mouseX, mouseY, partialTicks); int centerX = (width / 2) - WIDTH / 2; int centerY = (height / 2) - HEIGHT / 2; mc.getTextureManager().bindTexture(gui); drawTexturedModalRect(centerX, centerY, 0, 0, WIDTH, HEIGHT); energyCapacity.drawTextBox(); //drawString(mc.fontRenderer, "Maxiumum Capacity: " + energy, 260, 160, 0xffffff); } public GuiCapacityCard(CapacityCard card) { capacityCard = card; } @Override public void initGui() { super.initGui(); energyCapacity = new GuiTextFieldRevamped(mc.fontRenderer, 270, 100, 125, 20); energyCapacity.setMaxStringLength(10); energyCapacity.setCharFilter(GuiTextFieldRevamped.FILTER_NUMERIC); //energyCapacity.setText(Integer.toString(energy)); } @Override protected void actionPerformed(GuiButton button) throws IOException { super.actionPerformed(button); } @Override protected void keyTyped(char typedChar, int keyCode) throws IOException { super.keyTyped(typedChar, keyCode); energyCapacity.textboxKeyTyped(typedChar, keyCode); } @Override public boolean doesGuiPauseGame() { return false; } @Override public void onGuiClosed() { if (energyCapacity.getInteger() <= 0) { energyCapacity.setText("0"); } else { int energy = energyCapacity.getInteger(); capacityCard.setEnergyCapacity(energy); //PacketHandler.INSTANCE.sendToServer(new PacketEnergyCapacity(energy, capacityCard)); } super.onGuiClosed(); } @Override public void updateScreen() { super.updateScreen(); } @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); energyCapacity.mouseClicked(mouseX, mouseY, mouseButton); } private GuiTextFieldRevamped energyCapacity; Any help would be great. Thanks.
-
Hello, so I have made an item that has a GUI. I want the gui to save the data i have typed in a text box to the Item. However, I cannot get this to work properly. I believe I have to use packets. How would i got about this?
-
Ok, thank you!
-
Hello, so this is a follow up to my "Get block from coordinate" post. I have figured out how to find a tile entity from coordinates, but how would I get the tile entity from a dimension? I already have a item so that when i right click a block, it saves its coordinates and dimension. How would i get a tile entity from coordinates and a dimension? And also, if I didn't use the dimension and only coordinates, what would happen? In other words, what is the method to get a tile entity from coordinates and a dimension? Thanks in advanced.
-
[SOLVED] Get a block from a coordiante?
TesterTesting135 replied to TesterTesting135's topic in Modder Support
Ok, thank you so much! I'm going to mark this closed now. -
[SOLVED] Get a block from a coordiante?
TesterTesting135 replied to TesterTesting135's topic in Modder Support
Oh, I am on 1.12.2. What is the method for 1.12? -
[SOLVED] Get a block from a coordiante?
TesterTesting135 replied to TesterTesting135's topic in Modder Support
Ok, thank you! Also, what is the method to get the dimension? -
Hello, so I'm trying to make a energy transfer node that can wirelessly transfer energy through a linking card. I am making it so that it can transfer an infinite amount of energy by just dumping the contents of the sending end to the receiving end. I already have it so that you can shift right click on the receiving end of the block to save the coordinates to the NBT of the link card. The thing is, once you have the coordinates, how would you actually find the block in the world (The receiving end block)? I have it so it gets the coordinates but what is the method to find the block in those coordinates? EDIT: In other words, how would I get the BlockPos out of the coordinates?
-
Got it working now. Just realized. Thanks.
-
?
-
Hello, so i've recently made a plasma capability and would like there to be a block to relay, or transfer, plasma. The problem is, whenever i try to use the block to transfer plasma between multiple relay blocks, it will only transfer plasma to one. I think this is because the second plasma relay is also transfering back to the previous relay. Here is my sendPlasma method: private void sendPlasma() { if (plasmaStorage.getPlasmaStored() > 0) { for (EnumFacing facing : EnumFacing.VALUES) { TileEntity tileEntity = world.getTileEntity(pos.offset(facing)); if (tileEntity != null && tileEntity.hasCapability(CapabilityPlasma.PLASMA, facing.getOpposite())) { IPlasmaStorage handler = tileEntity.getCapability(CapabilityPlasma.PLASMA, facing.getOpposite()); if (handler != null && handler.canReceive()) { int accepted = handler.receivePlasma(plasmaStorage.getPlasmaStored(), false); plasmaStorage.consumePlasma(accepted); if (plasmaStorage.getPlasmaStored() <= 0) { break; } } } } markDirty(); } } Is there any way i can make this directional? I have tried to limit the capability to EnumFacing.NORTH, but it only works for one direction. Any ideas why? Any help would be greatly appreciated. Thanks.
-
Help with auto-ejecting items
TesterTesting135 replied to TesterTesting135's topic in Modder Support
I'm using forge 1.12.2-14.23.5.2836 and mappings "stable_39". I just downloaded the mdk, extracted it, and hopped into intellij and imported the project. I ran setUpDecompWorkspace. -
Help with auto-ejecting items
TesterTesting135 replied to TesterTesting135's topic in Modder Support
Ok, thanks for showing me. Unfortunately, i'm not getting the same thing .https://imgur.com/a/2xiJfE9 -
Help with auto-ejecting items
TesterTesting135 replied to TesterTesting135's topic in Modder Support
I can see the code, but what do yoiu mean they have java docs? -
Help with auto-ejecting items
TesterTesting135 replied to TesterTesting135's topic in Modder Support
Is this the correct webstite? mcforge.readthedocs.io/en -
Help with auto-ejecting items
TesterTesting135 replied to TesterTesting135's topic in Modder Support
Could you please bring me a link to the documentation? -
Help with auto-ejecting items
TesterTesting135 replied to TesterTesting135's topic in Modder Support
Ok so i am using insertItemStacked, and i modified the code a bit. Now it works with some tile entities, like a bin from mekanism and a vacuum chest from ender io. However, for other tile entities, like the chest, it will not work, and won't even insert into the container. Here is my code: private void sendItems() { if (!outputHandler.getStackInSlot(0).isEmpty()) { for (EnumFacing facing : EnumFacing.VALUES) { TileEntity tileEntity = world.getTileEntity(pos.offset(facing)); if (tileEntity != null && tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite())) { IItemHandler handler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()); if (handler != null) { ItemStack result = ItemHandlerHelper.insertItemStacked(handler, outputHandler.getStackInSlot(0), false); if (result.isEmpty()) { outputHandler.getStackInSlot(0).shrink(64); } if (outputHandler.getStackInSlot(0).isEmpty()) { break; } } } } markDirty(); } } Also, what do you mean by the get capability returning null? I checked if it had the item handler capability first. -
Help with auto-ejecting items
TesterTesting135 replied to TesterTesting135's topic in Modder Support
Ok, thank you!