Jump to content

[1.10] Consuming Item On A Flight Ring


opum2
 Share

Recommended Posts

So I have the a flight ring, and I want it to consume an item, but I don't know much about NBT or what the equivalent to player.inventory.consumeInventoryItem(itemNameHere) is.

 

Here is my code so far, with nothing to consume or check for the item:

 

public class FlightDongle extends Item implements IFlight {

public FlightDongle(String unlocalizedName) 
{
	this.setUnlocalizedName(unlocalizedName);
	this.setCreativeTab(BamsMod.tabBams);
	this.setMaxStackSize(1);
}

@Override
public String getUnlocalizedName(ItemStack itemStack) 
{
	if (itemStack.getItemDamage() == 0) 
	{
		return this.getUnlocalizedName() + ".deactivated";
	}
	if (itemStack.getItemDamage() == 1) 
	{
		return this.getUnlocalizedName() + ".activated";
	}
	return "deactivated";
}

@Override
    public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean bool)
    {
    	list.add("\u00A7f" + "Hold Shift For Details");
    	if((Keyboard.isKeyDown(42)) || (Keyboard.isKeyDown(54)))
    	{
    		list.add("");
    		list.add("\u00A7e" + "Consumes 1 BamSalt Every 2 Minutes.");
    	}
    }

@Override
public void getSubItems(Item item, CreativeTabs tabs, List subItems) 
{
	subItems.add(new ItemStack(item, 1, 0));
	subItems.add(new ItemStack(item, 1, 1));
}

@Override
public boolean onDroppedByPlayer(ItemStack stack, EntityPlayer player) 
{
	deactivateDongle(stack, player);
	return super.onDroppedByPlayer(stack, player);
}

@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand) 
{
	if (itemStack.getItemDamage() == 0) 
	{
		activateDongle(itemStack, player);
	}
	else
	{
		deactivateDongle(itemStack, player);
	}
	return new ActionResult(EnumActionResult.PASS, itemStack);
}
@Override
public void activateDongle(ItemStack itemStack, EntityPlayer player) 
{
	itemStack.setItemDamage(1);
	player.capabilities.allowFlying = true;
	player.capabilities.isFlying = true;
	player.fallDistance = 0;

	player.sendPlayerAbilities();
}

@Override
public void deactivateDongle(ItemStack itemStack, EntityPlayer player) 
{
	itemStack.setItemDamage(0);
	player.capabilities.allowFlying = false;
	player.capabilities.isFlying = false;

	player.sendPlayerAbilities();
}

@Override
public boolean isActive(ItemStack itemStack) 
{
	return itemStack.getItemDamage()==1;
}

 

 

Link to comment
Share on other sites

Well...a couple things (all unrelated to your problem) first.

  • Why don't you set the unlocalized name to the registry name?
  • Why do you use "\u00A7f" instead of the EnumChatFormat (EnumTextFormat? I forget the current class name)
  • Why do you use Keyboard.isKeyDown(42)? I'm pretty sure the last bool parameter will do what you want.

 

Now, on to your question:

You don't have an onUpdate method anywhere to even handle the deduction over time.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Well...step 1:

You need a way to count time.

Step 2:

When the time reaches a certain value, consume an item from the player's inventory (if it exists)

Step 3:

Reset the timer

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Would I use some sort of tick handler to count the ticks? Also, I don't know what the equivalent of player.inventory.consumeInventoryItem(itemHere); is in 1.10. I have the onUpdate method and I've casted Entity to EntityPlayer, but don't know what to do from there. As I said, not good at all with NBT, so I'm kinda stuck. Lol

 

I know it's nothing, but it's just to show an example of the variables and stuff. Here is what I have:

@Override
public void onUpdate(ItemStack itemStack, World world, Entity entity, int i, boolean bool)
{
	EntityPlayer player = (EntityPlayer)entity;


}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • My modpack install was functioning correctly until I messed around with video settings; if I remember correctly, the only change I made was re-enabling SEUS PTGI shaders (which were previously working fine) and increasing Render Distance from 16 to 32. When I did, the game immediately crashed and now crashes at launch. I've attempted the following to no avail: - Reverted Render Distance from 32 back to 16 via options.txt - Deleted options.txt - Deleted C:\Users\Cody\AppData\Roaming\.minecraft\config\forge-client.toml   Crash log: https://pastebin.com/fSeb4zpN Any advice on what to try next?
    • Can you submit the debug.log? (In Curseforge it's in Minecraft settings somewhere) ¿Puede enviar el archivo debug.log? (En Curseforge, está en la configuración de Minecraft)
    • ---- Minecraft Crash Report ---- 2 3WARNING: coremods are present: 4llibrary (llibrary-core-1.0.11-1.12.2.jar) 5IELoadingPlugin (ImmersiveEngineering-core-0.12-98.jar) 6clothesline-hooks (clothesline-hooks-1.12.2-0.0.1.2.jar) 7SteveKunGLibPlugin (SteveKunG's-Lib-1.12.2-1.2.0.jar) 8ApotheosisCore (Apotheosis-1.12.2-1.12.5.jar) 9iceandfire (iceandfire-1.9.1-1.12.2.jar) 10GSHooksLoader (GalaxySpace-1.12.2-2.0.19.jar) 11MixinBooter (!mixinbooter-7.0.jar) 12MicdoodlePlugin (Galacticraft-1.12.2-4.0.4.jar) 13Contact their authors BEFORE contacting forge 14 15// I bet Cylons wouldn't have this problem. 16 17Time: 1/29/23 7:44 PM 18Description: Exception in server tick loop 19 20java.lang.NoSuchMethodError: slimeknights.tconstruct.library.tools.ToolCore.func_190903_i()Lnet/minecraft/item/ItemStack; 21at liketechnik.tinkertweaks.config.ConfigFile.lambda$null$5(ConfigFile.java:138) 22at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) 23at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) 24at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) 25at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) 26at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) 27at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) 28at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) 29at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) 30at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485) 31at liketechnik.tinkertweaks.config.ConfigFile.lambda$insertDefaults$6(ConfigFile.java:149) 32at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) 33at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) 34at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) 35at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) 36at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) 37at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) 38at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) 39at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) 40at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485) 41at liketechnik.tinkertweaks.config.ConfigFile.insertDefaults(ConfigFile.java:129) 42at slimeknights.mantle.config.AbstractConfig.load(AbstractConfig.java:32) 43at liketechnik.tinkertweaks.config.Config.load(Config.java:25) 44at liketechnik.tinkertweaks.LiketechniksTinkerTweaks.registerTools(LiketechniksTinkerTweaks.java:58) 45at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_350_LiketechniksTinkerTweaks_registerTools_Register.invoke(.dynamic) 46at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) 47at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144) 48at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) 49at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:850) 50at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:630) 51at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:99) 52at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:333) 53at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:125) 54at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:486) 55at java.lang.Thread.run(Thread.java:750) 56 57No Mixin Metadata is found in the Stacktrace. 58 59 60A detailed walkthrough of the error, its code path and all known details is as follows: 61--------------------------------------------------------------------------------------- 62 63-- System Details -- 64Details: 65Minecraft Version: 1.12.2 66Operating System: Linux (amd64) version 5.4.0-121-generic 67Java Version: 1.8.0_362, Temurin 68Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Temurin 69Memory: 942390688 bytes (898 MB) / 1400373248 bytes (1335 MB) up to 1771044864 bytes (1689 MB) 70JVM Flags: 3 total; -XX:MaxMetaspaceSize=300M -Xmx1900M -Xms950M 71IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 72FML: MCP 9.42 Powered by Forge 14.23.5.2859 41 mods loaded, 41 mods active 73States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored 74 75| State | ID | Version | Source | Signature | 76|:----- |:------------------------ |:------------------------ |:------------------------------------------------------- |:---------------------------------------- | 77| LCH | minecraft | 1.12.2 | minecraft.jar | None | 78| LCH | mcp | 9.42 | minecraft.jar | None | 79| LCH | FML | 8.0.99.99 | forge.jar | e3c3d50c7c986df74c645c0ac54639741c90a557 | 80| LCH | forge | 14.23.5.2859 | forge.jar | e3c3d50c7c986df74c645c0ac54639741c90a557 | 81| LCH | micdoodlecore | 4.0.4 | minecraft.jar | None | 82| LCH | mixinbooter | 7.0 | minecraft.jar | None | 83| LCH | clothesline-hooks | 1.12.2-0.0.1.2 | minecraft.jar | None | 84| LCH | deconstruction | 3.0.4 | [MC1.12.2]DeconTable-3.0.4.jar | None | 85| LCH | placebo | 1.6.0 | Placebo-1.12.2-1.6.0.jar | None | 86| LCH | apotheosis | 1.12.4 | Apotheosis-1.12.2-1.12.5.jar | None | 87| LCH | galacticraftcore | 4.0.4 | Galacticraft-1.12.2-4.0.4.jar | None | 88| LCH | galacticraftplanets | 4.0.4 | Galacticraft-1.12.2-4.0.4.jar | None | 89| LCH | asmodeuscore | 0.0.30 | AsmodeusCore-1.12.2-0.0.31.jar | None | 90| LCH | attributefix | 1.0.10 | AttributeFix-1.12.2-1.0.10.jar | d476d1b22b218a10d845928d1665d45fce301b27 | 91| LCH | codechickenlib | 3.2.3.358 | CodeChickenLib-1.12.2-3.2.3.358-universal.jar | f1850c39b2516232a2108a7bd84d1cb5df93b261 | 92| LCH | redstoneflux | 2.1.1 | RedstoneFlux-1.12-2.1.1.1-universal.jar | None | 93| LCH | cofhcore | 4.6.6 | CoFHCore-1.12.2-4.6.6.1-universal.jar | None | 94| LCH | cofhworld | 1.4.0 | CoFHWorld-1.12.2-1.4.0.1-universal.jar | None | 95| LCH | mantle | 1.12-1.3.3.55 | Mantle-1.12-1.3.3.55.jar | None | 96| LCH | jei | 4.16.1.302 | jei_1.12.2-4.16.1.302.jar | None | 97| LCH | tconstruct | 1.12.2-2.13.0.183 | TConstruct-1.12.2-2.13.0.183.jar | None | 98| LCH | conarm | 1.2.5.10 | conarm-1.12.2-1.2.5.10.jar | b33d2c8df492beff56d1bbbc92da49b8ab7345a1 | 99| LCH | golems | 7.1.9 | ExtraGolems-1.12-7.1.9.jar | None | 100| LCH | galaxyspace | 2.0.19 | GalaxySpace-1.12.2-2.0.19.jar | None | 101| LCH | waila | 1.8.26 | Hwyla-1.8.26-B41_1.12.2.jar | None | 102| LCH | llibrary | 1.7.20 | llibrary-1.7.20-1.12.2.jar | b9f30a813bee3b9dd5652c460310cfcd54f6b7ec | 103| LCH | iceandfire | 1.9.1 | iceandfire-1.9.1-1.12.2.jar | None | 104| LCH | exoplanets | 0.1.4 | Interstellar-Exoplanets-0.1.4.jar | 3a39a2b4e84bec377849d48f372382b39f883e16 | 105| LCH | mjrlegendslib | 1.12.2-1.2.1 | MJRLegendsLib-1.12.2-1.2.1.jar | b02331787272ec3515ebe63ecdeea0d746653468 | 106| LCH | stevekung's_lib | 1.2.0 | SteveKunG's-Lib-1.12.2-1.2.0.jar | None | 107| LCH | moreplanets | 2.3.0 | More-Planets-1.12.2-2.3.0-GC4.0.4.jar | None | 108| LCH | moreplanetsextras | 1.12.2-1.0 | MorePlanetsExtras-1.12.2-1.0.jar | None | 109| LCH | mutantbeasts | 1.12.2-1.0.2 | MutantBeasts-1.12.2-1.0.2.jar | None | 110| LCH | simpleplanes | 3.0.1.7 | simpleplanes-1.12.2-3.0.1.7.jar | None | 111| LCH | liketechnikstinkertweaks | 1.12.2-1.0.0.DEV.01dd320 | TinkersToolLevelingWithRandomModifiers-1.12.2-1.0.3.jar | None | 112| LCH | vampirism | 1.6.2 | Vampirism-1.12.2-1.6.2.jar | None | 113| LCH | teamlapen-lib | 1.6.2 | Vampirism-1.12.2-1.6.2.jar | None | 114| LCH | ladylib | 2.6.2 | Ladylib-2.6.2.jar | None | 115| LCH | modwinder | 1.1 | Ladylib-2.6.2.jar | None | 116| LCH | dissolution | 0.3.13 | Dissolution-1.12.2-0.3.13r2.jar | None | 117| LCH | immersiveengineering | 0.12-98 | ImmersiveEngineering-0.12-98.jar | None | 118 119Loaded coremods (and transformers): 120llibrary (llibrary-core-1.0.11-1.12.2.jar) 121net.ilexiconn.llibrary.server.core.plugin.LLibraryTransformer 122net.ilexiconn.llibrary.server.core.patcher.LLibraryRuntimePatcher 123IELoadingPlugin (ImmersiveEngineering-core-0.12-98.jar) 124blusunrize.immersiveengineering.common.asm.IEClassTransformer 125clothesline-hooks (clothesline-hooks-1.12.2-0.0.1.2.jar) 126com.jamieswhiteshirt.clothesline.hooks.plugin.ClassTransformer 127SteveKunGLibPlugin (SteveKunG's-Lib-1.12.2-1.2.0.jar) 128 129ApotheosisCore (Apotheosis-1.12.2-1.12.5.jar) 130shadows.ApotheosisTransformer 131iceandfire (iceandfire-1.9.1-1.12.2.jar) 132com.github.alexthe666.iceandfire.patcher.IceAndFireRuntimePatcher 133GSHooksLoader (GalaxySpace-1.12.2-2.0.19.jar) 134galaxyspace.core.hooklib.minecraft.PrimaryClassTransformer 135MixinBooter (!mixinbooter-7.0.jar) 136 137MicdoodlePlugin (Galacticraft-1.12.2-4.0.4.jar) 138micdoodle8.mods.miccore.MicdoodleTransformer 139Pulsar/tconstruct loaded Pulses: 140- TinkerCommons (Enabled/Forced) 141- TinkerWorld (Enabled/Not Forced) 142- TinkerTools (Enabled/Not Forced) 143- TinkerHarvestTools (Enabled/Forced) 144- TinkerMeleeWeapons (Enabled/Forced) 145- TinkerRangedWeapons (Enabled/Forced) 146- TinkerModifiers (Enabled/Forced) 147- TinkerSmeltery (Enabled/Not Forced) 148- TinkerGadgets (Enabled/Not Forced) 149- TinkerOredict (Enabled/Forced) 150- TinkerIntegration (Enabled/Forced) 151- TinkerFluids (Enabled/Forced) 152- TinkerMaterials (Enabled/Forced) 153- TinkerModelRegister (Enabled/Forced) 154- wailaIntegration (Enabled/Not Forced) 155 156Profiler Position: N/A (disabled) 157Is Modded: Definitely; Server brand changed to 'fml,forge' 158Type: Dedicated Server (map_server.txt)
    • Es que nunca me llega ha aparecer la carpeta de crash reports, el informe de error que yo pasé lo tengo que coger directamente de logs, y siempre que se me crashea me pone error 1.
    • Yes, you can. People have made datapacks for cutting wood planks into stairs, etc. Just make your Json recipe files formatting exactly the same way the files are done for the Stone Cutter recipes.
  • Topics

×
×
  • Create New...

Important Information

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