use of net.minecraft.util.profiling.ProfilerFiller in project pollen by MoonflowerTeam.
the class LocalTextureTableLoader method reload.
@Override
public CompletableFuture<Void> reload(PreparableReloadListener.PreparationBarrier stage, ResourceManager resourceManager, ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor) {
return CompletableFuture.supplyAsync(() -> {
Map<ResourceLocation, GeometryModelTextureTable> textureLocations = new HashMap<>();
for (ResourceLocation textureTableLocation : resourceManager.listResources(this.folder, name -> name.endsWith(".json"))) {
ResourceLocation textureTableName = new ResourceLocation(textureTableLocation.getNamespace(), textureTableLocation.getPath().substring(this.folder.length(), textureTableLocation.getPath().length() - 5));
if (textureTableName.getPath().equals("hash_tables"))
continue;
try (Resource resource = resourceManager.getResource(textureTableLocation)) {
textureLocations.put(textureTableName, GeometryModelParser.parseTextures(new InputStreamReader(resource.getInputStream())));
} catch (Exception e) {
LOGGER.error("Failed to load texture table '" + textureTableName + "'", e);
}
}
LOGGER.info("Loaded " + textureLocations.size() + " model texture tables.");
return textureLocations;
}, backgroundExecutor).thenAcceptBothAsync(CompletableFuture.supplyAsync(() -> {
Set<String> hashTables = new HashSet<>();
for (String domain : resourceManager.getNamespaces()) {
ResourceLocation hashTableLocation = new ResourceLocation(domain, this.folder + "hash_tables.json");
if (!resourceManager.hasResource(hashTableLocation))
continue;
try (Resource resource = resourceManager.getResource(hashTableLocation)) {
hashTables.addAll(Arrays.asList(GSON.fromJson(new InputStreamReader(resource.getInputStream()), String[].class)));
} catch (Exception e) {
LOGGER.error("Failed to load texture hash table for " + domain, e);
}
}
LOGGER.info("Loaded " + hashTables.size() + " hash tables.");
return hashTables.toArray(new String[0]);
}, backgroundExecutor), (textureLocations, hashTables) -> {
this.textures.clear();
this.textures.putAll(textureLocations);
this.hashTables = hashTables;
}, gameExecutor).thenCompose(stage::wait);
}
use of net.minecraft.util.profiling.ProfilerFiller in project pollen by MoonflowerTeam.
the class EntitlementManager method init.
public static void init() {
AddRenderLayersEvent.EVENT.register(context -> {
for (String skin : context.getSkins()) {
PlayerRenderer renderer = context.getSkin(skin);
if (renderer != null)
renderer.addLayer(new PollenCosmeticLayer<>(context.getSkin(skin)));
}
});
ResourceRegistry.registerReloadListener(PackType.CLIENT_RESOURCES, new PollinatedPreparableReloadListener() {
@Override
public ResourceLocation getPollenId() {
return new ResourceLocation(Pollen.MOD_ID, "entitlements");
}
@Override
public CompletableFuture<Void> reload(PreparationBarrier stage, ResourceManager resourceManager, ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor) {
return EntitlementManager.reload(false, stage, gameExecutor);
}
});
}
use of net.minecraft.util.profiling.ProfilerFiller in project architectury-api by architectury.
the class MixinClientLevel method tickEntitiesPost.
@Inject(method = "tickEntities", at = @At("RETURN"))
private void tickEntitiesPost(CallbackInfo ci) {
ProfilerFiller profiler = getProfiler();
profiler.push("architecturyClientLevelPostTick");
ClientTickEvent.CLIENT_LEVEL_POST.invoker().tick((ClientLevel) (Object) this);
profiler.pop();
}
use of net.minecraft.util.profiling.ProfilerFiller in project architectury-api by architectury.
the class ReloadListenerRegistryImpl method register.
public static void register(PackType type, PreparableReloadListener listener) {
var bytes = new byte[8];
RANDOM.nextBytes(bytes);
var id = new ResourceLocation("architectury:reload_" + StringUtils.leftPad(Math.abs(Longs.fromByteArray(bytes)) + "", 19, '0'));
ResourceManagerHelper.get(type).registerReloadListener(new IdentifiableResourceReloadListener() {
@Override
public ResourceLocation getFabricId() {
return id;
}
@Override
public String getName() {
return listener.getName();
}
@Override
public CompletableFuture<Void> reload(PreparationBarrier preparationBarrier, ResourceManager resourceManager, ProfilerFiller profilerFiller, ProfilerFiller profilerFiller2, Executor executor, Executor executor2) {
return listener.reload(preparationBarrier, resourceManager, profilerFiller, profilerFiller2, executor, executor2);
}
});
}
use of net.minecraft.util.profiling.ProfilerFiller in project fabric-carpet by gnembon.
the class Level_movableBEMixin method setBlockStateWithBlockEntity.
/**
* @author 2No2Name
*/
public boolean setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState blockState_1, BlockEntity newBlockEntity, int int_1) {
if (isOutsideBuildHeight(blockPos_1) || !this.isClientSide && isDebug())
return false;
LevelChunk worldChunk_1 = this.getChunkAt(blockPos_1);
Block block_1 = blockState_1.getBlock();
BlockState blockState_2;
if (newBlockEntity != null && block_1 instanceof EntityBlock) {
blockState_2 = ((WorldChunkInterface) worldChunk_1).setBlockStateWithBlockEntity(blockPos_1, blockState_1, newBlockEntity, (int_1 & 64) != 0);
if (newBlockEntity instanceof LidBlockEntity) {
scheduleTick(blockPos_1, block_1, 5);
}
} 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.getLightBlock((BlockGetter) this, blockPos_1) != blockState_2.getLightBlock((BlockGetter) this, blockPos_1) || blockState_3.getLightEmission() != blockState_2.getLightEmission() || blockState_3.useShapeForLightOcclusion() || blockState_2.useShapeForLightOcclusion())) {
ProfilerFiller profiler = getProfiler();
profiler.push("queueCheckLight");
this.getChunkSource().getLightEngine().checkBlock(blockPos_1);
profiler.pop();
}
if (blockState_3 == blockState_1) {
if (blockState_2 != blockState_3) {
this.setBlocksDirty(blockPos_1, blockState_2, blockState_3);
}
if ((int_1 & 2) != 0 && (!this.isClientSide || (int_1 & 4) == 0) && (this.isClientSide || worldChunk_1.getFullStatus() != null && worldChunk_1.getFullStatus().isOrAfter(ChunkHolder.FullChunkStatus.TICKING))) {
this.sendBlockUpdated(blockPos_1, blockState_2, blockState_1, int_1);
}
if (!this.isClientSide && (int_1 & 1) != 0) {
this.updateNeighborsAt(blockPos_1, blockState_2.getBlock());
if (blockState_1.hasAnalogOutputSignal()) {
updateNeighbourForOutputSignal(blockPos_1, block_1);
}
}
if ((int_1 & 16) == 0) {
int int_2 = int_1 & -34;
// prepare
blockState_2.updateIndirectNeighbourShapes(this, blockPos_1, int_2);
// updateNeighbours
blockState_1.updateNeighbourShapes(this, blockPos_1, int_2);
// prepare
blockState_1.updateIndirectNeighbourShapes(this, blockPos_1, int_2);
}
this.onBlockStateChange(blockPos_1, blockState_2, blockState_3);
}
return true;
}
}
Aggregations