Jump to content

Villfuk02

Members
  • Posts

    301
  • Joined

  • Last visited

Everything posted by Villfuk02

  1. @Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); IDetector detector = stack.getCapability(DetectorProvider.DETECTOR_CAP, null); detector.setFound(false); Block block = worldIn.getBlockState(player.getPosition()).getBlock(); int x = 0; int y = 0; int z = 0; if (!(block instanceof BlockLiquid)){ Utils.getLogger().info("No Liquid"); int batteryMulti = 0; int coilMulti = 0; int rodMulti = 0; int displayMulti = 0; if (stack.getItemDamage() < maxDamage - 2500){ switch(detector.getCoil()){ case 0: Scan(pos, worldIn, false, stack, generateScan(-1, 1, 1, generateScan(0, 1, 2))); break; case 1: Scan(pos, worldIn, false, stack, generateScan(-2, 0, 0,generateScan(-1, 1, 2,generateScan(0, 2, 3)))); break; case 2: Scan(pos, worldIn, false, stack, generateScan(-2, 1, 2,generateScan(-1, 2, 3,generateScan(0, 3, 4)))); break; case 3: Scan(pos, worldIn, false, stack,generateScan(-2, 1, 2,generateScan(-1, 2, 3,generateScan(0, 2, 3,generateScan(1, 2, 3,generateScan(2, 1, 2)))))); break; case 4: Scan(pos, worldIn, true, stack, generateScan(-2, 0, 0,generateScan(-1, 1, 2,generateScan(0, 2, 3)))); break; case 5: Scan(pos, worldIn, false, stack, generateScan(-5, 0, 0,generateScan(-4, 1, 1,generateScan(-3, 1, 1,generateScan(-2, 1, 2,generateScan(-1, 1, 2,generateScan(0, 1, 2))))))); break; } if(detector.getBattery() < BatteryTypes.values().length) batteryMulti = BatteryTypes.values()[detector.getBattery()].getMulti(); if(detector.getRod() < RodTypes.values().length) rodMulti = RodTypes.values()[detector.getRod()].getMulti(); if(detector.getCoil() < CoilTypes.values().length) coilMulti = CoilTypes.values()[detector.getCoil()].getMulti(); if(detector.getDisplay() < DisplayTypes.values().length) displayMulti = DisplayTypes.values()[detector.getDisplay()].getMulti(); stack.damageItem((batteryMulti * coilMulti * rodMulti * displayMulti) / efficiency, player); if (detector.getIntegrity() > 2000) detector.setIntegrity(detector.getIntegrity() -(((detector.getIntegrity() - 2000) * RodTypes.values()[detector.getRod()].getIntegrity()) / (use_integrity_divider * 5))); } else { stack.damageItem(maxDamage - stack.getItemDamage(), player); } } else { Utils.getLogger().info("Liquid"); } return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } public List<BlockPos> generateScan(int y, int radius, int max){ List<BlockPos> modifiers = new ArrayList(); for(int x = 0 - radius; x <= radius; x++){ for(int z = 0 - radius; z <= radius; z++){ if(Math.abs(x) + Math.abs(z) <= max) modifiers.add(new BlockPos(x, y, z)); } } return modifiers; } public List<BlockPos> generateScan(int y, int radius, int max, List<BlockPos> modifiers){ for(int x = 0 - radius; x <= radius; x++){ for(int z = 0 - radius; z <= radius; z++){ if(Math.abs(x) + Math.abs(z) <= max) modifiers.add(new BlockPos(x, y, z)); } } return modifiers; } public void Scan(BlockPos pos, World world, Boolean ultraSound, ItemStack stack, List<BlockPos> modifiers){ IDetector detector = stack.getCapability(DetectorProvider.DETECTOR_CAP, null); for (int i = 0; i < modifiers.size(); i++) { BlockPos scanBlock = new BlockPos(pos.getX() + modifiers.get(i).getX(), pos.getY() + modifiers.get(i).getY(), pos.getZ() + modifiers.get(i).getZ()); if (world.getBlockState(scanBlock).getBlock().equals(ModBlocks.archeology_dirt)){ if(ultraSound && ArcheologyDirt.getIntFromState(world.getBlockState(scanBlock)) != 0 && ArcheologyDirt.getIntFromState(world.getBlockState(scanBlock)) != 14){ detector.setFound(true); detector.setDistance(scanBlock.distanceSqToCenter(pos.getX(), pos.getY(), pos.getZ())); detector.setType(EnumHandler.Types.getTypeId(ArcheologyDirt.getTypeFromMeta(ArcheologyDirt.getIntFromState((world.getBlockState(scanBlock)))))); detector.setDirection(getDirection(modifiers.get(i))); } else if(ArcheologyDirt.getMetalFromMeta(ArcheologyDirt.getIntFromState(world.getBlockState(scanBlock)))){ detector.setFound(true); detector.setDistance(scanBlock.distanceSqToCenter(pos.getX(), pos.getY(), pos.getZ())); detector.setType(EnumHandler.Types.getTypeId(ArcheologyDirt.getTypeFromMeta(ArcheologyDirt.getIntFromState((world.getBlockState(scanBlock)))))); detector.setDirection(getDirection(modifiers.get(i))); } } } } Here's the method i call the check in, hope you can find something
  2. I've used this method to make my own Anvil recipes, @SubscribeEvent public void handleAnvilEvent(AnvilUpdateEvent evt) but i have one problem - the anvil needs to have something in both slots in order to allow use, but i want the item to be repaired just with XP. Then i had an idea - i can make an reusable item just to fill up the slot and allow the repair, but the anvil allways consumes the item Is there a way to fix any of these two problems? thanks
  3. because the item is supposed to not work in water, but it still does-client side and removes durability, updates model and other things and reverts back to it's supposed state when it syncs with the server, so the durability bar jumps back and forth, etc.
  4. I have in my code this line: if (!(block instanceof BlockLiquid)){ while the block is block the player is currently standing in Block block = worldIn.getBlockState(player.getPosition()).getBlock(); and i'm trying to test if the player is standing in any liquid for example water/lava/oil... It seems to work, but only server-side not client-side and only on vanilla liquids - lava and water with liquids from other mods it doesn't detect liquid at all please hep me thanks
  5. Ok, and what if i want to make the item consume XP from the player to repair, is there a way to remove the XP from a player?
  6. Ok, thanks
  7. does it also work with chests and other inventories?
  8. I made custom item with durability and i want it to slowly repair, how can i call something every tick? i found no methods for ticking item unless it's being used or equipped as armor thx for any help
  9. K, but try looking at the sample i sent you meanwhile please I'm running out of time today and i'd like to fix it
  10. I've changed the anvil method a little: @SubscribeEvent public void handleAnvilEvent(AnvilUpdateEvent evt) { ItemStack stack = evt.getLeft().copy(); if(stack.getItem().equals(ModTools.metal_detector)){ if (evt.getRight().getItem().equals(Items.DYE)){ if(evt.getRight().getMetadata() < 7){ int antiIntegrity = 100 - stack.getCapability(DetectorProvider.DETECTOR_CAP, null).getIntegrity(); int cost = (antiIntegrity * antiIntegrity) / 200 + 5; evt.setCost(cost); stack.getCapability(DetectorProvider.DETECTOR_CAP, null).setBattery(evt.getRight().getMetadata() + 1); stack.getCapability(DetectorProvider.DETECTOR_CAP, null).setIntegrity(stack.getCapability(DetectorProvider.DETECTOR_CAP, null).getIntegrity() - cost); evt.setOutput(stack); } } } } But the integrity doesn't change and is allways 100 When i made it to print the integrity to chat, it printed the correct value... BTW here are methods about Integrity from the Capability @Override public void setIntegrity(int value) { integrity = value; if (integrity < 0) integrity = 0; if (integrity > 100) integrity = 100; } @Override public int getIntegrity() { return integrity; } IDK what is wrong with this, because setBattery() works
  11. Ok, i made this: @SubscribeEvent public void handleAnvilEvent(AnvilUpdateEvent evt) { ItemStack stack = evt.getLeft(); if(stack.equals(ModTools.metal_detector)){ if (evt.getRight().equals(Items.DYE)){ if(evt.getRight().getMetadata() < 7) evt.setCost(4); stack.getCapability(DetectorProvider.DETECTOR_CAP, null).setBattery(evt.getRight().getMetadata() + 1); evt.setOutput(stack); } } } but it does just nothing am i supposed to register it somewhere, or set something to true, or something? i couldn't find the solution myself
  12. would this be simpler with anvil instead of crafting?
  13. thx, did it like this: public static ItemStack generateDetector(int coil, int display, int rod, int battery){ ItemStack stack = new ItemStack(ModTools.metal_detector); stack.getCapability(DetectorProvider.DETECTOR_CAP, null).setCoil(coil); stack.getCapability(DetectorProvider.DETECTOR_CAP, null).setDisplay(display); stack.getCapability(DetectorProvider.DETECTOR_CAP, null).setRod(rod); stack.getCapability(DetectorProvider.DETECTOR_CAP, null).setBattery(battery); return stack; } public static void registerCraftingRecipes() { GameRegistry.addRecipe(new ShapelessOreRecipe(generateDetector(1, 1, 1, 1), new Object[] {"ingotIron", "chest"})); GameRegistry.addRecipe(new ShapelessOreRecipe(generateDetector(2, 2, 2, 2), new Object[] {"ingotGold", "chest"})); GameRegistry.addRecipe(new ShapelessOreRecipe(generateDetector(3, 3, 3, 7), new Object[] {Blocks.OBSIDIAN, "chest"})); } now, what if i want to be able to replace parts of the detector like if i put in crafting detector and coil, i'll get detector same as the one i put there, but with different coil how can i do this else than making a recipe for every detector-part combination?
  14. i made it so different recipes make different NBT public static NBTTagCompound generateNBT(int coil, int display, int rod, int battery){ NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("coil", coil); nbt.setInteger("display", display); nbt.setInteger("rod", rod); nbt.setInteger("battery", battery); return nbt; } public static void registerCraftingRecipes() { GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModTools.metal_detector, 1, 0, generateNBT(1, 1, 1, 1)), new Object[] {"ingotIron", "chest"})); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModTools.metal_detector, 1, 0, generateNBT(2, 2, 2, 2)), new Object[] {"ingotGold", "chest"})); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModTools.metal_detector, 1, 0, generateNBT(3, 3, 3, 3)), new Object[] {Blocks.OBSIDIAN, "chest"})); } (the recipes are just placeholders) but the item allways has the default values how do i make it read from the NBT and save it to the capability?
  15. someBODY once told me you can set NBT for itemStack in the crafting recipe, if it's true, i could just read from NBT and set the values from it. Is it possible?
  16. ok, works, thanks Now how do i make it so, when i craft the item, the capability has different values depending on the crafting recipe? Basically i set the valuses when is the item crafted
  17. And should i call initCapabilities in constructor, or override it, or call it form somewhere else?
  18. look at GitHub detector.setFound(false); basicly the first line, where it tries to do something with the Capability
  19. [15:43:30] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: ---- Minecraft Crash Report ---- // You should try our sister game, Minceraft! Time: 2/5/17 3:43 PM Description: Unexpected error java.lang.NullPointerException: Unexpected error at vms.archeology.items.Detector.onItemUse(Detector.java:102) at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:180) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1606) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2276) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1841) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1119) at net.minecraft.client.Minecraft.run(Minecraft.java:407) at net.minecraft.client.main.Main.main(Main.java:118) 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.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) 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.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at vms.archeology.items.Detector.onItemUse(Detector.java:102) at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:180) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1606) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2276) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player774'/1, l='MpServer', x=4.01, y=6.00, z=12.36]] Chunk stats: MultiplayerChunkCache: 81, 81 Level seed: 0 Level generator: ID 01 - flat, ver 0. Features enabled: false Level generator options: Level spawn location: World: (8,4,8), Chunk: (at 8,0,8 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 69924 game time, 69924 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 1 total; [EntityPlayerSP['Player774'/1, l='MpServer', x=4.01, y=6.00, z=12.36]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:451) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2774) at net.minecraft.client.Minecraft.run(Minecraft.java:436) at net.minecraft.client.main.Main.main(Main.java:118) 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.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) 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.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) -- System Details -- Details: Minecraft Version: 1.11.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_111, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 1888181704 bytes (1800 MB) / 2130051072 bytes (2031 MB) up to 2130051072 bytes (2031 MB) JVM Flags: 3 total; -Xincgc -Xmx2048M -Xms2048M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.38 Powered by Forge 13.20.0.2210 6 mods loaded, 6 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA minecraft{1.11.2} [Minecraft] (minecraft.jar) UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.11.2-13.20.0.2210.jar) UCHIJAAAA forge{13.20.0.2210} [Minecraft Forge] (forgeSrc-1.11.2-13.20.0.2210.jar) UCHIJAAAA archeology{0.0.0 (Alpha)} [Archeology] (bin) UCHIJAAAA jei{4.2.2.215} [Just Enough Items] (jei_1.11.2-4.2.2.215.jar) Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 369.09' Renderer: 'GeForce GT 610/PCIe/SSE2' Launched Version: 1.11.2 LWJGL: 2.9.4 OpenGL: GeForce GT 610/PCIe/SSE2 GL version 4.5.0 NVIDIA 369.09, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: Current Language: English (US) Profiler Position: N/A (disabled) CPU: 2x Pentium(R) Dual-Core CPU E5700 @ 3.00GHz [15:43:31] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Villfuk\Desktop\ancient\run\.\crash-reports\crash-2017-02-05_15.43.30-client.txt AL lib: (EE) alc_cleanup: 1 device not closed Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
  20. it crashes when it tries to interact with the Capability i added for example when i use the item
  21. anyone here please?
  22. Ok, updated my GitHub https://github.com/Villfuk02/Archeology
  23. I BROKE MY DETECTOR HALP
  24. Also, it doesn't work ¯\_(ツ)_/¯ IDK what am i doing wrong, because i don't understand it properly
×
×
  • Create New...

Important Information

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