net.minecraft.world.chunk.UpgradeData Java Examples

The following examples show how to use net.minecraft.world.chunk.UpgradeData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MixinClientChunkManager.java    From multiconnect with MIT License 6 votes vote down vote up
@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();
                    }
                }
            }
        }
    }
}
 
Example #2
Source File: MixinUpgradeData.java    From multiconnect with MIT License 5 votes vote down vote up
@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();
}
 
Example #3
Source File: ChunkSerializerMixin.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@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;
}
 
Example #4
Source File: ChunkHolder_scarpetChunkCreationMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Override
public CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> setDefaultProtoChunk(ChunkPos chpos, ThreadExecutor<Runnable> executor)
{
    int i = ChunkStatus.EMPTY.getIndex();
    CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> completableFuture2 = CompletableFuture.supplyAsync(
            () -> Either.left(new ProtoChunk(chpos, UpgradeData.NO_UPGRADE_DATA)),
            executor
    );
    updateFuture(completableFuture2);
    futuresByStatus.set(i, completableFuture2);
    return completableFuture2;
}
 
Example #5
Source File: ChunkUpgrader.java    From multiconnect with MIT License 4 votes vote down vote up
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);
}
 
Example #6
Source File: MixinWorldChunk.java    From multiconnect with MIT License 4 votes vote down vote up
@Override
public UpgradeData multiconnect_getClientUpgradeData() {
    return clientUpgradeData;
}
 
Example #7
Source File: MixinWorldChunk.java    From multiconnect with MIT License 4 votes vote down vote up
@Override
public void multiconnect_setClientUpgradeData(UpgradeData upgradeData) {
    this.clientUpgradeData = upgradeData;
}
 
Example #8
Source File: IUpgradableChunk.java    From multiconnect with MIT License votes vote down vote up
UpgradeData multiconnect_getClientUpgradeData(); 
Example #9
Source File: IUpgradableChunk.java    From multiconnect with MIT License votes vote down vote up
void multiconnect_setClientUpgradeData(UpgradeData upgradeData);