Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

frankiecav

Members
  • Posts

    37
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

frankiecav's Achievements

Tree Puncher

Tree Puncher (2/8)

3

Reputation

  1. Hi forum, I wanted to share something that I think is pretty neat and that you may be wondering how to do. Adjusting the size of items while being held in hand, while not the most important aspect of a mod can be a fun thing to play with, which isn't very complicated, either. Custom size, versus default below: Changing the size is pretty easy. It only has to do with editing the item json file. Below is the json file for the orange sword seen above. Finding the size you want requires testing. By changing the scale, you'll probably have to translate the object as well. { "parent": "item/handheld", "textures": { "layer0": "survivalessentials:item/camiline_sword" }, "display": { "ground": { "rotation": [ 0, 0, 0 ], "translation": [ 0, 3, 0], "scale":[ 1, 1, 1 ] }, "fixed": { "rotation": [ 0, 0, 0 ], "translation": [ 0, 0, 0], "scale":[ 1, 1, 1 ] }, "thirdperson_righthand": { "rotation": [ 0, 270, 40 ], "translation": [ 0, 8, 1], "scale": [ 1.3, 1.3, 1.3 ] }, "firstperson_righthand": { "rotation": [ 0, 270, 40 ], "translation": [ 0, 8, 1 ], "scale": [ 1.3, 1.3, 1.3 ] }, "firstperson_lefthand": { "rotation": [ 0, 90, -40 ], "translation": [ 0, 8, 1 ], "scale": [ 1.3, 1.3, 1.3 ] }, "thirdperson_lefthand": { "rotation": [ 0, 90, -40 ], "translation": [0, 8, 1 ], "scale": [ 1.3, 1.3, 1.3] } } }
  2. I realize that, but you know what: That constructor is only used for registering the container. The ItemStackHandler doesn't do anything except fill out the super because of the second constructor, the one which I use. That's how I understand it, anyway. Thanks for your help, and everyone on the thread. One more thing, before you leave: If I wanted to make this item switch textures depending on what was in it, any advice? I should be able to tackle this one on my own, but since I have you on the thread...
  3. except... it did. the sheath was able to hold an item and worked as expected.
  4. This works: public ContainerSheath(final int windowID, PlayerInventory player) { this(windowID, player, new ItemStackHandler()); } public ContainerSheath(final int windowID, PlayerInventory player, IItemHandler cap) { super(EssentialContainers.SHEATH, windowID); for(int y = 0; y < 3; ++y) for(int x = 0; x < 9; ++x) this.addSlot(new Slot(player, 9 + x + y * 9, 8 + x * 18, 84 + y * 18)); for(int x = 0; x < 9; ++x) this.addSlot(new Slot(player, x, 8 + x * 18, 142)); this.addSlot(new SlotItemHandler(cap, 0, 50, 50)); } Is there a downside to using that?
  5. But how do I invoke IItemHandler here: public ContainerSheath(final int windowID, PlayerInventory player) { this(windowID, player); } public ContainerSheath(final int windowID, PlayerInventory player, IItemHandler cap) { super(EssentialContainers.SHEATH, windowID); for(int y = 0; y < 3; ++y) for(int x = 0; x < 9; ++x) this.addSlot(new Slot(player, 9 + x + y * 9, 8 + x * 18, 84 + y * 18)); for(int x = 0; x < 9; ++x) this.addSlot(new Slot(player, x, 8 + x * 18, 142)); this.addSlot(new SlotItemHandler(cap, 0, 50, 50)); } in the top constructor? Edit: I put in ItemStackHandler
  6. Ok loordgek I'll try it. So you're saying that if the itemstack doesn't have the capability it will return null. I set the capability. This makes sense!
  7. Ok. I thought that since in initCapabilities I returned SheathCapability, stack would contain SheathCapability.
  8. I don't see how that helps, I'm trying to pass in an ICapabilityProvider not an IItemHandler. I have ItemStackHandler in the Capability class. Unless I'm totally missing something (definitely possible). I really appreciate everyone's patience. Wait... can I just say: ICapabilityProvider icap = stack; if (icap instanceof SheathCapability) { NetworkHooks.openGui((ServerPlayerEntity) player, new InterfaceSheath((SheathCapability) icap)); } ?? Apparently not, because it didn't work!
  9. Yes, but then how do I get it to return ICapabilityProvider or SheathCapability? public class ItemSheath extends Item { public ItemSheath() { super(new Properties().group(SurvivalEssentials.ESSENTIAL_TAB).maxStackSize(1)); setRegistryName("sheath"); } @Override public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { PlayerEntity player = context.getPlayer(); if(!context.getWorld().isRemote && player instanceof ServerPlayerEntity) { ICapabilityProvider icap = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); if (icap instanceof SheathCapability) { NetworkHooks.openGui((ServerPlayerEntity) player, new InterfaceSheath((SheathCapability) icap)); } } return ActionResultType.SUCCESS; } @Override public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) { return new SheathCapability(); } public static class InterfaceSheath implements INamedContainerProvider { private final SheathCapability sheath; public InterfaceSheath(SheathCapability sheath) { this.sheath = sheath; } @Override public ITextComponent getDisplayName() { return NarratorChatListener.EMPTY; } @Override public Container createMenu(int windowID, PlayerInventory playerInventory, PlayerEntity playerIn) { return new ContainerSheath(windowID, playerInventory, sheath); } } } "Cannot convert LazyOptional<IItemHandler> to ICapabilityProvider"
  10. Ok. Start a new thread, post build.gradle and cmd/ps logs, and the specific problem you’re having ( mine was that the MCP wasn’t installing)
  11. You set it to the file location of your JDK?
  12. Actually forget that... here's what I think has to be fixed: @Override public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) { PlayerEntity player = context.getPlayer(); if(!context.getWorld().isRemote && player instanceof ServerPlayerEntity) { SheathCapability icap = new SheathCapability(); NetworkHooks.openGui((ServerPlayerEntity) player, new InterfaceSheath(icap)); } return ActionResultType.SUCCESS; } The Capability needs to be passed into InterfaceSheath, and I make a new instance of it every time onItemUse is called. Is there a way to get the SheathCapability class from ItemStack or ItemUseContext?
  13. Does anyone know if there's a markDirty method for items? That's what I would put in onSlotChanged if this was a tileentity. public ContainerSheath(final int windowID, PlayerInventory player) { this(windowID, player, new SheathCapability()); } public ContainerSheath(final int windowID, PlayerInventory player, SheathCapability cap) { super(EssentialContainers.SHEATH, windowID); ItemStackHandler inv = cap.getInventory(); for(int y = 0; y < 3; ++y) for(int x = 0; x < 9; ++x) this.addSlot(new Slot(player, 9 + x + y * 9, 8 + x * 18, 84 + y * 18)); for(int x = 0; x < 9; ++x) this.addSlot(new Slot(player, x, 8 + x * 18, 142)); this.addSlot(new SlotItemHandler(inv, 0, 50, 50) { @Override public void onSlotChanged() { } }); }
  14. CAS thanks for the example; I fixed the NBT crash. Still trying to go with the capability which Draco and Ben have helped me with... by the way, Frost, I have been trying... and it's not all solutions I'm being thrown (except casual), but hints so that I figure it out on my own which I respect. If I wanted to just copy someone's code completely, there are enough githubs online to do so. Anyway, I'm really close. Just need to get a reference to my capability class without creating an instance of it, as Draco pointed out...
  15. Ok I didn't make an instance of it and I made the ItemStackHandler field in the capability class public. this.addSlot(new SlotItemHandler(cap.inventory, 0, 50, 50)); I'm lazy. It crashes the game when I click on it and try to put it in my inventory. ---- Minecraft Crash Report ---- // Don't do that. Time: 8/6/20 1:21 PM Description: mouseClicked event handler java.lang.IllegalArgumentException: Invalid null NBT value with key Parent at net.minecraft.nbt.CompoundNBT.put(CompoundNBT.java:107) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading} at net.minecraftforge.common.capabilities.CapabilityDispatcher.serializeNBT(CapabilityDispatcher.java:127) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading} at net.minecraftforge.common.capabilities.CapabilityProvider.serializeCaps(CapabilityProvider.java:86) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading} at net.minecraft.item.ItemStack.copy(ItemStack.java:375) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading} at net.minecraft.client.gui.screen.inventory.CreativeScreen.handleMouseClick(CreativeScreen.java:191) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.inventory.ContainerScreen.mouseClicked(ContainerScreen.java:341) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.inventory.CreativeScreen.mouseClicked(CreativeScreen.java:443) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.lambda$mouseButtonCallback$0(MouseHelper.java:87) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.Screen.wrapScreenError(Screen.java:446) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.mouseButtonCallback(MouseHelper.java:85) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:173) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:86) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.client.MouseHelper.lambda$registerCallbacks$5(MouseHelper.java:172) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar:build 10] {} at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:85) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MainWindow.flipFrame(MainWindow.java:296) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:983) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:558) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:177) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_231] {} at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_231] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_231] {} at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_231] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.1.0.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.1.0.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.1.0.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.1.0.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.1.0.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) [forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace: at net.minecraft.nbt.CompoundNBT.put(CompoundNBT.java:107) at net.minecraftforge.common.capabilities.CapabilityDispatcher.serializeNBT(CapabilityDispatcher.java:127) at net.minecraftforge.common.capabilities.CapabilityProvider.serializeCaps(CapabilityProvider.java:86) at net.minecraft.item.ItemStack.copy(ItemStack.java:375) at net.minecraft.client.gui.screen.inventory.CreativeScreen.handleMouseClick(CreativeScreen.java:191) at net.minecraft.client.gui.screen.inventory.ContainerScreen.mouseClicked(ContainerScreen.java:341) at net.minecraft.client.gui.screen.inventory.CreativeScreen.mouseClicked(CreativeScreen.java:443) at net.minecraft.client.MouseHelper.lambda$mouseButtonCallback$0(MouseHelper.java:87) -- Affected screen -- Details: Screen name: net.minecraft.client.gui.screen.inventory.CreativeScreen Stacktrace: at net.minecraft.client.gui.screen.Screen.wrapScreenError(Screen.java:446) at net.minecraft.client.MouseHelper.mouseButtonCallback(MouseHelper.java:85) at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:173) at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:86) at net.minecraft.client.MouseHelper.lambda$registerCallbacks$5(MouseHelper.java:172) at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) at org.lwjgl.system.JNI.invokeV(Native Method) at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:85) -- Affected level -- Details: All players: 1 total; [ClientPlayerEntity['Dev'/273, l='MpServer', x=-492.61, y=63.00, z=-603.96]] Chunk stats: Client Chunk Cache: 625, 361 Level dimension: DimensionType{survivalessentials:cookie} Level name: MpServer Level seed: 5302932262801901022 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: {} Level spawn location: World: (240,63,-48), Chunk: (at 0,3,0 in 15,-3; contains blocks 240,0,-48 to 255,255,-33), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1) Level time: 9480 game time, 9480 day time Known server brands: Level was modded: false Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false Server brand: forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.world.ClientWorld.fillCrashReport(ClientWorld.java:457) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:1839) at net.minecraft.client.Minecraft.run(Minecraft.java:572) at net.minecraft.client.main.Main.main(Main.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) -- System Details -- Details: Minecraft Version: 1.15.2 Minecraft Version ID: 1.15.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_231, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 1200263296 bytes (1144 MB) / 1830813696 bytes (1746 MB) up to 3791650816 bytes (3616 MB) CPUs: 4 JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump ModLauncher: 5.1.0+69+master.79f13f7 ModLauncher launch target: fmluserdevclient ModLauncher naming: mcp ModLauncher services: /eventbus-2.2.0-service.jar eventbus PLUGINSERVICE /forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar object_holder_definalize PLUGINSERVICE /forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar runtime_enum_extender PLUGINSERVICE /accesstransformers-2.1.1-shadowed.jar accesstransformer PLUGINSERVICE /forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar capability_inject_definalize PLUGINSERVICE /forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar runtimedistcleaner PLUGINSERVICE /forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar fml TRANSFORMATIONSERVICE FML: 31.2 Forge: net.minecraftforge:31.2.0 FML Language Providers: javafml@31.2 minecraft@1 Mod List: client-extra.jar Minecraft {minecraft@1.15.2 DONE} main Survival Essentials {survivalessentials@1.1.1 DONE} forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar Forge {forge@31.2.0 DONE} Launched Version: MOD_DEV Backend library: LWJGL version 3.2.2 build 10 Backend API: Intel(R) HD Graphics 620 GL version 4.4.0 - Build 21.20.16.4542, Intel GL Caps: Using framebuffer using OpenGL 3.0 Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'forge' Type: Client (map_client.txt) Resource Packs: Current Language: English (US) CPU: 4x Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz Error is probably here: @Override public INBT serializeNBT() { return null; } @Override public void deserializeNBT(INBT nbt) { } Not sure what goes here...
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.