Everything posted by American2050
-
[Solved] I can't figure this out - Boolean on Client and Server side
Thanks. Gonna look around on how to implement it correctly.
-
[Solved] I can't figure this out - Boolean on Client and Server side
So guys, I went onr of the way you suggested and I'm using the NBT to store the timer, but the problem I see now is that whenever I'm holding the item, it never comes to position. Like you know when you hold a tool and it shows from down and it comes up, its happening the same, but it stays always down. The item works and everything, but I'm not sure what's causing this. I believe it is the reason that I'm constantly updating the NBT (I mean, it has to be that right?) but not sure what I can do to prevent this. Here is the code: http://pastebin.com/46S1v18u Thanks once again for the patience, as always
-
[Solved] Spawn Horses with "Colors"
I'm spawning horses in game using something like: entityX1 = new EntityHorse(world); Stuff.setEntityPos(entityX1, pos.getX(), pos.getY(), pos.getZ()); world.spawnEntityInWorld(entityX1); Problem is that they always spawn as White horses. What do I need to set on them so they can spawn with random colors? PS: I noticed the setHorseTexturePaths on the Horses, but that is private.
-
[Solved] I can't figure this out - Boolean on Client and Server side
Ohhh I see what you guys mean. Thanks for the help. Those are things I always forget to consider.
-
[Solved] I can't figure this out - Boolean on Client and Server side
Yes. You can only cast a value to a type if you know that it's a value of that type. I just noticed that you appear to be using a field of your Item class as a timer, this won't work. Item s are singletons, only one instance exists per item type. This means that you can't store per-stack data in fields, you need to store it in the ItemStack (using metadata, NBT or capabilities). You mean the "updateTick"? It's only running if the item is selected and the item is only max stack at 1, so it shouldn't be a problem, right?
-
[Solved] I can't figure this out - Boolean on Client and Server side
Thanks, I'm using something like this now. Problems solved apparently EntityPlayer player = (EntityPlayer) entity; RayTraceResult rtr = this.rayTrace(world, player, false); And I'm also running the code only when: if(entity instanceof EntityPlayer){ I think I have to make that check right? Because otherway the code will also run if some mob is holding the item?
-
[Solved] I can't figure this out - Boolean on Client and Server side
I think I noticed now where I went wrong, using: RayTraceResult rtr = Minecraft.getMinecraft().objectMouseOver; When apparently I should be using: RayTraceResult rtr = entity.rayTrace(6, 1); Gonna do some tests with that now and see how it goes. Hopefully this is the fix.
-
[Solved] I can't figure this out - Boolean on Client and Server side
So... Maybe the error was another? This was the crash report. [12:11:40] [server thread/WARN] [net.minecraft.network.NetworkSystem]: Failed to handle packet for /127.0.0.1:51001 net.minecraft.util.ReportedException: Ticking player at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:418) ~[EntityPlayerMP.class:?] at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:174) ~[NetHandlerPlayServer.class:?] at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:215) ~[NetworkDispatcher$1.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:308) ~[NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:806) [MinecraftServer.class:?] at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:408) [DedicatedServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_91] Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft at com.mramericanmike.mikedongles.items.WateringDongle.onUpdate(WateringDongle.java:214) ~[WateringDongle.class:?] at net.minecraft.item.ItemStack.updateAnimation(ItemStack.java:526) ~[itemStack.class:?] at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:389) ~[inventoryPlayer.class:?] at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:559) ~[EntityPlayer.class:?] at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2218) ~[EntityLivingBase.class:?] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:259) ~[EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341) ~[EntityPlayerMP.class:?] ... 9 more Caused by: java.lang.ClassNotFoundException: net.minecraft.client.Minecraft at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_91] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_91] at com.mramericanmike.mikedongles.items.WateringDongle.onUpdate(WateringDongle.java:214) ~[WateringDongle.class:?] at net.minecraft.item.ItemStack.updateAnimation(ItemStack.java:526) ~[itemStack.class:?] at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:389) ~[inventoryPlayer.class:?] at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:559) ~[EntityPlayer.class:?] at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2218) ~[EntityLivingBase.class:?] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:259) ~[EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341) ~[EntityPlayerMP.class:?] ... 9 more Caused by: net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerException: Exception in class transformer net.minecraftforge.fml.common.asm.transformers.SideTransformer@770b3be0 from coremod FMLCorePlugin at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:253) ~[forgeSrc-1.10.2-12.18.1.2018.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_91] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_91] at com.mramericanmike.mikedongles.items.WateringDongle.onUpdate(WateringDongle.java:214) ~[WateringDongle.class:?] at net.minecraft.item.ItemStack.updateAnimation(ItemStack.java:526) ~[itemStack.class:?] at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:389) ~[inventoryPlayer.class:?] at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:559) ~[EntityPlayer.class:?] at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2218) ~[EntityLivingBase.class:?] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:259) ~[EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341) ~[EntityPlayerMP.class:?] ... 9 more Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/Minecraft for invalid side SERVER at net.minecraftforge.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:56) ~[forgeSrc-1.10.2-12.18.1.2018.jar:?] at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:249) ~[forgeSrc-1.10.2-12.18.1.2018.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_91] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_91] at com.mramericanmike.mikedongles.items.WateringDongle.onUpdate(WateringDongle.java:214) ~[WateringDongle.class:?] at net.minecraft.item.ItemStack.updateAnimation(ItemStack.java:526) ~[itemStack.class:?] at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:389) ~[inventoryPlayer.class:?] at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:559) ~[EntityPlayer.class:?] at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2218) ~[EntityLivingBase.class:?] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:259) ~[EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341) ~[EntityPlayerMP.class:?] ... 9 more Maybe I misread it and the problem was a different one? Line 214 I believe it was were this was on the original code before I redid it. RayTraceResult rtr = Minecraft.getMinecraft().objectMouseOver;
-
[Solved] I can't figure this out - Boolean on Client and Server side
So I have an item that needs to check if the player is actually looking at some block, so I use RayTraceResult for this, that can be called only on Client Side. My Problem is that then, if that returns true, I need to do something on the Server side, but as I'm setting a boolean to true on the Client side, that boolean is true only on the Client, and not on the Server. How would I go around this so the server knows that the boolean is returning true on the Client and it needs to do stuff? This is the code: @Override public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { //CHECK IF IS SELECTED if(isSelected){ if(updateTick>=4) { updateTick = 0; //CLIENT SIDE if(world.isRemote){ //IS LOCKED? if(this.getNBTTagBoolean(stack, TAG_WATERING_DONGLE_LOCKED)){ //GET BLOCK PLAYER IS LOOKING AT RayTraceResult rtr = Minecraft.getMinecraft().objectMouseOver; if(rtr!=null){ RayTraceResult.Type rtrHit = rtr.typeOfHit; //IS PLAYER LOOKING AT A BLOCK? if(rtrHit == RayTraceResult.Type.BLOCK) { posBlockWatering = rtr.getBlockPos(); playerWatering = (EntityPlayer) entity; doWatering = true; }//END LOOKING AT BLOCK //NO LOOKING AT BLOCK else{ posBlockWatering = null; playerWatering = null; doWatering = false; }//END NO LOOKING AT BLOCK } }//END IS LOCKED //NO LOCKED else{ doWatering = false; }//END NO LOCKED }//END CLIENT SIDE if(doWatering){ doWater(stack, world, playerWatering, posBlockWatering); } } //UPDATE TICK NOT 4 OR HIGHER - INCREASE IT else{ updateTick++; } } //NO SELECTED else{ this.updateNBTData(stack, TAG_WATERING_DONGLE_LOCKED, false); doWatering = false; } }//END ON UPDATE Complete code here: http://pastebin.com/6gXh7inP Thanks for the help.
-
[1.9.4+] Render Item/Block on top of my item
Wow, so some items on Vanilla Render different from others in inventory, didn't know that, gonna take a look at the snowball as you suggested and see if I get an idea on how to implement that for my mod. Thanks a lot.
-
[1.9.4+] Render Item/Block on top of my item
I wonder how would I go about doing this. I have an item that can hold stacks of items. How do I render one of the items its holding on top the item itself?
-
Not sure if this is really a bug - No such version exists!
Thanks, not sure how to tell the mod to run on older versions even if it was compiled in 1.10.2 so gonna check that.
-
Not sure if this is really a bug - No such version exists!
Well, 1.10.2 wont run on 1.9.4 but if I make a 1.9.4 it will run on 1.10 and 1.10.2 also.
-
Not sure if this is really a bug - No such version exists!
When trying to SetUp a Decomp environment I get this error. C:\eclipse\Minecraft\KaratGarden\1.9.4-KaratGarden>gradlew setupDecompWorkspace FAILURE: Build failed with an exception. * Where: Build file 'C:\eclipse\Minecraft\KaratGarden\1.9.4-KaratGarden\build.gradle' line: 28 * What went wrong: A problem occurred evaluating root project '1.9.4-KaratGarden'. > No such version exists! * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more l og output. BUILD FAILED Total time: 12.422 secs C:\eclipse\Minecraft\KaratGarden\1.9.4-KaratGarden>gradlew setupDecompWorkspace --stacktrace FAILURE: Build failed with an exception. * Where: Build file 'C:\eclipse\Minecraft\KaratGarden\1.9.4-KaratGarden\build.gradle' line: 28 * What went wrong: A problem occurred evaluating root project '1.9.4-KaratGarden'. > No such version exists! * Try: Run with --info or --debug option to get more log output. * Exception is: org.gradle.api.GradleScriptException: A problem occurred evaluating root project '1.9.4-KaratGarden' . at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(Defaul tScriptRunnerFactory.java:93) at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$1.run(DefaultScriptP luginFactory.java:148) at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:72 ) at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptP luginFactory.java:153) at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:3 at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:2 5) at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActio nsProjectEvaluator.java:34) at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvalu ator.java:55) at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:491) at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:89) at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator .java:42) at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35) at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:126) at org.gradle.internal.Factories$1.create(Factories.java:22) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecu tor.java:90) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecu tor.java:52) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java: 123) at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:33) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:100) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:94) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecu tor.java:90) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecu tor.java:62) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:94) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83) at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProces sBuildActionExecuter.java:94) at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunne r.java:28) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecute r.java:43) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecute r.java:28) at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecu ter.java:77) at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecu ter.java:47) at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSugg estingBuildActionExecuter.java:51) at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSugg estingBuildActionExecuter.java:28) at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43) at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineA ctionFactory.java:237) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineA ctionFactory.java:210) at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.j ava:35) at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.j ava:24) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFac tory.java:206) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFac tory.java:169) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33 ) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22 ) at org.gradle.launcher.Main.doAction(Main.java:33) at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54) at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35) at org.gradle.launcher.GradleMain.main(GradleMain.java:23) at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) Caused by: net.minecraftforge.gradle.util.GradleConfigurationException: No such version exists! at net.minecraftforge.gradle.user.patcherUser.forge.ForgeExtension.checkAndSetVersion(ForgeE xtension.java:204) at net.minecraftforge.gradle.user.patcherUser.forge.ForgeExtension.setVersion(ForgeExtension .java:83) at net.minecraftforge.gradle.user.patcherUser.forge.ForgeExtension_Decorated.setVersion(Unkn own Source) at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.setProperty(BeanDynamicObject. java:194) at org.gradle.api.internal.BeanDynamicObject.setProperty(BeanDynamicObject.java:111) at org.gradle.api.internal.CompositeDynamicObject.setProperty(CompositeDynamicObject.java:10 4) at net.minecraftforge.gradle.user.patcherUser.forge.ForgeExtension_Decorated.setProperty(Unk nown Source) at build_8crdkr8ak5ejwr6uw3h8p0oyk$_run_closure1.doCall(C:\eclipse\Minecraft\KaratGarden\1.9 .4-KaratGarden\build.gradle:28) at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67) at org.gradle.api.internal.plugins.ExtensionsStorage$ExtensionHolder.configure(ExtensionsSto rage.java:145) at org.gradle.api.internal.plugins.ExtensionsStorage.configureExtension(ExtensionsStorage.ja va:69) at org.gradle.api.internal.plugins.DefaultConvention$ExtensionsDynamicObject.invokeMethod(De faultConvention.java:207) at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:1 50) at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79) at build_8crdkr8ak5ejwr6uw3h8p0oyk.run(C:\eclipse\Minecraft\KaratGarden\1.9.4-KaratGarden\bu ild.gradle:27) at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(Defaul tScriptRunnerFactory.java:91) ... 50 more BUILD FAILED Total time: 4.037 secs C:\eclipse\Minecraft\KaratGarden\1.9.4-KaratGarden> Line 28 is: minecraft { version = "1.9.4-12.17.0.1990" It doesn't happen using: minecraft { version = "1.9.4-12.17.0.1987"
-
Change Item Json with game running?
Yes. Run the Game n Debug Mode (Not sure if this is really needed) and then press F3+T after you make the changes on the .json file (Save it) That will reload the texture.
-
[1.9.4] Making a weapon apply a potion effect randomly?
If I understand correctly, you already made it to apply slowness when an enemy is hit. I think you can do the same way, but choosing a random from 0 to 3, and if it is 0 then apply the effect.
-
[1.9.x - 1.10.x] Is there anything like GameRegistry.removeItem?
I was wondering if is there nay way to remove items/blocks from the game.
-
[1.10.2] | setSoundType() access
But if you do something like: public MyBlock(Material materialIn, String name) { super(materialIn, name); this.setSoundType(SoundType.CLOTH); } It works. Even been protected.
-
Is it ok to run this constantly onUpdate in an item?
Thanks Ernio, yes always good to know, I know it can be improved, that's a constant, specially when I'm just dealing with this. Sound totally logic, gonna implement that for sure.
-
Is it ok to run this constantly onUpdate in an item?
I use that here @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { String description = this.getNBTTagString(stack, TAG_PICKAPPA_MODE_DESC); list.add(description); }
-
Is it ok to run this constantly onUpdate in an item?
Guys I believe it's first time I use NBTs I'm not sure all I understood about NBTs I implemented correctly, if anyone want to take a look and comment I would be really appreciate. As always thanks for your time, and thanks for helping me learn something new every day. package com.mramericanmike.mikedongles.items; import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import com.mramericanmike.mikedongles.ModInfo; import com.mramericanmike.mikedongles.creativetab.ModCreativeTab; public class PickappaDongle extends ItemPickaxe { private static String deleteMode = "-"; private static boolean getBool = false; private static final String TAG_PICKAPPA = "pickappa"; private static final String TAG_PICKAPPA_MODE_DESC = "pickappa.mode.desc"; private static final String TAG_PICKAPPA_MODE = "pickappa.mode"; private static final String TAG_PICKAPPA_COBBLESTONE = "pickappa.cobblestone"; private static int base=0; private static int max=9; public PickappaDongle(ToolMaterial material, String name) { super(material); this.setRegistryName(name); this.setUnlocalizedName(ModInfo.MODID.toLowerCase() + ":" + name); this.setMaxDamage(material.getMaxUses()); this.setMaxStackSize(1); this.setCreativeTab(ModCreativeTab.MOD_TAB); } @Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(!world.isRemote && player.isSneaking()){ boolean bool = getNBTTagBoolean(stack, TAG_PICKAPPA_COBBLESTONE); deleteMode = getNBTTagString(stack, TAG_PICKAPPA_MODE); if(bool == false){ if(deleteMode == "-"){ this.updateNBTData(stack, TAG_PICKAPPA_COBBLESTONE, true); player.addChatComponentMessage(new TextComponentString("Delete Cobblestone Mode HotBar Enabled")); this.updateNBTData(stack, TAG_PICKAPPA_MODE_DESC, "Delete Cobblestone From HotBar"); this.updateNBTData(stack, TAG_PICKAPPA_MODE, "A"); this.updateNBTData(stack, TAG_PICKAPPA_COBBLESTONE, true); this.base=0; this.max=9; return EnumActionResult.SUCCESS; } else if(deleteMode == "A"){ this.updateNBTData(stack, TAG_PICKAPPA_COBBLESTONE, true); player.addChatComponentMessage(new TextComponentString("Delete Cobblestone Mode Inventory Enabled")); this.updateNBTData(stack, TAG_PICKAPPA_MODE_DESC, "Delete Cobblestone From Inventory"); this.updateNBTData(stack, TAG_PICKAPPA_MODE, "B"); this.updateNBTData(stack, TAG_PICKAPPA_COBBLESTONE, true); this.base=9; this.max=36; return EnumActionResult.SUCCESS; } else if(deleteMode == "B"){ this.updateNBTData(stack, TAG_PICKAPPA_COBBLESTONE, true); player.addChatComponentMessage(new TextComponentString("Delete Cobblestone Mode Whole Inventory Enabled")); this.updateNBTData(stack, TAG_PICKAPPA_MODE_DESC, "Delete Cobblestone From Whole Inventory"); this.updateNBTData(stack, TAG_PICKAPPA_MODE, "C"); this.updateNBTData(stack, TAG_PICKAPPA_COBBLESTONE, true); this.base=0; this.max=36; return EnumActionResult.SUCCESS; } } else if(bool == true){ player.addChatComponentMessage(new TextComponentString("Delete Cobblestone Disabled")); this.updateNBTData(stack, TAG_PICKAPPA_MODE_DESC, "Delete Cobblestone Disabled"); this.updateNBTData(stack, TAG_PICKAPPA_COBBLESTONE, false); if(deleteMode == "C"){ this.updateNBTData(stack, TAG_PICKAPPA_MODE, "-"); } return EnumActionResult.SUCCESS; } } return EnumActionResult.PASS; } @Override public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { if(getNBTTagBoolean(stack, TAG_PICKAPPA_COBBLESTONE) && isSelected){ if(entity instanceof EntityPlayer){ EntityPlayer thePlayer = (EntityPlayer) entity; Item cobblestone = Item.getItemFromBlock(Blocks.COBBLESTONE); for(int slot = base; slot<max; slot++){ ItemStack theStack = thePlayer.inventory.getStackInSlot(slot); if(theStack!=null){ Item theItem = theStack.getItem(); if(theItem.equals(cobblestone)){ thePlayer.inventory.removeStackFromSlot(slot); } } } } } } @Override @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack) { return getNBTTagBoolean(stack, TAG_PICKAPPA_COBBLESTONE); } @Override public void onCreated(ItemStack itemStack, World world, EntityPlayer player){ createNBTData(itemStack); } private static void createNBTData(ItemStack itemStack){ NBTTagCompound data = new NBTTagCompound(); data.setBoolean(TAG_PICKAPPA_COBBLESTONE, false); data.setString(TAG_PICKAPPA_MODE_DESC, "Delete Cobblestone Disabled"); data.setString(TAG_PICKAPPA_MODE, "-"); itemStack.setTagInfo(TAG_PICKAPPA, data); } private static void updateNBTData(ItemStack itemStack, String tag, String value){ if(itemStack.getTagCompound()!=null){ NBTTagCompound data = itemStack.getTagCompound().getCompoundTag(TAG_PICKAPPA); data.setString(tag, value); itemStack.setTagInfo(TAG_PICKAPPA, data); } } private static void updateNBTData(ItemStack itemStack, String tag, boolean bool){ if(itemStack.getTagCompound()!=null){ NBTTagCompound data = itemStack.getTagCompound().getCompoundTag(TAG_PICKAPPA); data.setBoolean(tag, bool); itemStack.setTagInfo(TAG_PICKAPPA, data); } } private static boolean getNBTTagBoolean(ItemStack itemStack, String tag){ if(itemStack.getTagCompound()!=null){ NBTTagCompound data = itemStack.getTagCompound().getCompoundTag(TAG_PICKAPPA); return data.getBoolean(tag); } else{ return false; } } private static String getNBTTagString(ItemStack itemStack, String tag){ if(itemStack.getTagCompound()!=null){ NBTTagCompound data = itemStack.getTagCompound().getCompoundTag(TAG_PICKAPPA); return data.getString(tag); } else{ return "-"; } } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { String description = this.getNBTTagString(stack, TAG_PICKAPPA_MODE_DESC); list.add(description); } }
-
Is it ok to run this constantly onUpdate in an item?
About point 3, thanks, I'm aware already that this is not a good practice as 2 items in my inventory would start doing the same. I know I have to move that to NBT's but I'm still "raw" on working with those. Hopefully I can learn that soon to fix this. Point 2: Thanks for the headsup.
-
Is it ok to run this constantly onUpdate in an item?
Basically it's a tool, that while active, will scan the player inventory looking for cobblestone, and if it finds cobblestone, it deletes it. @Override public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { if(this.deleteCobble && isSelected){ if(entity instanceof EntityPlayer){ EntityPlayer thePlayer = (EntityPlayer) entity; Item cobblestone = new ItemStack(Blocks.COBBLESTONE,1,0).getItem(); for(int x=0; x<36; x++){ ItemStack theStack = thePlayer.inventory.getStackInSlot(x); if(theStack!=null){ Item theItem = theStack.getItem(); if(theItem.equals(cobblestone)){ thePlayer.inventory.removeStackFromSlot(x); } } } } } } Could this be a problem?
-
Play sound on Key Press (Key Handler and Binding Class)
What was the crash? Also onKeyInput only takes 1 parameter "InputEvent.KeyInputEvent event" Get all the parameters you need from that event and then try something like: world.playSound(player, pos, ModSounds.THE_SOUND, SoundCategory.MASTER, 1.0F, 1.0F);
-
[Solved!][1.10.2] Make a block instantly kill you
Does it has to be a full block the one that kills you? Can't it just be a platform smaller, like the pressure plates? If you need a full block, I would think on creating an invisible block above the one and make that one the block that kills you, but not sure if that could be easily implemented. Also... Have you take a look at the code on the Ice Blocks? Those are full blocks and affect players above them right? Maybe there is something there that can be used.
IPS spam blocked by CleanTalk.