mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 19:59:36 +00:00
Minor optimization in MathHelper, cleanup for rel
This commit is contained in:
3 files changed
+4
-15
No files matched your search
@@ -21,7 +21,7 @@ public final class MathHelper {
|
||||
}
|
||||
|
||||
public static float pointDistanceSpace(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
return (float) Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2) + Math.pow(z1 - z2, 2));
|
||||
return (float) Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2));
|
||||
}
|
||||
|
||||
// Backwards compatibility
|
||||
|
||||
@@ -33,6 +33,7 @@ import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.core.helper.MathHelper;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.entity.EntityThrownItem;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
@@ -168,7 +169,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
|
||||
Botania.proxy.wispFX(world, item.posX + item.width / 2, item.posY + item.height / 2, item.posZ + item.width / 2, r, 0F, b, s, xm, ym, zm);
|
||||
}
|
||||
|
||||
setEntityMotionFromVector(item, target3, 0.3333333F);
|
||||
MathHelper.setEntityMotionFromVector(item, target3, 0.3333333F);
|
||||
|
||||
ItemNBTHelper.setInt(stack, TAG_TARGET, item.getEntityId());
|
||||
ItemNBTHelper.setDouble(stack, TAG_DIST, length);
|
||||
@@ -181,18 +182,6 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
|
||||
return ActionResult.newResult(EnumActionResult.PASS, stack);
|
||||
}
|
||||
|
||||
public static void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) {
|
||||
Vector3 entityVector = Vector3.fromEntityCenter(entity);
|
||||
Vector3 finalVector = originalPosVector.copy().subtract(entityVector);
|
||||
|
||||
if(finalVector.mag() > 1)
|
||||
finalVector.normalize();
|
||||
|
||||
entity.motionX = finalVector.x * modifier;
|
||||
entity.motionY = finalVector.y * modifier;
|
||||
entity.motionZ = finalVector.z * modifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMana(ItemStack stack) {
|
||||
return true;
|
||||
|
||||
@@ -64,7 +64,7 @@ public final class LibObfuscation {
|
||||
public static final String[] MAX_NEARBY_ENTITIES = new String[] { "maxNearbyEntities", "field_98292_k", "j" };
|
||||
public static final String[] MAX_SPAWN_DELAY = new String[] { "maxSpawnDelay", "field_98293_h", "g" };
|
||||
public static final String[] MIN_SPAWN_DELAY = new String[] { "minSpawnDelay", "field_98283_g", "f" };
|
||||
public static final String[] POTENTIAL_ENTITY_SPAWNS = new String[] { "minecartToSpawn", "field_98285_e", "b" }; // Todo 1.8 new name makes no sense -> "minecartToSpawn" see MCP name github issue
|
||||
public static final String[] POTENTIAL_ENTITY_SPAWNS = new String[] { "minecartToSpawn", "field_98285_e", "b" };
|
||||
public static final String[] SPAWN_DELAY = new String[] { "spawnDelay", "field_98286_b", "a" };
|
||||
public static final String[] PREV_MOB_ROTATION = new String[] { "prevMobRotation", "field_98284_d", "e" };
|
||||
public static final String[] MOB_ROTATION = new String[] { "mobRotation", "field_98287_c", "d" };
|
||||
|
||||
Reference in new issue
Block a user