Stop 'Replace Item in Hand' "animation"

Started by gustavowizard123 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Stop 'Replace Item in Hand' "animation"

so i notice when you use the procedure 'replace item in main hand', there is a animation and a sound (the item kinda go down and back up), i open the procedure code here, is there a way to turn OFF that animation?

Entity entity = (Entity) dependencies.get("entity");
		double x = dependencies.get("x") instanceof Integer ? (int) dependencies.get("x") : (double) dependencies.get("x");
		double y = dependencies.get("y") instanceof Integer ? (int) dependencies.get("y") : (double) dependencies.get("y");
		double z = dependencies.get("z") instanceof Integer ? (int) dependencies.get("z") : (double) dependencies.get("z");
		IWorld world = (IWorld) dependencies.get("world");
		if (((world.getEntitiesWithinAABB(CreeperEntity.class,
				new AxisAlignedBB(x - 20 / 2, y - 20 / 2, z - 20 / 2, x + 20 / 2, y + 20 / 2, z + 20 / 2), null).stream()
				.sorted(Comparator.comparing(_ent -> _ent.getDistanceSq(x, y, z))).findFirst().orElse(null)) != null)) {
			if (entity instanceof LivingEntity) {
				ItemStack _setstack = new ItemStack(LifeDetectorONItem.block, (int) (1));
				_setstack.setCount((int) 1);
				((LivingEntity) entity).setHeldItem(Hand.MAIN_HAND, _setstack);
				if (entity instanceof ServerPlayerEntity)
					((ServerPlayerEntity) entity).inventory.markDirty();
			}
			if (((entity.getPersistentData().getDouble("lifedetectortick")) < 21)) {
				entity.getPersistentData().putDouble("lifedetectortick", ((entity.getPersistentData().getDouble("lifedetectortick")) + 1));
			} else {
				entity.getPersistentData().putDouble("lifedetectortick", 0);
			}
			if (((entity.getPersistentData().getDouble("lifedetectortick")) == 10)) {
				world.playSound(world.getWorld().isRemote ? Minecraft.getInstance().player : (PlayerEntity) null, new BlockPos(x, y, z),
						(net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("wizardtech:beep_detect")),
						SoundCategory.NEUTRAL, (float) 1, (float) 1);
			}
		} else {
			entity.getPersistentData().putDouble("lifedetectortick", 0);
		}

thanks in advance

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I don't entirely know…
Fri, 07/31/2020 - 12:57

I don't entirely know everything there is to know about coding, but if I had to guess, I suggest maybe cutting this bit out and see if it works. Back up your project first so that if it doesn't work, you can have it return to normal

​​​​​​new AxisAlignedBB(x - 20 / 2, y - 20 / 2, z - 20 / 2, x + 20 / 2, y + 20 / 2, z + 20 / 2), null).stream()

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
hum yeah i tried but give…
Fri, 07/31/2020 - 19:39

hum yeah i tried but give errors, i also tried to remove the hole section too

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
hmmmmmmm. I'll take a bit of…
Sun, 08/02/2020 - 19:07

hmmmmmmm. I'll take a bit of a closer look at this, cuz I too am trying to stop the animation. But for some reason I keep losing where an items code section is . lol

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
lol aight let me know here…
Mon, 08/03/2020 - 00:57

lol

aight let me know here if you know something, i was noticing its indeed related with the procedure 'Replace item in Hand'

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
this can affect guns,…
Mon, 08/03/2020 - 00:58

this can affect guns, lightsabers, and even this life detector i did (witch switch itens when detect the mob), they all use the 'Replace in Main Hand' procedure

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yep. It might take a bit as…
Mon, 08/03/2020 - 12:03

Yep. It might take a bit as I have some school I need to do, but I will get back to ya when I do. 

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ok i think I got it. So look…
Mon, 08/03/2020 - 15:51

Ok i think I got it. So look at this bit of code

if (((entity.getPersistentData().getDouble("lifedetectortick")) < 21)) { entity.getPersistentData().putDouble("lifedetectortick",

((entity.getPersistentData().getDouble("lifedetectortick")) + 1)); } else { entity.getPersistentData().putDouble("lifedetectortick", 0); }

if (((entity.getPersistentData().getDouble("lifedetectortick")) == 10)) { world.playSound(world.getWorld().isRemote ?

Minecraft.getInstance().player : (PlayerEntity) null, new BlockPos(x, y, z),​​​​​​

look at the new BlockPos part. If you cut this part out, it should work. i could run a test for you. I just need to know what procedure it was under and what player hand its for.

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i wonder if this could be…
Mon, 08/03/2020 - 15:52

i wonder if this could be related to the item usage animation with long-ranged weapons like u said. If so, then it will make getting my minigun finished cuz i don't like the animation while its in my hand. 

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
lol i just notice the code…
Tue, 08/04/2020 - 01:27

lol i just notice the code changed after i got the new 2020.4 that part over there you are pointing just dont exist anymore, check it out:

Entity entity = (Entity) dependencies.get("entity");
		double x = dependencies.get("x") instanceof Integer ? (int) dependencies.get("x") : (double) dependencies.get("x");
		double y = dependencies.get("y") instanceof Integer ? (int) dependencies.get("y") : (double) dependencies.get("y");
		double z = dependencies.get("z") instanceof Integer ? (int) dependencies.get("z") : (double) dependencies.get("z");
		IWorld world = (IWorld) dependencies.get("world");
		if (((world.getEntitiesWithinAABB(MonsterEntity.class,
				new AxisAlignedBB(x - 20 / 2, y - 20 / 2, z - 20 / 2, x + 20 / 2, y + 20 / 2, z + 20 / 2), null).stream()
				.sorted(Comparator.comparing(_entcnd -> _entcnd.getDistanceSq(x, y, z))).findFirst().orElse(null)) != null)) {
			if (entity instanceof LivingEntity) {
				ItemStack _setstack = new ItemStack(LifeDetectorONItem.block, (int) (1));
				_setstack.setCount((int) 1);
				((LivingEntity) entity).setHeldItem(Hand.MAIN_HAND, _setstack);
				if (entity instanceof ServerPlayerEntity)
					((ServerPlayerEntity) entity).inventory.markDirty();
			}
			if (((entity.getPersistentData().getDouble("lifedetectortick")) < 21)) {
				entity.getPersistentData().putDouble("lifedetectortick", ((entity.getPersistentData().getDouble("lifedetectortick")) + 1));
			} else {
				entity.getPersistentData().putDouble("lifedetectortick", 0);
			}
			if (((entity.getPersistentData().getDouble("lifedetectortick")) == 10)) {
				if (!world.getWorld().isRemote) {
					world.playSound(null, new BlockPos((int) x, (int) y, (int) z),
							(net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("wizardtech:beep_detect")),
							SoundCategory.NEUTRAL, (float) 1, (float) 1);
				} else {
					world.getWorld().playSound(x, y, z,
							(net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("wizardtech:beep_detect")),
							SoundCategory.NEUTRAL, (float) 1, (float) 1, false);
				}
			}
		} else {
			entity.getPersistentData().putDouble("lifedetectortick", 0);
		}

 

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
oh btw that part here: new…
Tue, 08/04/2020 - 01:36

oh btw that part here:

new AxisAlignedBB(x - 20 / 2, y - 20 / 2, z - 20 / 2, x + 20 / 2, y + 20 / 2, z + 20 / 2), null).stream()

that is the range of my life detector lol, it detect mobs 20 squares away (monsters), i was trying to mess around here :D

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ah lol. Darn. Sorry it didn…
Tue, 08/04/2020 - 12:51

Ah lol. Darn. Sorry it didn't help. Does it still not work??

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yeah i still dont know how…
Tue, 08/04/2020 - 21:59

yeah i still dont know how to 'fix' that lol but thanks anyway :D, it happens when the item in main hand is replaced or when ranged weapons shot.

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm trying to make a minigun…
Wed, 08/05/2020 - 01:52

I'm trying to make a minigun and I can't get a good view to see how it looks cuz of that. -_-. if you figure it out, plz let me know. :P

 

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you mean the translating…
Wed, 08/05/2020 - 04:59

you mean the translating when you are on first person view? are you using blockbench for your minigun model?