encapsulating isClientSide()

This commit is contained in:
gnembon committed 2025-07-31 01:43:45 +02:00
1 parent 90ba928479
commit 49840619f5
16 files changed
+24 -24

No files matched your search

@@ -23,7 +23,7 @@ public abstract class AbstractArrowMixin extends Entity
@Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;DDDLnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)V", at = @At("RETURN")) @Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;DDDLnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)V", at = @At("RETURN"))
private void addLogger(final EntityType entityType, final double x, final double y, final double z, final Level level, final ItemStack itemStack, final ItemStack weapon, final CallbackInfo ci) private void addLogger(final EntityType entityType, final double x, final double y, final double z, final Level level, final ItemStack itemStack, final ItemStack weapon, final CallbackInfo ci)
{ {
if (LoggerRegistry.__projectiles && !level.isClientSide) if (LoggerRegistry.__projectiles && !level.isClientSide())
logHelper = new TrajectoryLogHelper("projectiles"); logHelper = new TrajectoryLogHelper("projectiles");
} }
@@ -29,7 +29,7 @@ public abstract class ArmorStand_scarpetMarkerMixin extends LivingEntity
@Inject(method = "readAdditionalSaveData", at = @At("HEAD")) @Inject(method = "readAdditionalSaveData", at = @At("HEAD"))
private void checkScarpetMarkerUnloaded(CallbackInfo ci) private void checkScarpetMarkerUnloaded(CallbackInfo ci)
{ {
if (!level().isClientSide) if (!level().isClientSide())
{ {
if (getTags().contains(Auxiliary.MARKER_STRING)) if (getTags().contains(Auxiliary.MARKER_STRING))
{ {
+1 -1
View File
@@ -35,6 +35,6 @@ public abstract class EntityMixin implements EntityInterface
@Inject(method = "isLocalInstanceAuthoritative", at = @At("HEAD"), cancellable = true) @Inject(method = "isLocalInstanceAuthoritative", at = @At("HEAD"), cancellable = true)
private void isFakePlayer(CallbackInfoReturnable<Boolean> cir) private void isFakePlayer(CallbackInfoReturnable<Boolean> cir)
{ {
if (getControllingPassenger() instanceof EntityPlayerMPFake) cir.setReturnValue(!level.isClientSide); if (getControllingPassenger() instanceof EntityPlayerMPFake) cir.setReturnValue(!level.isClientSide());
} }
} }
@@ -31,7 +31,7 @@ public abstract class ExperienceOrb_xpNoCooldownMixin extends Entity
@Inject(method = "playerTouch", at = @At("HEAD")) @Inject(method = "playerTouch", at = @At("HEAD"))
private void addXP(Player player, CallbackInfo ci) { private void addXP(Player player, CallbackInfo ci) {
if (CarpetSettings.xpNoCooldown && !level().isClientSide) { if (CarpetSettings.xpNoCooldown && !level().isClientSide()) {
player.takeXpDelay = 0; player.takeXpDelay = 0;
// reducing the count to 1 and leaving vanilla to deal with it // reducing the count to 1 and leaving vanilla to deal with it
while (this.count > 1) { while (this.count > 1) {
@@ -45,7 +45,7 @@ public abstract class Explosion_optimizedTntMixin
cancellable = true) cancellable = true)
private void calculateExplodedPositionsCM(final CallbackInfoReturnable<List<BlockPos>> cir) private void calculateExplodedPositionsCM(final CallbackInfoReturnable<List<BlockPos>> cir)
{ {
if (CarpetSettings.optimizedTNT && !level.isClientSide && !(getIndirectSourceEntity() instanceof Breeze)) if (CarpetSettings.optimizedTNT && !level.isClientSide() && !(getIndirectSourceEntity() instanceof Breeze))
{ {
cir.setReturnValue(OptimizedExplosion.doExplosionA((Explosion) (Object) this, eLogger)); cir.setReturnValue(OptimizedExplosion.doExplosionA((Explosion) (Object) this, eLogger));
} }
@@ -79,7 +79,7 @@ public abstract class Explosion_optimizedTntMixin
at = @At(value = "RETURN")) at = @At(value = "RETURN"))
private void onExplostion(ServerLevel world, Entity entity, DamageSource damageSource, final ExplosionDamageCalculator explosionBehavior, final Vec3 vec3, final float power, final boolean createFire, final Explosion.BlockInteraction destructionType, final CallbackInfo ci) private void onExplostion(ServerLevel world, Entity entity, DamageSource damageSource, final ExplosionDamageCalculator explosionBehavior, final Vec3 vec3, final float power, final boolean createFire, final Explosion.BlockInteraction destructionType, final CallbackInfo ci)
{ {
if (LoggerRegistry.__explosions && ! world.isClientSide) if (LoggerRegistry.__explosions && ! world.isClientSide())
{ {
eLogger = new ExplosionLogHelper(vec3.x, vec3.y, vec3.z, power, createFire, destructionType, level.registryAccess()); eLogger = new ExplosionLogHelper(vec3.x, vec3.y, vec3.z, power, createFire, destructionType, level.registryAccess());
} }
@@ -21,7 +21,7 @@ public abstract class FallingBlockEntityMixin extends Entity
@Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V", at = @At("RETURN")) @Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V", at = @At("RETURN"))
private void addLogger(EntityType<? extends Projectile> entityType_1, Level world_1, CallbackInfo ci) private void addLogger(EntityType<? extends Projectile> entityType_1, Level world_1, CallbackInfo ci)
{ {
if (LoggerRegistry.__fallingBlocks && !world_1.isClientSide) if (LoggerRegistry.__fallingBlocks && !world_1.isClientSide())
logHelper = new TrajectoryLogHelper("fallingBlocks"); logHelper = new TrajectoryLogHelper("fallingBlocks");
} }
@@ -22,7 +22,7 @@ public abstract class Guardian_renewableSpongesMixin extends Monster
@Override @Override
public void thunderHit(ServerLevel serverWorld, LightningBolt lightningEntity) public void thunderHit(ServerLevel serverWorld, LightningBolt lightningEntity)
{ // isRemoved() { // isRemoved()
if (!this.level().isClientSide && !this.isRemoved() && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardian)) if (!this.level().isClientSide() && !this.isRemoved() && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardian))
{ {
ElderGuardian elderGuardian = new ElderGuardian(EntityType.ELDER_GUARDIAN ,this.level()); ElderGuardian elderGuardian = new ElderGuardian(EntityType.ELDER_GUARDIAN ,this.level());
elderGuardian.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); elderGuardian.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
@@ -156,7 +156,7 @@ public abstract class LevelChunk_movableBEMixin extends ChunkAccess implements W
return null; return null;
} }
if (!level.isClientSide && sideEffects) { if (!level.isClientSide() && sideEffects) {
// this updates stuff, schedule ticks - do we want that since its only be called from MovingPistonBlock really? // this updates stuff, schedule ticks - do we want that since its only be called from MovingPistonBlock really?
newBlockState.onPlace(level, blockPos_1, oldBlockState, boolean_1); newBlockState.onPlace(level, blockPos_1, oldBlockState, boolean_1);
} }
@@ -125,7 +125,7 @@ public abstract class PistonMovingBlockEntity_movableBEMixin extends BlockEntity
//Handle TNT Explosions or other ways the moving Block is broken //Handle TNT Explosions or other ways the moving Block is broken
//Also /setblock will cause this to be called, and drop e.g. a moving chest's contents. //Also /setblock will cause this to be called, and drop e.g. a moving chest's contents.
// This is MC-40380 (BlockEntities that aren't Inventories drop stuff when setblock is called ) // This is MC-40380 (BlockEntities that aren't Inventories drop stuff when setblock is called )
if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null && !this.level.isClientSide && this.level.getBlockState(this.worldPosition).getBlock() == Blocks.AIR) if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null && !this.level.isClientSide() && this.level.getBlockState(this.worldPosition).getBlock() == Blocks.AIR)
{ {
BlockState blockState_2; BlockState blockState_2;
if (this.isSourcePiston) if (this.isSourcePiston)
@@ -52,7 +52,7 @@ public abstract class Player_parrotMixin extends LivingEntity
private void onTickMovement(CallbackInfo ci) private void onTickMovement(CallbackInfo ci)
{ {
boolean parrots_will_drop = !CarpetSettings.persistentParrots || this.abilities.invulnerable; boolean parrots_will_drop = !CarpetSettings.persistentParrots || this.abilities.invulnerable;
if (!this.level().isClientSide && ((parrots_will_drop && this.fallDistance > 0.5F) || this.isInWater() || this.abilities.flying || isSleeping())) if (!this.level().isClientSide() && ((parrots_will_drop && this.fallDistance > 0.5F) || this.isInWater() || this.abilities.flying || isSleeping()))
{ {
this.removeEntitiesOnShoulder(); this.removeEntitiesOnShoulder();
} }
@@ -58,7 +58,7 @@ public abstract class Player_scarpetEventsMixin extends LivingEntity
@Inject(method = "touch", at = @At("HEAD")) @Inject(method = "touch", at = @At("HEAD"))
private void onEntityCollision(Entity entity, CallbackInfo ci) private void onEntityCollision(Entity entity, CallbackInfo ci)
{ {
if (PLAYER_COLLIDES_WITH_ENTITY.isNeeded() && !level().isClientSide) if (PLAYER_COLLIDES_WITH_ENTITY.isNeeded() && !level().isClientSide())
{ {
PLAYER_COLLIDES_WITH_ENTITY.onEntityHandAction((ServerPlayer)(Object)this, entity, null); PLAYER_COLLIDES_WITH_ENTITY.onEntityHandAction((ServerPlayer)(Object)this, entity, null);
} }
@@ -67,7 +67,7 @@ public abstract class Player_scarpetEventsMixin extends LivingEntity
@Inject(method = "interactOn", cancellable = true, at = @At("HEAD")) @Inject(method = "interactOn", cancellable = true, at = @At("HEAD"))
private void doInteract(Entity entity, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) private void doInteract(Entity entity, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir)
{ {
if (!level().isClientSide && PLAYER_INTERACTS_WITH_ENTITY.isNeeded()) if (!level().isClientSide() && PLAYER_INTERACTS_WITH_ENTITY.isNeeded())
{ {
if(PLAYER_INTERACTS_WITH_ENTITY.onEntityHandAction((ServerPlayer) (Object)this, entity, hand)) { if(PLAYER_INTERACTS_WITH_ENTITY.onEntityHandAction((ServerPlayer) (Object)this, entity, hand)) {
cir.setReturnValue(InteractionResult.PASS); cir.setReturnValue(InteractionResult.PASS);
@@ -79,7 +79,7 @@ public abstract class Player_scarpetEventsMixin extends LivingEntity
@Inject(method = "attack", at = @At("HEAD"), cancellable = true) @Inject(method = "attack", at = @At("HEAD"), cancellable = true)
private void onAttack(Entity target, CallbackInfo ci) private void onAttack(Entity target, CallbackInfo ci)
{ {
if (!level().isClientSide && PLAYER_ATTACKS_ENTITY.isNeeded() && target.isAttackable()) if (!level().isClientSide() && PLAYER_ATTACKS_ENTITY.isNeeded() && target.isAttackable())
{ {
if(PLAYER_ATTACKS_ENTITY.onEntityHandAction((ServerPlayer) (Object)this, target, null)) { if(PLAYER_ATTACKS_ENTITY.onEntityHandAction((ServerPlayer) (Object)this, target, null)) {
ci.cancel(); ci.cancel();
@@ -43,7 +43,7 @@ public abstract class PrimedTntMixin extends Entity implements TntEntityInterfac
@Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V", at = @At("RETURN")) @Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V", at = @At("RETURN"))
private void initTNTLoggerPrime(EntityType<? extends PrimedTnt> entityType_1, Level world_1, CallbackInfo ci) private void initTNTLoggerPrime(EntityType<? extends PrimedTnt> entityType_1, Level world_1, CallbackInfo ci)
{ {
if (LoggerRegistry.__tnt && !world_1.isClientSide) if (LoggerRegistry.__tnt && !world_1.isClientSide())
{ {
logHelper = new TNTLogHelper(); logHelper = new TNTLogHelper();
} }
@@ -90,7 +90,7 @@ public abstract class PrimedTntMixin extends Entity implements TntEntityInterfac
// Merge code for combining tnt into a single entity if they happen to exist in the same spot, same fuse, no motion CARPET-XCOM // Merge code for combining tnt into a single entity if they happen to exist in the same spot, same fuse, no motion CARPET-XCOM
if(CarpetSettings.mergeTNT){ if(CarpetSettings.mergeTNT){
Vec3 velocity = getDeltaMovement(); Vec3 velocity = getDeltaMovement();
if(!level().isClientSide && mergeBool && velocity.x == 0 && velocity.y == 0 && velocity.z == 0){ if(!level().isClientSide() && mergeBool && velocity.x == 0 && velocity.y == 0 && velocity.z == 0){
mergeBool = false; mergeBool = false;
for(Entity entity : level().getEntities(this, this.getBoundingBox())){ for(Entity entity : level().getEntities(this, this.getBoundingBox())){
if(entity instanceof PrimedTnt && !entity.isRemoved()){ if(entity instanceof PrimedTnt && !entity.isRemoved()){
@@ -113,7 +113,7 @@ public abstract class PrimedTntMixin extends Entity implements TntEntityInterfac
{ {
// Merge code, merge only tnt that have had a chance to move CARPET-XCOM // Merge code, merge only tnt that have had a chance to move CARPET-XCOM
Vec3 velocity = getDeltaMovement(); Vec3 velocity = getDeltaMovement();
if(!level().isClientSide && (velocity.y != 0 || velocity.x != 0 || velocity.z != 0)){ if(!level().isClientSide() && (velocity.y != 0 || velocity.x != 0 || velocity.z != 0)){
mergeBool = true; mergeBool = true;
} }
} }
@@ -25,7 +25,7 @@ public class SummonCommand_lightningMixin
private static BlockPos addRiders(Entity entity) private static BlockPos addRiders(Entity entity)
{ {
// [CM] SummonNaturalLightning - if statement around // [CM] SummonNaturalLightning - if statement around
if (CarpetSettings.summonNaturalLightning && entity instanceof LightningBolt && !entity.level().isClientSide) if (CarpetSettings.summonNaturalLightning && entity instanceof LightningBolt && !entity.level().isClientSide())
{ {
ServerLevel world = (ServerLevel) entity.level(); ServerLevel world = (ServerLevel) entity.level();
BlockPos at = entity.blockPosition(); BlockPos at = entity.blockPosition();
@@ -21,7 +21,7 @@ public abstract class ThrowableProjectileMixin extends Entity
@Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V", at = @At("RETURN")) @Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V", at = @At("RETURN"))
private void addLogger(EntityType<? extends Projectile> entityType_1, Level world_1, CallbackInfo ci) private void addLogger(EntityType<? extends Projectile> entityType_1, Level world_1, CallbackInfo ci)
{ {
if (LoggerRegistry.__projectiles && !world_1.isClientSide) if (LoggerRegistry.__projectiles && !world_1.isClientSide())
logHelper = new TrajectoryLogHelper("projectiles"); logHelper = new TrajectoryLogHelper("projectiles");
} }
@@ -22,7 +22,7 @@ public abstract class WoolCarpetBlock_placeMixin extends Block
public BlockState getStateForPlacement(BlockPlaceContext context) public BlockState getStateForPlacement(BlockPlaceContext context)
{ {
BlockState state = super.getStateForPlacement(context); BlockState state = super.getStateForPlacement(context);
if (context.getPlayer() != null && !context.getLevel().isClientSide) if (context.getPlayer() != null && !context.getLevel().isClientSide())
{ // getColor() { // getColor()
WoolTool.carpetPlacedAction(((WoolCarpetBlock)(Object)this).getColor(), (ServerPlayer) context.getPlayer(), context.getClickedPos(), (ServerLevel) context.getLevel()); WoolTool.carpetPlacedAction(((WoolCarpetBlock)(Object)this).getColor(), (ServerPlayer) context.getPlayer(), context.getClickedPos(), (ServerLevel) context.getLevel());
} }
@@ -140,7 +140,7 @@ public class CarpetProfiler
Level world = tok.world; Level world = tok.world;
String current_section = (world == null) ? String current_section = (world == null) ?
(String) tok.section : (String) tok.section :
String.format("%s.%s%s", world.dimension().location(), tok.section, world.isClientSide ? " (Client)" : ""); String.format("%s.%s%s", world.dimension().location(), tok.section, world.isClientSide() ? " (Client)" : "");
SECTION_STATS.addTo(current_section, end_time - tok.start); SECTION_STATS.addTo(current_section, end_time - tok.start);
} }
} }
@@ -286,7 +286,7 @@ public class CarpetProfiler
id = regs.lookupOrThrow(Registries.BLOCK_ENTITY_TYPE).getKey((BlockEntityType<?>) section.getValue()); id = regs.lookupOrThrow(Registries.BLOCK_ENTITY_TYPE).getKey((BlockEntityType<?>) section.getValue());
} }
String name = "minecraft".equals(id.getNamespace())?id.getPath():id.toString(); String name = "minecraft".equals(id.getNamespace())?id.getPath():id.toString();
if (section.getKey().isClientSide) if (section.getKey().isClientSide())
{ {
name += " (client)"; name += " (client)";
} }
@@ -311,7 +311,7 @@ public class CarpetProfiler
{ {
if (++total > 10) break; if (++total > 10) break;
Pair<Level,Object> section = sectionEntry.getKey(); Pair<Level,Object> section = sectionEntry.getKey();
boolean cli = section.getKey().isClientSide; boolean cli = section.getKey().isClientSide();
Messenger.m(currentRequester, String.format( Messenger.m(currentRequester, String.format(
"%s - %s: ", cli?"gi":"w", "%s - %s: ", cli?"gi":"w",
sectionName(section)), sectionName(section)),
@@ -325,7 +325,7 @@ public class CarpetProfiler
{ {
if (++total > 10) break; if (++total > 10) break;
Pair<Level,Object> section = sectionEntry.getKey(); Pair<Level,Object> section = sectionEntry.getKey();
boolean cli = section.getKey().isClientSide; boolean cli = section.getKey().isClientSide();
Messenger.m(currentRequester, String.format( Messenger.m(currentRequester, String.format(
"%s - %s: ", cli?"gi":"w", "%s - %s: ", cli?"gi":"w",
sectionName(section)), sectionName(section)),