This commit is contained in:
eaglercraft 2024-03-10 13:49:48 -07:00
commit aae277ed5d
20 changed files with 495 additions and 57 deletions

View file

@ -17,6 +17,7 @@ import net.lax1dude.eaglercraft.v1_8.EaglercraftSoundManager;
import com.google.common.collect.Lists;
import net.lax1dude.eaglercraft.v1_8.IOUtils;
import net.lax1dude.eaglercraft.v1_8.ThreadLocalRandom;
import net.lax1dude.eaglercraft.v1_8.json.JSONTypeProvider;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
@ -266,7 +267,7 @@ public class SoundHandler implements IResourceManagerReloadListener, ITickable {
if (arraylist.isEmpty()) {
return null;
} else {
return (SoundEventAccessorComposite) arraylist.get((new EaglercraftRandom()).nextInt(arraylist.size()));
return (SoundEventAccessorComposite) arraylist.get(ThreadLocalRandom.current().nextInt(arraylist.size()));
}
}

View file

@ -9,6 +9,7 @@ import java.util.HashSet;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.HString;
import net.lax1dude.eaglercraft.v1_8.ThreadLocalRandom;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@ -115,7 +116,7 @@ public class CommandSpreadPlayers extends CommandBase {
private void func_110669_a(ICommandSender worldIn, List<Entity> parList, CommandSpreadPlayers.Position parPosition,
double parDouble1, double parDouble2, World parWorld, boolean parFlag) throws CommandException {
EaglercraftRandom random = new EaglercraftRandom();
EaglercraftRandom random = ThreadLocalRandom.current();
double d0 = parPosition.field_111101_a - parDouble2;
double d1 = parPosition.field_111100_b - parDouble2;
double d2 = parPosition.field_111101_a + parDouble2;

View file

@ -2,6 +2,7 @@ package net.minecraft.command;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.ThreadLocalRandom;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.BlockPos;
import net.minecraft.world.WorldServer;
@ -55,7 +56,7 @@ public class CommandWeather extends CommandBase {
*/
public void processCommand(ICommandSender parICommandSender, String[] parArrayOfString) throws CommandException {
if (parArrayOfString.length >= 1 && parArrayOfString.length <= 2) {
int i = (300 + (new EaglercraftRandom()).nextInt(600)) * 20 * 2;
int i = (300 + ThreadLocalRandom.current().nextInt(600)) * 20 * 2;
if (parArrayOfString.length >= 2) {
i = parseInt(parArrayOfString[1], 1, 1000000) * 20;
}

View file

@ -1,24 +0,0 @@
package net.minecraft.entity;
import net.minecraft.world.World;
/**
* Copyright (c) 2022 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public interface EntityConstructor<T> {
T createEntity(World world);
}

View file

@ -10,6 +10,7 @@ import com.google.common.collect.Maps;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.minecraft.EntityConstructor;
import net.minecraft.entity.ai.EntityMinecartMobSpawner;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.boss.EntityWither;

View file

@ -79,6 +79,10 @@ public abstract class EntityFireball extends Entity {
this.setLocationAndAngles(x, y, z, this.rotationYaw, this.rotationPitch);
this.setPosition(x, y, z);
double d0 = (double) MathHelper.sqrt_double(accelX * accelX + accelY * accelY + accelZ * accelZ);
if (d0 == 0.0) {
this.accelerationX = this.accelerationY = this.accelerationZ = 0.0D;
return;
}
this.accelerationX = accelX / d0 * 0.1D;
this.accelerationY = accelY / d0 * 0.1D;
this.accelerationZ = accelZ / d0 * 0.1D;
@ -95,6 +99,10 @@ public abstract class EntityFireball extends Entity {
accelY = accelY + this.rand.nextGaussian() * 0.4D;
accelZ = accelZ + this.rand.nextGaussian() * 0.4D;
double d0 = (double) MathHelper.sqrt_double(accelX * accelX + accelY * accelY + accelZ * accelZ);
if (d0 == 0.0) {
this.accelerationX = this.accelerationY = this.accelerationZ = 0.0D;
return;
}
this.accelerationX = accelX / d0 * 0.1D;
this.accelerationY = accelY / d0 * 0.1D;
this.accelerationZ = accelZ / d0 * 0.1D;
@ -144,7 +152,7 @@ public abstract class EntityFireball extends Entity {
.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
for (int i = 0; i < list.size(); ++i) {
for (int i = 0, l = list.size(); i < l; ++i) {
Entity entity1 = (Entity) list.get(i);
if (entity1.canBeCollidedWith()
&& (!entity1.isEntityEqual(this.shootingEntity) || this.ticksInAir >= 25)) {