Remove world, pos override of dispatchTE, which requeries the TE and thus is laggier

This commit is contained in:
Vincent Lee committed 2020-06-12 09:07:31 -05:00
1 parent 4d7defad63
commit f2f6cdba41
15 files changed
+21 -30

No files matched your search

@@ -30,11 +30,4 @@ public final class VanillaPacketDispatcher {
}
}
public static void dispatchTEToNearbyPlayers(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile != null) {
dispatchTEToNearbyPlayers(tile);
}
}
}
@@ -95,7 +95,7 @@ public class BlockFloatingFlower extends BlockModWaterloggable {
if (type != null && type != flower.getIslandType()) {
if (!world.isRemote) {
flower.setIslandType(type);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(te);
}
if (!player.abilities.isCreativeMode) {
@@ -90,9 +90,7 @@ public class BlockPool extends BlockModWaterloggable implements IWandHUD, IWanda
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
if (entity instanceof ItemEntity) {
TilePool tile = (TilePool) world.getTileEntity(pos);
if (tile.collideEntityItem((ItemEntity) entity)) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
}
tile.collideEntityItem((ItemEntity) entity);
}
}
@@ -210,7 +210,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
public void trySetLastRecipe(PlayerEntity player) {
tryToSetLastRecipe(player, itemHandler, lastRecipe);
if (!isEmpty()) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
}
@@ -265,7 +265,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
}
if (didChange) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
} else {
for (int i = 0; i < getSizeInventory(); i++) {
@@ -362,7 +362,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
public void setFluid(Fluid fluid) {
Preconditions.checkArgument(fluid == Fluids.WATER || fluid == Fluids.LAVA || fluid == Fluids.EMPTY);
this.fluid = fluid;
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
@Override
@@ -84,7 +84,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I
}
if (did) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
findRecipe();
}
@@ -381,7 +381,7 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
}
public void sync() {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
@Override
@@ -113,7 +113,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
}
if (did) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
return true;
@@ -219,7 +219,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
if (manaToGet != this.manaToGet) {
world.playSound(null, pos, ModSounds.runeAltarStart, SoundCategory.BLOCKS, 1, 1);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
}
@@ -239,7 +239,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
public void trySetLastRecipe(PlayerEntity player) {
TileAltar.tryToSetLastRecipe(player, itemHandler, lastRecipe);
if (!isEmpty()) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
}
@@ -89,7 +89,7 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab
.forEach(os -> os.registerTransfer(spark));
}
if (mana > 0) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
PacketHandler.sendToNearby(world, getPos(),
new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.TERRA_PLATE, getPos().getX(), getPos().getY(), getPos().getZ()));
}
@@ -106,7 +106,7 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab
world.playSound(null, item.getPosX(), item.getPosY(), item.getPosZ(), ModSounds.terrasteelCraft, SoundCategory.BLOCKS, 1, 1);
mana = 0;
world.updateComparatorOutputLevel(pos, getBlockState().getBlock());
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
}
}
@@ -123,7 +123,7 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickableTile
@Override
public void markDirty() {
super.markDirty();
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
@Override
@@ -149,7 +149,7 @@ public class TileBellows extends TileMod implements ITickableTileEntity {
boolean diff = this.active != active;
this.active = active;
if (diff) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
}
}
@@ -395,7 +395,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
public void onWanded(PlayerEntity player) {
if (player == null || player.isSneaking()) {
outputting = !outputting;
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
}
@@ -107,7 +107,7 @@ public class TilePump extends TileMod implements ITickableTileEntity {
boolean diff = this.active != active;
this.active = active;
if (diff) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
}
}
@@ -269,7 +269,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
if (receiverLastTick != receiver && !world.isRemote) {
requestsClientUpdate = true;
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
redstoneLastTick = redstone;
@@ -424,7 +424,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
checkForReceiver();
requestsClientUpdate = true;
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, getPos());
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
}
}
@@ -632,7 +632,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
@Override
public void markDirty() {
checkForReceiver();
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
@Override
@@ -82,7 +82,7 @@ public class TileTurntable extends TileMod implements ITickableTileEntity {
} else {
speed = speed == 6 ? 1 : speed + 1;
}
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
}
@OnlyIn(Dist.CLIENT)
@@ -625,7 +625,7 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst {
if (tile instanceof IThrottledPacket) {
((IThrottledPacket) tile).markDispatchable();
} else {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers((TileEntity) tile);
}
}