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

Entity moving after setting motion to zero


Recommended Posts

I am trying to keep all entities within a certain bounds from moving.  Currently, this is working for mobs only, and all other entities (Item drops, falling sand/gravel, prime TNT, etc) keep falling at a slower rate than normal.

 

public void updateEntity()
{
	World world = this.worldObj;
	int x = this.xCoord;
	int y = this.yCoord;
	int z = this.zCoord;

	updateWalls(world, x, y, z);

	if(world.isBlockIndirectlyGettingPowered(x, y, z))
	{
		List<Entity> entitiesToFreeze = world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(this.xCoord,  0, this.zCoord, xcoord, 128, zcoord));
		if(entitiesToFreeze.size() > 0)
		{
			for(int i = 0; i < entitiesToFreeze.size(); i++)
			{
				Entity e = entitiesToFreeze.get(i);
				System.out.println(e);
				if(e instanceof EntityPlayer)
				{

				}
				else
				{
					e.motionX = 0.0D;
					e.motionY = 0.0D;
					e.motionZ = 0.0D;
					e.setPosition(e.posX, e.posY, e.posZ);
				}
			}
		}
	}
}

 

Any ideas why this might be happening or how to fix it?

Link to post
Share on other sites

A quick glance at EntityItem's class reveals the following line (118), in the onUpdate method:

 

this.motionY -= 0.03999999910593033D;

 

I believe this is to simulate gravity. This is the reason why items fall "slower" in your bounds - their acceleration is being effectively zeroed by your code setting their Y motion to zero. They are not stopped because EntityItem has it's own ideas and sometime after you set the entity's velocity to zero, the onUpdate method is called and suddenly they're moving again.

 

Fortunately, EntityItem does check the noClip bounding box before actually moving the items, perhaps you could take advantage of this?

Link to post
Share on other sites

I just checked some code i used to ass velocity to an entity and i used

entity.addVelocity(d2 / d4 * 8.0D, 5.20000000298023224D, d3 / d4 * 8.0D);
entity.velocityChanged = true;

so maby try

entity.setVelocity(0D, 0D, 0D);
entity.velocityChanged = true;

 

Edit: i just threw that into my LivingUpdateEvent handler and it froze every entity in the world so if it dosnt work you you it must be as you said "the block's update loop is being called before the entity"

I am the author of Draconic Evolution

Link to post
Share on other sites

I suppose I wasn't overt enough before. I apologize if this comes off as rude.

 

-You are applying a velocity to things that have an acceleration. This is why you're seeing a "slowing" effect but not a "stopping" effect, you're only removing one dimension of the object's displacement. Acceleration is displacement over time squared, if you remove one dimension of this, you're left with a displacement over time, a velocity.

 

-By adding universal "set velocity of this entity" rule, you may encounter odd behavior in the future if ever your mod is installed alongside another that has different movement rules for their entities. There is a nonzero chance of this happening, because Forge provides ways for modders to accomplish precisely this.

 

Instead, I would suggest picking around in the net.minecraft.entity superclass, which is the point from which all the objects you care about extend. There are a few functions in there that may catch your eye, namely setPosition, setVelocity (as brandon3055 suggested), moveEntity, and even some public fields dealing with this stuff such as isCollided (and the ones you've found, motionX, motionY, motionZ). You might be able to trick the entity into thinking it has collided with something while it is in your AABB, thereby halting it's movement, or just repeatedly reset the position of the entity, etc.

 

Failing all that, you could even try to write your own EntityItem that doesn't move, and have that object temporarily replace all the ones in your AABB.

 

What's the scope of "all entities movement", if I might ask? Does it include blocklike entities such piston heads, blocks moved by pistons, TNT and other moving entities like arrows, snowballs, particles, etc? Movement-like block state changes, like lever flips, button pushes, doors being closed?

 

Unrelated: I noticed you're using a List, and lists are iterable. Have you yet opened your heart to the Church of the For-Each-Loop? I love them.

 

for (Entity iteratedEntity : entitiesToFreeze) { // For each element iteratedEntity in the list entitiesToFreeze,
iteratedEntity.extinguish(); // call the extinguish method on it.
}

Link to post
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.

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.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Trying to figure out the cause of this, unsure what it is i get this error anytime i launch a custom mod pack i created,looked to see if there was invalid depndencies or missing mods, couldnt see anything https://pastebin.com/2ZxW8SVc
    • 1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • If someone know what to do pls help me do i need to reinstall mods or delete some?   ---- Minecraft Crash Report ---- WARNING: coremods are present:   Quark Plugin (Quark-r1.6-178.jar)   SteveKunGLibPlugin (SteveKunG's-Lib-1.12.2-1.1.9.jar)   ForgelinPlugin (Forgelin-1.8.4.jar)   MovingWorldCore (movingworld-1.12-6.353-full.jar)   MekanismCoremod (Mekanism-1.12.2-9.8.3.390.jar)   MicdoodlePlugin (MicdoodleCore-1.12.2-4.0.2.280.jar)   TransformLoader (DynamicSurroundings-1.12.2-3.6.2.1.jar)   FutureMC (future-mc-1.12.2-0.2.6.1.jar) Contact their authors BEFORE contacting forge // You should try our sister game, Minceraft! Time: 4/11/21 11:03 PM Description: There was a severe problem during mod loading that has caused the game to fail net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from �3Dynamic Surroundings (dsurround) Caused by: java.lang.ExceptionInInitializerError   at org.orecruncher.dsurround.registry.RegistryManager.initialize(RegistryManager.java:103)   at org.orecruncher.dsurround.proxy.Proxy.loadCompleted(Proxy.java:92)   at org.orecruncher.dsurround.ModBase.loadCompleted(ModBase.java:178)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   at java.lang.reflect.Method.invoke(Method.java:498)   at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:637)   at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   at java.lang.reflect.Method.invoke(Method.java:498)   at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)   at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)   at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)   at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)   at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)   at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)   at com.google.common.eventbus.EventBus.post(EventBus.java:217)   at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219)   at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   at java.lang.reflect.Method.invoke(Method.java:498)   at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)   at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)   at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)   at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)   at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)   at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)   at com.google.common.eventbus.EventBus.post(EventBus.java:217)   at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136)   at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:757)   at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336)   at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:535)   at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378)   at net.minecraft.client.main.Main.main(SourceFile:123)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   at java.lang.reflect.Method.invoke(Method.java:498)   at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)   at net.minecraft.launchwrapper.Launch.main(Launch.java:28) Caused by: java.lang.IllegalArgumentException: No enum constant net.minecraft.util.SoundCategory.DS_FOOTSTEPS   at java.lang.Enum.valueOf(Enum.java:238)   at net.minecraft.util.SoundCategory.valueOf(SourceFile:8)   at org.orecruncher.dsurround.registry.sound.SoundRegistry.<clinit>(SoundRegistry.java:67)   ... 43 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details:   Minecraft Version: 1.12.2   Operating System: Windows 10 (amd64) version 10.0   Java Version: 1.8.0_271, Oracle Corporation   Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation   Memory: 2114811232 bytes (2016 MB) / 4294967296 bytes (4096 MB) up to 16777216000 bytes (16000 MB)   JVM Flags: 10 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx16000M -Xms4096M -Xss1M -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M   IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0   FML: MCP 9.42 Powered by Forge 14.23.5.2854 39 mods loaded, 39 mods active   States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored   | State  | ID                                           | Version           | Source                                        | Signature                                |   |:------ |:-------------------------------------------- |:----------------- |:--------------------------------------------- |:---------------------------------------- |   | LCHIJA | minecraft                                    | 1.12.2            | minecraft.jar                                 | None                                     |   | LCHIJA | mcp                                          | 9.42              | minecraft.jar                                 | None                                     |   | LCHIJA | FML                                          | 8.0.99.99         | forge-1.12.2-14.23.5.2854.jar                 | e3c3d50c7c986df74c645c0ac54639741c90a557 |   | LCHIJA | forge                                        | 14.23.5.2854      | forge-1.12.2-14.23.5.2854.jar                 | e3c3d50c7c986df74c645c0ac54639741c90a557 |   | LCHIJA | micdoodlecore                                |                   | minecraft.jar                                 | None                                     |   | LCHIJA | com.elytradev.movingworld.common.asm.coremod |                   | minecraft.jar                                 | None                                     |   | LCHIJA | aether_legacy                                | 1.5.3             | aether-1.12.2-v1.5.3.jar                      | None                                     |   | LCHIJA | jei                                          | 4.16.1.301        | jei_1.12.2-4.16.1.301.jar                     | None                                     |   | LCHIJA | quark                                        | r1.6-178          | Quark-r1.6-178.jar                            | None                                     |   | LCHIJA | autoreglib                                   | 1.3-32            | AutoRegLib-1.3-32.jar                         | None                                     |   | LCHIJA | backpack                                     | 3.0.2             | backpack-3.0.2-1.12.2.jar                     | None                                     |   | LCHIJA | bettercaves                                  | 1.12.2            | bettercaves-1.12.2-2.0.4.jar                  | None                                     |   | LCHIJA | bettermineshafts                             | 1.12.2-2.2.1      | BetterMineshaftsForge-1.12.2-2.2.1.jar        | None                                     |   | LCHIJA | bibliocraft                                  | 2.4.5             | BiblioCraft[v2.4.5][MC1.12.2].jar             | None                                     |   | LCHIJA | biomesoplenty                                | 7.0.1.2443        | BiomesOPlenty-1.12.2-7.0.1.2443-universal.jar | None                                     |   | LCHIJA | chameleon                                    | 1.12-4.1.3        | Chameleon-1.12-4.1.3.jar                      | None                                     |   | LCHIJA | chesttransporter                             | 2.8.8             | ChestTransporter-1.12.2-2.8.8.jar             | None                                     |   | LCHIJA | mantle                                       | 1.12-1.3.3.55     | Mantle-1.12-1.3.3.55.jar                      | None                                     |   | LCHIJA | twilightforest                               | 3.11.1021         | twilightforest-1.12.2-3.11.1021-universal.jar | None                                     |   | LCHIJA | tconstruct                                   | 1.12.2-2.13.0.183 | TConstruct-1.12.2-2.13.0.183.jar              | None                                     |   | LCHIJA | conarm                                       | 1.2.5.10          | conarm-1.12.2-1.2.5.10.jar                    | b33d2c8df492beff56d1bbbc92da49b8ab7345a1 |   | LCHIJA | movingworld                                  | 1.12-6.353        | movingworld-1.12-6.353-full.jar               | None                                     |   | LCHIJA | davincisvessels                              | @DVESSELSVER@     | davincisvessels-1.12-6.340-full.jar           | None                                     |   | LCHIJA | galacticraftcore                             | 4.0.2.280         | GalacticraftCore-1.12.2-4.0.2.280.jar         | None                                     |   | LCHIJA | orelib                                       | 3.6.0.1           | OreLib-1.12.2-3.6.0.1.jar                     | 7a2128d395ad96ceb9d9030fbd41d035b435753a |   | LCHIJE | dsurround                                    | 3.6.2.1           | DynamicSurroundings-1.12.2-3.6.2.1.jar        | 7a2128d395ad96ceb9d9030fbd41d035b435753a |   | LCHIJ  | fastleafdecay                                | v14               | FastLeafDecay-v14.jar                         | None                                     |   | LCHIJ  | forgelin                                     | 1.8.4             | Forgelin-1.8.4.jar                            | None                                     |   | LCHIJ  | futuremc                                     | 0.2.6             | future-mc-1.12.2-0.2.6.1.jar                  | None                                     |   | LCHIJ  | galacticraftplanets                          | 4.0.2.280         | Galacticraft-Planets-1.12.2-4.0.2.280.jar     | None                                     |   | LCHIJ  | gravestone                                   | 1.10.1            | gravestone-1.10.1.jar                         | None                                     |   | LCHIJ  | waila                                        | 1.8.26            | Hwyla-1.8.26-B41_1.12.2.jar                   | None                                     |   | LCHIJ  | ironchest                                    | 1.12.2-7.0.67.844 | ironchest-1.12.2-7.0.72.847.jar               | None                                     |   | LCHIJ  | mekanism                                     | 1.12.2-9.8.3.390  | Mekanism-1.12.2-9.8.3.390.jar                 | None                                     |   | LCHIJ  | stevekung's_lib                              | 1.1.9             | SteveKunG's-Lib-1.12.2-1.1.9.jar              | None                                     |   | LCHIJ  | moreplanets                                  | 2.2.1             | More-Planets-1.12.2-2.2.1-GC280.jar           | None                                     |   | LCHIJ  | stg                                          | 1.12.2-1.2.3      | stg-1.12.2-1.2.3.jar                          | None                                     |   | LCHIJ  | storagedrawers                               | 1.12.2-5.4.0      | StorageDrawers-1.12.2-5.4.0.jar               | None                                     |   | LCHIJ  | waystones                                    | 4.1.0             | Waystones_1.12.2-4.1.0.jar                    | None                                     |   Loaded coremods (and transformers):  Quark Plugin (Quark-r1.6-178.jar)   vazkii.quark.base.asm.ClassTransformer SteveKunGLibPlugin (SteveKunG's-Lib-1.12.2-1.1.9.jar)    ForgelinPlugin (Forgelin-1.8.4.jar)    MovingWorldCore (movingworld-1.12-6.353-full.jar)    MekanismCoremod (Mekanism-1.12.2-9.8.3.390.jar)   mekanism.coremod.KeybindingMigrationHelper MicdoodlePlugin (MicdoodleCore-1.12.2-4.0.2.280.jar)   micdoodle8.mods.miccore.MicdoodleTransformer TransformLoader (DynamicSurroundings-1.12.2-3.6.2.1.jar)    FutureMC (future-mc-1.12.2-0.2.6.1.jar)   thedarkcolour.futuremc.asm.CoreTransformer   GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 465.89' Renderer: 'NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2'   Pulsar/tconstruct loaded Pulses:      - TinkerCommons (Enabled/Forced)     - TinkerWorld (Enabled/Not Forced)     - TinkerTools (Enabled/Not Forced)     - TinkerHarvestTools (Enabled/Forced)     - TinkerMeleeWeapons (Enabled/Forced)     - TinkerRangedWeapons (Enabled/Forced)     - TinkerModifiers (Enabled/Forced)     - TinkerSmeltery (Enabled/Not Forced)     - TinkerGadgets (Enabled/Not Forced)     - TinkerOredict (Enabled/Forced)     - TinkerIntegration (Enabled/Forced)     - TinkerFluids (Enabled/Forced)     - TinkerMaterials (Enabled/Forced)     - TinkerModelRegister (Enabled/Forced)     - wailaIntegration (Enabled/Not Forced)     - quarkIntegration (Enabled/Not Forced) [23:03:47] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:func_179870_a:553]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Piotroxx\AppData\Roaming\Crystal-Launcher\instances\u.PiotroxxPack1\.minecraft\crash-reports\crash-2021-04-11_23.03.47-client.txt  
    • The client log shows you trying to connect to a vanilla server. The server log is from a forge server, but it ends (based on the timestamps) before the client log even shows the connection attempt. The server log shows several successful logins.
    • After removing Botania, it has been stable. So there was definitely something not happy there.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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