-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed the interaction limited - Improvements to tnt explosions (non-vanilla) - Readd the removal of JFR profiler - Add the ability to remove sounds (WIP) - FastMath for Vec3d - More optimizations with FastMath
- Loading branch information
Showing
21 changed files
with
287 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
.../com/github/tatercertified/potatoptimize/mixin/fastmath/general/GenericFastMathMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.github.tatercertified.potatoptimize.mixin.fastmath.general; | ||
|
||
import net.minecraft.util.math.Box; | ||
import net.minecraft.util.math.MathHelper; | ||
import net.minecraft.util.math.Vec3d; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
|
||
import java.util.stream.IntStream; | ||
|
||
@Mixin(MathHelper.class) | ||
public class GenericFastMathMixin { | ||
|
||
/** | ||
* @author QPCrummer | ||
* @reason Slightly more optimized | ||
*/ | ||
@Overwrite | ||
public static boolean method_34945(Vec3d origin, Vec3d direction, Box box) { | ||
|
||
double d = (box.minX + box.maxX) * 0.5; | ||
double e = (box.maxX - box.minX) * 0.5; | ||
double f = origin.x - d; | ||
if (Math.abs(f) > e && f * direction.x > 0.0) { | ||
return false; | ||
} | ||
|
||
double g = (box.minY + box.maxY) * 0.5; | ||
double h = (box.maxY - box.minY) * 0.5; | ||
double i = origin.y - g; | ||
if (Math.abs(i) > h && i * direction.y >= 0.0) { | ||
return false; | ||
} | ||
|
||
double j = (box.minZ + box.maxZ) * 0.5; | ||
double k = (box.maxZ - box.minZ) * 0.5; | ||
double l = origin.z - j; | ||
if (Math.abs(l) > k && l * direction.z >= 0.0) { | ||
return false; | ||
} | ||
|
||
double m = Math.abs(direction.x); | ||
double n = Math.abs(direction.y); | ||
double o = Math.abs(direction.z); | ||
double p = direction.y * l - direction.z * i; | ||
if (Math.abs(p) > h * o + k * n || Math.abs(direction.z * f - direction.x * l) > e * o + k * m) { | ||
return false; | ||
} | ||
|
||
return Math.abs(direction.x * i - direction.y * f) < e * n + h * m; | ||
} | ||
|
||
/** | ||
* @author QPCrummer | ||
* @reason Slightly more optimized | ||
*/ | ||
@Overwrite | ||
public static IntStream stream(int seed, int lowerBound, int upperBound, int steps) { | ||
|
||
if (steps < 1 || seed < lowerBound || seed > upperBound) { | ||
return IntStream.empty(); | ||
} | ||
|
||
return IntStream.iterate(seed, i -> { | ||
int nextValue = i + (i <= seed ? steps : -steps); | ||
return nextValue >= lowerBound && nextValue <= upperBound ? nextValue : i; | ||
}); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...n/java/com/github/tatercertified/potatoptimize/mixin/fastmath/vec/FastMathVec3DMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.github.tatercertified.potatoptimize.mixin.fastmath.vec; | ||
|
||
import net.minecraft.util.math.Vec3d; | ||
import org.spongepowered.asm.mixin.*; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(Vec3d.class) | ||
public class FastMathVec3DMixin { | ||
@Mutable | ||
@Shadow | ||
@Final | ||
public double x; | ||
|
||
@Mutable | ||
@Shadow @Final public double y; | ||
|
||
@Mutable | ||
@Shadow @Final public double z; | ||
private Vec3d cachedNormalized; | ||
|
||
/** | ||
* @author QPCrummer | ||
* @reason Cache normalized Vec | ||
*/ | ||
@Overwrite | ||
public Vec3d normalize() { | ||
if (cachedNormalized == null) { | ||
double squaredLength = x * x + y * y + z * z; | ||
if (squaredLength < 1.0E-8) { | ||
cachedNormalized = Vec3d.ZERO; | ||
} else { | ||
double invLength = 1.0 / Math.sqrt(squaredLength); | ||
cachedNormalized = new Vec3d(x * invLength, y * invLength, z * invLength); | ||
} | ||
} | ||
return cachedNormalized; | ||
} | ||
|
||
// TODO Figure out why I did this... | ||
@Inject(method = "relativize", at = @At("HEAD")) | ||
private void optimizedRelativize(Vec3d vec, CallbackInfoReturnable<Vec3d> cir) { | ||
this.x -= vec.x; | ||
this.y -= vec.y; | ||
this.z -= vec.z; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
...ified/potatoptimize/mixin/feature/interaction_limiter/LimiterServerPlayerEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
.../tatercertified/potatoptimize/mixin/memory/reduce_alloc/EntityExplosionBehaviorMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.github.tatercertified.potatoptimize.mixin.memory.reduce_alloc; | ||
|
||
import com.moulberry.mixinconstraints.annotations.IfModAbsent; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.fluid.FluidState; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.BlockView; | ||
import net.minecraft.world.explosion.EntityExplosionBehavior; | ||
import net.minecraft.world.explosion.Explosion; | ||
import net.minecraft.world.explosion.ExplosionBehavior; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Credit: Leaves Patch #0091 | ||
*/ | ||
@IfModAbsent(value = "lithium") | ||
@Mixin(EntityExplosionBehavior.class) | ||
public class EntityExplosionBehaviorMixin extends ExplosionBehavior { | ||
@Shadow @Final private Entity entity; | ||
|
||
/** | ||
* @author QPCrummer | ||
* @reason Reduce Allocations | ||
*/ | ||
@Overwrite | ||
public Optional<Float> getBlastResistance(Explosion explosion, BlockView world, BlockPos pos, BlockState blockState, FluidState fluidState) { | ||
Optional<Float> optionalBlastResistance = super.getBlastResistance(explosion, world, pos, blockState, fluidState); | ||
if (optionalBlastResistance.isPresent()) { | ||
float blastResistance = optionalBlastResistance.get(); | ||
float effectiveExplosionResistance = this.entity.getEffectiveExplosionResistance(explosion, world, pos, blockState, fluidState, blastResistance); | ||
if (effectiveExplosionResistance != blastResistance) { | ||
return Optional.of(effectiveExplosionResistance); | ||
} | ||
} | ||
return optionalBlastResistance; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...n/java/com/github/tatercertified/potatoptimize/mixin/remove/profiler/JFRCommandMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.github.tatercertified.potatoptimize.mixin.remove.profiler; | ||
|
||
import net.minecraft.server.command.JfrCommand; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
|
||
@Mixin(JfrCommand.class) | ||
public class JFRCommandMixin { | ||
/** | ||
* @author QPCrummer | ||
* @reason Removal | ||
*/ | ||
@Overwrite | ||
private static int executeStart(ServerCommandSource source) { | ||
source.sendFeedback(() -> Text.literal("JFR has been removed by Potatoptimize; Use Spark instead!"), false); | ||
return 0; | ||
} | ||
|
||
/** | ||
* @author QPCrummer | ||
* @reason Removal | ||
*/ | ||
@Overwrite | ||
private static int executeStop(ServerCommandSource source) { | ||
source.sendFeedback(() -> Text.literal("JFR has been removed by Potatoptimize; Use Spark instead!"), false); | ||
return 0; | ||
} | ||
} |
Oops, something went wrong.