Merge branch 'master' into future
This commit is contained in:
commit
ab989155ad
6 files changed
+92
-37
No files matched your search
@@ -45,7 +45,11 @@ public class TickCommand
|
||||
getInteger(c,"ticks"),
|
||||
getString(c, "tail command")))))).
|
||||
then(literal("freeze").executes( (c)-> toggleFreeze(c.getSource(), false)).
|
||||
then(literal("deep").executes( (c)-> toggleFreeze(c.getSource(), true)))).
|
||||
then(literal("status").executes( (c) -> freezeStatus(c.getSource()))).
|
||||
then(literal("deep").executes( (c) -> toggleFreeze(c.getSource(), true))).
|
||||
then(literal("on").executes( (c) -> setFreeze(c.getSource(), false, true)).
|
||||
then(literal("deep").executes( (c)-> setFreeze(c.getSource(), true, true)))).
|
||||
then(literal("off").executes( (c) -> setFreeze(c.getSource(), false, false)))).
|
||||
then(literal("step").
|
||||
executes((c) -> step(1)).
|
||||
then(argument("ticks", integer(1,72000)).
|
||||
@@ -94,9 +98,22 @@ public class TickCommand
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int toggleFreeze(ServerCommandSource source, boolean isDeep)
|
||||
private static int freezeStatus(ServerCommandSource source)
|
||||
{
|
||||
TickSpeed.setFrozenState(!TickSpeed.isPaused(), isDeep);
|
||||
if(TickSpeed.isPaused())
|
||||
{
|
||||
Messenger.m(source, "gi Freeze Status: Game is "+(TickSpeed.deeplyFrozen()?"deeply ":"")+"frozen");
|
||||
}
|
||||
else
|
||||
{
|
||||
Messenger.m(source, "gi Freeze Status: Game runs normally");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int setFreeze(ServerCommandSource source, boolean isDeep, boolean freeze)
|
||||
{
|
||||
TickSpeed.setFrozenState(freeze, isDeep);
|
||||
if (TickSpeed.isPaused())
|
||||
{
|
||||
Messenger.m(source, "gi Game is "+(isDeep?"deeply ":"")+"frozen");
|
||||
@@ -108,6 +125,11 @@ public class TickCommand
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int toggleFreeze(ServerCommandSource source, boolean isDeep)
|
||||
{
|
||||
return setFreeze(source, isDeep, !TickSpeed.isPaused());
|
||||
}
|
||||
|
||||
private static int step(int advance)
|
||||
{
|
||||
TickSpeed.add_ticks_to_run_in_pause(advance);
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.math.RoundingMode;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import carpet.logging.logHelpers.ExplosionLogHelper;
|
||||
@@ -12,7 +13,6 @@ import carpet.mixins.ExplosionAccessor;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.utils.Messenger;
|
||||
import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -58,8 +58,8 @@ public class OptimizedExplosion
|
||||
// masa's optimizations
|
||||
private static Object2DoubleOpenHashMap<Pair<Vec3d, Box>> densityCache = new Object2DoubleOpenHashMap<>();
|
||||
private static MutablePair<Vec3d, Box> pairMutable = new MutablePair<>();
|
||||
private static Object2ObjectOpenHashMap<BlockPos, BlockState> stateCache = new Object2ObjectOpenHashMap<>();
|
||||
private static Object2ObjectOpenHashMap<BlockPos, FluidState> fluidCache = new Object2ObjectOpenHashMap<>();
|
||||
private static HashMap<BlockPos.Mutable, Float> blastResCache = new HashMap<>();
|
||||
private static HashMap<BlockPos.Mutable, BlockState> blockStateCache = new HashMap<>();
|
||||
private static BlockPos.Mutable posMutable = new BlockPos.Mutable(0, 0, 0);
|
||||
private static ObjectOpenHashSet<BlockPos> affectedBlockPositionsSet = new ObjectOpenHashSet<>();
|
||||
private static boolean firstRay;
|
||||
@@ -86,8 +86,8 @@ public class OptimizedExplosion
|
||||
getAffectedPositionsOnPlaneX(e, 15, 1, 14, 0, 15); // east
|
||||
getAffectedPositionsOnPlaneZ(e, 0, 1, 14, 1, 14); // north
|
||||
getAffectedPositionsOnPlaneZ(e, 15, 1, 14, 1, 14); // south
|
||||
stateCache.clear();
|
||||
fluidCache.clear();
|
||||
blastResCache.clear();
|
||||
blockStateCache.clear();
|
||||
|
||||
e.getAffectedBlocks().addAll(affectedBlockPositionsSet);
|
||||
affectedBlockPositionsSet.clear();
|
||||
@@ -446,6 +446,7 @@ public class OptimizedExplosion
|
||||
double xInc = (xRel / len) * 0.3;
|
||||
double yInc = (yRel / len) * 0.3;
|
||||
double zInc = (zRel / len) * 0.3;
|
||||
World world = eAccess.getWorld();
|
||||
float rand = eAccess.getWorld().random.nextFloat();
|
||||
float sizeRand = (CarpetSettings.tntRandomRange >= 0 ? (float) CarpetSettings.tntRandomRange : rand);
|
||||
float size = eAccess.getPower() * (0.7F + sizeRand * 0.6F);
|
||||
@@ -457,38 +458,44 @@ public class OptimizedExplosion
|
||||
{
|
||||
posMutable.set(posX, posY, posZ);
|
||||
|
||||
// Don't query already cached positions again from the world
|
||||
BlockState state = stateCache.get(posMutable);
|
||||
FluidState fluid = fluidCache.get(posMutable);
|
||||
BlockPos posImmutable = null;
|
||||
|
||||
if (state == null)
|
||||
// Don't query already cached positions again from the world
|
||||
if (!blastResCache.containsKey(posMutable))
|
||||
{
|
||||
posImmutable = posMutable.toImmutable();
|
||||
state = eAccess.getWorld().getBlockState(posImmutable);
|
||||
stateCache.put(posImmutable, state);
|
||||
fluid = eAccess.getWorld().getFluidState(posImmutable);
|
||||
fluidCache.put(posImmutable, fluid);
|
||||
}
|
||||
|
||||
if (state.getMaterial() != Material.AIR)
|
||||
{
|
||||
float resistance = Math.max(state.getBlock().getBlastResistance(), fluid.getBlastResistance());
|
||||
|
||||
if (eAccess.getEntity() != null)
|
||||
BlockState state = world.getBlockState(posImmutable);
|
||||
Float resistance = null;
|
||||
if (!state.isAir())
|
||||
{
|
||||
resistance = eAccess.getEntity().getEffectiveExplosionResistance(e, eAccess.getWorld(), posMutable, state, fluid, resistance);
|
||||
FluidState fluid = world.getFluidState(posImmutable);
|
||||
resistance = Math.max(state.getBlock().getBlastResistance(), fluid.getBlastResistance());
|
||||
if (eAccess.getEntity() != null)
|
||||
{
|
||||
resistance = eAccess.getEntity().getEffectiveExplosionResistance(e, world, posMutable, state, fluid, resistance);
|
||||
}
|
||||
}
|
||||
|
||||
size -= (resistance + 0.3F) * 0.3F;
|
||||
blockStateCache.put(posMutable, state);
|
||||
blastResCache.put(posMutable, resistance);
|
||||
}
|
||||
|
||||
if (size > 0.0F)
|
||||
Float blastRes = blastResCache.get(posMutable);
|
||||
BlockState state = blockStateCache.get(posMutable);
|
||||
|
||||
if(blastRes != null)
|
||||
{
|
||||
if ((eAccess.getEntity() == null || eAccess.getEntity().canExplosionDestroyBlock(e, eAccess.getWorld(), posMutable, state, size)))
|
||||
affectedBlockPositionsSet.add(posImmutable != null ? posImmutable : posMutable.toImmutable());
|
||||
size -= (blastRes + 0.3F) * 0.3F;
|
||||
if (size > 0.0F)
|
||||
{
|
||||
if ((eAccess.getEntity() == null || eAccess.getEntity().canExplosionDestroyBlock(e, eAccess.getWorld(), posMutable, state, size)))
|
||||
{
|
||||
affectedBlockPositionsSet.add(posImmutable != null ? posImmutable : posMutable.toImmutable());
|
||||
blastResCache.put(posMutable, null);
|
||||
blockStateCache.remove(posMutable);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (firstRay)
|
||||
if (firstRay)
|
||||
{
|
||||
rayCalcDone = true;
|
||||
return true;
|
||||
|
||||
@@ -941,7 +941,7 @@ public class EntityValue extends Value
|
||||
{
|
||||
e.velocityModified = true;
|
||||
if (Math.abs(scale) > 10000)
|
||||
CarpetScriptServer.LOG.warn("Moved entity "+e.getEntityName()+" "+e.getName()+" at " +e.getPos()+" extremly fast: "+e.getVelocity());
|
||||
CarpetScriptServer.LOG.warn("Moved entity "+e.getEntityName()+" "+e.getName()+" at " +e.getPos()+" extremely fast: "+e.getVelocity());
|
||||
//((ServerWorld)e.getEntityWorld()).method_14178().sendToNearbyPlayers(e, new EntityVelocityUpdateS2CPacket(e));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user