类net.minecraft.world.chunk.WorldChunk源码实例Demo

下面列出了怎么用net.minecraft.world.chunk.WorldChunk的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: multiconnect   文件: MixinClientChunkManager.java
@Inject(method = "loadChunkFromPacket", at = @At("RETURN"))
private void onLoadChunkFromPacket(int x, int z, BiomeArray biomes, PacketByteBuf buf, CompoundTag heightmaps, int verticalStripBitmask, boolean bl, CallbackInfoReturnable<WorldChunk> ci) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_12_2) {
        if (ci.getReturnValue() != null) {
            synchronized (LOCK) {
                UpgradeData upgradeData = ChunkUpgrader.fixChunk(ci.getReturnValue());
                ((IUpgradableChunk) ci.getReturnValue()).multiconnect_setClientUpgradeData(upgradeData);
                for (int dx = -1; dx <= 1; dx++) {
                    for (int dz = -1; dz <= 1; dz++) {
                        WorldChunk chunk = getChunk(x + dx, z + dz, ChunkStatus.FULL, false);
                        if (chunk != null)
                            ((IUpgradableChunk) chunk).multiconnect_onNeighborLoaded();
                    }
                }
            }
        }
    }
}
 
源代码2 项目: multiconnect   文件: MixinClientChunkManager.java
@Inject(method = "loadChunkFromPacket", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/WorldChunk;getSectionArray()[Lnet/minecraft/world/chunk/ChunkSection;"))
private void recalculateHeightmaps(int x, int z, BiomeArray biomeArray, PacketByteBuf buf, CompoundTag tag, int verticalStripMask, boolean bl, CallbackInfoReturnable<WorldChunk> ci) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_13_2) {
        WorldChunk chunk = this.chunk.get();
        for (ChunkSection section : chunk.getSectionArray()) {
            if (section != null) {
                section.calculateCounts();
            }
        }
        Heightmap.populateHeightmaps(chunk, CLIENT_HEIGHTMAPS);
    }
    this.chunk.set(null);
}
 
源代码3 项目: multiconnect   文件: MixinClientChunkManager.java
@Inject(method = "loadChunkFromPacket", at = @At("RETURN"))
private void onLoadChunkFromPacket(int x, int z, BiomeArray biomeArray, PacketByteBuf buf, CompoundTag heightmaps, int verticalStripMask, boolean bl, CallbackInfoReturnable<WorldChunk> ci) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_14_4) {
        if (ci.getReturnValue() != null) {
            Biome[] biomeData = PendingBiomeData.getPendingBiomeData(x, z);
            if (biomeData != null) {
                ((IBiomeStorage_1_14_4) ci.getReturnValue()).multiconnect_setBiomeArray_1_14_4(biomeData);
                PendingBiomeData.setPendingBiomeData(x, z, null);
            }
        }
    }
}
 
源代码4 项目: multiconnect   文件: MixinWorldChunk.java
@Override
public void multiconnect_onNeighborLoaded() {
    if (clientUpgradeData != null) {
        for (int dx = -1; dx <= 1; dx++) {
            for (int dz = -1; dz <= 1; dz++) {
                if (world.getChunk(pos.x + dx, pos.z + dz, ChunkStatus.FULL, false) == null) {
                    return;
                }
            }
        }
        clientUpgradeData.upgrade((WorldChunk) (Object) this);
        clientUpgradeData = null;
    }
}
 
源代码5 项目: multiconnect   文件: MixinUpgradeData.java
@Redirect(method = "upgradeSide", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/WorldChunk;getUpgradeData()Lnet/minecraft/world/chunk/UpgradeData;"))
private static UpgradeData redirectGetUpgradeData(WorldChunk chunk) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_12_2) {
        return ((IUpgradableChunk) chunk).multiconnect_getClientUpgradeData();
    }
    return chunk.getUpgradeData();
}
 
源代码6 项目: patchwork-api   文件: ChunkSerializerMixin.java
@Redirect(method = "deserialize", at = @At(value = "NEW", target = "net/minecraft/world/chunk/WorldChunk"))
private static WorldChunk newWorldChunk(
		World newWorld, ChunkPos newChunkPos, Biome[] newBiomes, UpgradeData newUpgradeData, TickScheduler<Block> newTickScheduler, TickScheduler<Fluid> newTickScheduler2, long newL, @Nullable ChunkSection[] newChunkSections, @Nullable Consumer<WorldChunk> newConsumer,
		ServerWorld serverWorld, StructureManager structureManager, PointOfInterestStorage pointOfInterestStorage, ChunkPos chunkPos, CompoundTag compoundTag) {
	WorldChunk chunk = new WorldChunk(newWorld, newChunkPos, newBiomes, newUpgradeData, newTickScheduler, newTickScheduler2, newL, newChunkSections, newConsumer);
	CompoundTag level = compoundTag.getCompound("Level");

	if (level.contains("ForgeCaps")) {
		((CapabilityProviderHolder) chunk).deserializeCaps(level.getCompound("ForgeCaps"));
	}

	return chunk;
}
 
源代码7 项目: patchwork-api   文件: PacketDistributor.java
private Consumer<Packet<?>> trackingChunk(final Supplier<WorldChunk> worldChunk) {
	return packet -> {
		final WorldChunk chunk = worldChunk.get();
		((ServerChunkManager) chunk.getWorld().getChunkManager()).threadedAnvilChunkStorage.getPlayersWatchingChunk(chunk.getPos(), false)
			.forEach(e -> e.networkHandler.sendPacket(packet));
	};
}
 
源代码8 项目: fabric-carpet   文件: BlockValue.java
public static BlockEntity getBlockEntity(ServerWorld world, BlockPos pos)
{
    if (world.getServer().isOnThread())
        return world.getBlockEntity(pos);
    else
        return world.getWorldChunk(pos).getBlockEntity(pos, WorldChunk.CreationType.IMMEDIATE);
}
 
源代码9 项目: fabric-carpet   文件: ServerChunkManagerMixin.java
@SuppressWarnings("UnresolvedMixinReference")
@Redirect(method = "method_20801", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/world/SpawnHelper;spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/util/math/BlockPos;)V"
))
// inject our repeat of spawns if more spawn ticks per tick are chosen.
private void spawnMultipleTimes(EntityCategory entityCategory_1, ServerWorld world_1, WorldChunk worldChunk_1, BlockPos blockPos_1)
{
    for (int i = 0; i < SpawnReporter.spawn_tries.get(entityCategory_1); i++)
    {
        SpawnHelper.spawnEntitiesInChunk(entityCategory_1, world_1, worldChunk_1, blockPos_1);
    }
}
 
源代码10 项目: fabric-carpet   文件: World_scarpetPlopMixin.java
@Redirect(method = "getTopY", at = @At(
        value = "INVOKE",
        target = "net/minecraft/world/chunk/WorldChunk.sampleHeightmap(Lnet/minecraft/world/Heightmap$Type;II)I"
))
private int fixSampleHeightmap(WorldChunk chunk, Heightmap.Type type, int x, int z)
{
    if (CarpetSettings.skipGenerationChecks)
    {
        Heightmap.Type newType = type;
        if (type == Heightmap.Type.OCEAN_FLOOR_WG) newType = Heightmap.Type.OCEAN_FLOOR;
        else if (type == Heightmap.Type.WORLD_SURFACE_WG) newType = Heightmap.Type.WORLD_SURFACE;
        return chunk.sampleHeightmap(newType, x, z);
    }
    return chunk.sampleHeightmap(type, x, z);
}
 
@Inject(method = "tickChunk", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/server/world/ServerWorld;addLightning(Lnet/minecraft/entity/LightningEntity;)V"
))
private void onNaturalLightinig(WorldChunk chunk, int randomTickSpeed, CallbackInfo ci,
                                ChunkPos chunkPos, boolean bl, int i, int j, Profiler profiler, BlockPos blockPos, boolean bl2)
{
    if (LIGHTNING.isNeeded()) LIGHTNING.onWorldEventFlag((ServerWorld) (Object)this, blockPos, bl2?1:0);
}
 
源代码12 项目: fabric-carpet   文件: SpawnHelperMixin.java
@Redirect(method = "spawnEntitiesInChunk", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/entity/player/PlayerEntity;squaredDistanceTo(DDD)D"
))
private static double getSqDistanceTo(PlayerEntity playerEntity, double double_1, double double_2, double double_3,
                                      EntityCategory entityCategory_1, ServerWorld world_1, WorldChunk worldChunk_1, BlockPos blockPos_1)
{
    double distanceTo = playerEntity.squaredDistanceTo(double_1, double_2, double_3);
    if (CarpetSettings.lagFreeSpawning && distanceTo > 16384.0D && entityCategory_1 != EntityCategory.CREATURE)
        return 0.0;
    return distanceTo;
}
 
源代码13 项目: fabric-carpet   文件: WorldChunk_movableTEMixin.java
@Redirect(method = "setBlockState", at = @At(value = "INVOKE", ordinal = 1,
        target = "Lnet/minecraft/world/chunk/WorldChunk;getBlockEntity(Lnet/minecraft/util/math/BlockPos;" + "Lnet/minecraft/world/chunk/WorldChunk$CreationType;)" + "Lnet/minecraft/block/entity/BlockEntity;"))
private BlockEntity ifGetBlockEntity(WorldChunk worldChunk, BlockPos blockPos_1,
        WorldChunk.CreationType worldChunk$CreationType_1)
{
    if (!CarpetSettings.movableBlockEntities)
    {
        return this.getBlockEntity(blockPos_1, WorldChunk.CreationType.CHECK);
    }
    else
    {
        return this.world.getBlockEntity(blockPos_1);
    }
}
 
源代码14 项目: multiconnect   文件: MixinClientChunkManager.java
@Inject(method = "loadChunkFromPacket", at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", ordinal = 0, remap = false), cancellable = true)
private void cancelErrorMessage(int x, int z, BiomeArray biomeArray, PacketByteBuf buf, CompoundTag tag, int verticalStripMask, boolean bl, CallbackInfoReturnable<WorldChunk> ci) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_13_2 && !PendingChunkDataPackets.isProcessingQueuedPackets())
        ci.setReturnValue(null);
}
 
源代码15 项目: multiconnect   文件: MixinClientChunkManager.java
@ModifyVariable(method = "loadChunkFromPacket", ordinal = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/WorldChunk;getSectionArray()[Lnet/minecraft/world/chunk/ChunkSection;"))
private WorldChunk grabChunk(WorldChunk chunk) {
    this.chunk.set(chunk);
    return chunk;
}
 
源代码16 项目: multiconnect   文件: ChunkUpgrader.java
public static UpgradeData fixChunk(WorldChunk chunk) {
    IntList centerIndicesToUpgrade = new IntArrayList();
    int sidesToUpgrade = 0;

    BlockPos.Mutable otherPos = new BlockPos.Mutable();
    for (BlockPos pos : BlockPos.iterate(chunk.getPos().getStartX(), 0, chunk.getPos().getStartZ(),
            chunk.getPos().getEndX(), chunk.getHighestNonEmptySectionYOffset() + 15, chunk.getPos().getEndZ())) {
        BlockState state = chunk.getBlockState(pos);
        Block block = state.getBlock();
        inPlaceFix(chunk, state, pos, otherPos);

        int blockId = Registry.BLOCK.getRawId(block) & 4095;
        if (ChunkPalettedStorageFixAccessor.getBlocksNeedingSideUpdate().get(blockId)) {
            boolean west = (pos.getX() & 15) == 0;
            boolean east = (pos.getX() & 15) == 15;
            boolean north = (pos.getZ() & 15) == 0;
            boolean south = (pos.getZ() & 15) == 15;
            if (north) {
                if (east) {
                    sidesToUpgrade |= 2;
                } else if (west) {
                    sidesToUpgrade |= 128;
                } else {
                    sidesToUpgrade |= 1;
                }
            } else if (south) {
                if (west) {
                    sidesToUpgrade |= 32;
                } else if (east) {
                    sidesToUpgrade |= 8;
                } else {
                    sidesToUpgrade |= 16;
                }
            } else if (east) {
                sidesToUpgrade |= 4;
            } else if (west) {
                sidesToUpgrade |= 64;
            } else {
                centerIndicesToUpgrade.add(pos.getY() << 8 | (pos.getZ() & 15) << 4 | (pos.getX() & 15));
            }
        }
    }

    if (centerIndicesToUpgrade.isEmpty() && sidesToUpgrade == 0)
        return null;

    CompoundTag upgradeData = new CompoundTag();
    upgradeData.putInt("Sides", sidesToUpgrade);
    CompoundTag centerIndices = new CompoundTag();
    centerIndicesToUpgrade.forEach((IntConsumer) index -> {
        int low = index & 4095;
        int high = index >>> 12;
        Tag tag = centerIndices.get(String.valueOf(high));
        if (tag == null)
            centerIndices.put(String.valueOf(high), tag = new ListTag());
        ((ListTag) tag).add(IntTag.of(low));
    });
    for (String key : centerIndices.getKeys()) {
        //noinspection ConstantConditions
        centerIndices.put(key, new IntArrayTag(((ListTag) centerIndices.get(key)).stream().mapToInt(val -> ((IntTag) val).getInt()).toArray()));
    }
    upgradeData.put("Indices", centerIndices);
    return new UpgradeData(upgradeData);
}
 
源代码17 项目: patchwork-api   文件: WorldChunkMixin.java
@Nonnull
@Override
public CapabilityProvider<WorldChunk> getCapabilityProvider() {
	return provider;
}
 
源代码18 项目: fabric-carpet   文件: World_movableTEMixin.java
@Shadow
public abstract WorldChunk getWorldChunk(BlockPos blockPos_1);
 
源代码19 项目: fabric-carpet   文件: World_movableTEMixin.java
/**
 * @author 2No2Name
 */
public boolean setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState blockState_1, BlockEntity newBlockEntity, int int_1)
{
    if ((Object) this instanceof EmptyChunk)
        return false;
    
    if (World.isHeightInvalid(blockPos_1))
    {
        return false;
    }
    else if (!this.isClient && this.properties.getGeneratorType() == LevelGeneratorType.DEBUG_ALL_BLOCK_STATES)
    {
        return false;
    }
    else
    {
        WorldChunk worldChunk_1 = this.getWorldChunk(blockPos_1);
        Block block_1 = blockState_1.getBlock();
        
        BlockState blockState_2;
        if (newBlockEntity != null && block_1 instanceof BlockEntityProvider)
            blockState_2 = ((WorldChunkInterface) worldChunk_1).setBlockStateWithBlockEntity(blockPos_1, blockState_1, newBlockEntity, (int_1 & 64) != 0);
        else
            blockState_2 = worldChunk_1.setBlockState(blockPos_1, blockState_1, (int_1 & 64) != 0);
        
        if (blockState_2 == null)
        {
            return false;
        }
        else
        {
            BlockState blockState_3 = this.getBlockState(blockPos_1);
            
            if (blockState_3 != blockState_2 && (blockState_3.getOpacity((BlockView) this, blockPos_1) != blockState_2.getOpacity((BlockView) this, blockPos_1) || blockState_3.getLuminance() != blockState_2.getLuminance() || blockState_3.hasSidedTransparency() || blockState_2.hasSidedTransparency()))
            {
                this.profiler.push("queueCheckLight");
                this.getChunkManager().getLightingProvider().checkBlock(blockPos_1);
                this.profiler.pop();
            }
            
            if (blockState_3 == blockState_1)
            {
                if (blockState_2 != blockState_3)
                {
                    this.checkBlockRerender(blockPos_1, blockState_2, blockState_3);
                }
                
                if ((int_1 & 2) != 0 && (!this.isClient || (int_1 & 4) == 0) && (this.isClient || worldChunk_1.getLevelType() != null && worldChunk_1.getLevelType().isAfter(ChunkHolder.LevelType.TICKING)))
                {
                    this.updateListeners(blockPos_1, blockState_2, blockState_1, int_1);
                }
                
                if (!this.isClient && (int_1 & 1) != 0)
                {
                    this.updateNeighbors(blockPos_1, blockState_2.getBlock());
                    if (blockState_1.hasComparatorOutput())
                    {
                        this.updateHorizontalAdjacent(blockPos_1, block_1);
                    }
                }
                
                if ((int_1 & 16) == 0)
                {
                    int int_2 = int_1 & -2;
                    blockState_2.method_11637((net.minecraft.world.IWorld) this, blockPos_1, int_2);
                    blockState_1.updateNeighborStates((net.minecraft.world.IWorld) this, blockPos_1, int_2);
                    blockState_1.method_11637((net.minecraft.world.IWorld) this, blockPos_1, int_2);
                }
                
                this.onBlockChanged(blockPos_1, blockState_2, blockState_3);
            }
            return true;
        }
    }
}
 
源代码20 项目: fabric-carpet   文件: WorldChunk_movableTEMixin.java
@Shadow
/* @Nullable */
public abstract BlockEntity getBlockEntity(BlockPos blockPos_1, WorldChunk.CreationType worldChunk$CreationType_1);
 
源代码21 项目: multiconnect   文件: MixinClientChunkManager.java
@Shadow public abstract WorldChunk getChunk(int x, int z, ChunkStatus status, boolean create); 
 类所在包
 类方法
 同包方法