use of net.minecraft.resource.ResourceManager in project Primeval by devs-immortal.
the class PrimevalFluids method setupFluidRendering.
/*
* Fluid rendering setup from Spectrum,
* Made by DaFaqs, credit to him for this
* method
*/
@Environment(EnvType.CLIENT)
private static void setupFluidRendering(final Fluid still, final Fluid flowing, final Identifier textureFluidId, final int color) {
final Identifier stillSpriteId = new Identifier(textureFluidId.getNamespace(), "block/" + textureFluidId.getPath());
final Identifier flowingSpriteId = new Identifier(textureFluidId.getNamespace(), "block/" + textureFluidId.getPath() + "_flow");
// If they're not already present, add the sprites to the block atlas
ClientSpriteRegistryCallback.event(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE).register((atlasTexture, registry) -> {
registry.register(stillSpriteId);
registry.register(flowingSpriteId);
});
final Identifier fluidId = Registry.FLUID.getId(still);
final Identifier listenerId = new Identifier(fluidId.getNamespace(), fluidId.getPath() + "_reload_listener");
final Sprite[] fluidSprites = { null, null };
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
/**
* Get the sprites from the block atlas when resources are reloaded
*/
@Override
public void reload(ResourceManager manager) {
final Function<Identifier, Sprite> atlas = MinecraftClient.getInstance().getSpriteAtlas(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE);
fluidSprites[0] = atlas.apply(stillSpriteId);
fluidSprites[1] = atlas.apply(flowingSpriteId);
}
@Override
public Identifier getFabricId() {
return listenerId;
}
});
// The FluidRenderer gets the sprites and color from a FluidRenderHandler during rendering
final FluidRenderHandler renderHandler = new FluidRenderHandler() {
@Override
public Sprite[] getFluidSprites(BlockRenderView view, BlockPos pos, FluidState state) {
return fluidSprites;
}
@Override
public int getFluidColor(BlockRenderView view, BlockPos pos, FluidState state) {
return color;
}
};
FluidRenderHandlerRegistry.INSTANCE.register(still, renderHandler);
// FluidRenderHandlerRegistry.INSTANCE.register(flowing, renderHandler); // Temp removed because of flowing shenanigans
}
use of net.minecraft.resource.ResourceManager in project BleachHack by BleachDrinker420.
the class ShaderLoader method loadEffect.
public static ShaderEffect loadEffect(Framebuffer framebuffer, Identifier id) throws JsonSyntaxException, IOException {
ResourceManager resMang = MinecraftClient.getInstance().getResourceManager();
TextureManager texMang = MinecraftClient.getInstance().getTextureManager();
return new ShaderEffect(texMang, new OpenResourceManager(resMang), framebuffer, id);
}
use of net.minecraft.resource.ResourceManager in project fabric by FabricMC.
the class ResourceReloadModClient method onInitializeClient.
@Override
public void onInitializeClient() {
for (int i = 64; i >= 2; i--) {
final int _i = i;
ResourceManagerHelper.get(ResourceType.ASSETS).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
@Override
public void apply(ResourceManager var1) {
System.out.println("Reloading (should run as #" + _i + ")");
}
@Override
public Identifier getFabricId() {
return new Identifier("fabric:rrmc" + _i);
}
@Override
public Collection<Identifier> getFabricDependencies() {
return Collections.singletonList(new Identifier("fabric:rrmc" + (_i - 1)));
}
});
}
ResourceManagerHelper.get(ResourceType.ASSETS).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
@Override
public Identifier getFabricId() {
return new Identifier("fabric:rrmc1");
}
@Override
public void apply(ResourceManager var1) {
System.out.println("Reloading (should run as #1)");
}
});
ResourceManagerHelper.get(ResourceType.ASSETS).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
@Override
public Identifier getFabricId() {
return new Identifier("fabric:rrmc_should_not_resolve");
}
@Override
public Collection<Identifier> getFabricDependencies() {
return Collections.singletonList(new Identifier("fabric:rrmc_nonexistent"));
}
@Override
public void apply(ResourceManager var1) {
}
});
}
use of net.minecraft.resource.ResourceManager in project quilt-standard-libraries by QuiltMC.
the class ResourceReloaderTestMod method setupClientReloadListeners.
private void setupClientReloadListeners() {
ResourceLoader.get(ResourceType.CLIENT_RESOURCES).registerReloader(new SimpleSynchronousResourceReloader() {
@Override
public Identifier getQuiltId() {
return ResourceLoaderTestMod.id("client_second");
}
@Override
public void reload(ResourceManager manager) {
if (!clientResources) {
throw new AssertionError("Second resource reloader was called before the first!");
}
LOGGER.info("Second client resource reloader is called.");
}
@Override
public Collection<Identifier> getQuiltDependencies() {
return Collections.singletonList(ResourceLoaderTestMod.id("client_first"));
}
});
ResourceLoader.get(ResourceType.CLIENT_RESOURCES).registerReloader(new SimpleSynchronousResourceReloader() {
@Override
public Identifier getQuiltId() {
return ResourceLoaderTestMod.id("client_first");
}
@Override
public void reload(ResourceManager manager) {
clientResources = true;
LOGGER.info("First client resource reloader is called.");
}
});
}
use of net.minecraft.resource.ResourceManager in project tweed-api by Siphalor.
the class Tweed method onInitialize.
@Override
public void onInitialize() {
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
@Override
public Identifier getFabricId() {
return new Identifier(Tweed.MOD_ID, "resource_reload");
}
@Override
public void apply(ResourceManager resourceManager) {
try {
ConfigLoader.loadConfigs(resourceManager, ConfigEnvironment.SERVER, ConfigScope.SMALLEST);
} catch (Throwable e) {
Tweed.LOGGER.error("Tweed failed to load config files:");
e.printStackTrace();
}
}
});
ServerSidePacketRegistry.INSTANCE.register(REQUEST_SYNC_C2S_PACKET, (packetContext, packetByteBuf) -> {
String fileName = packetByteBuf.readString(32767);
for (ConfigFile configFile : TweedRegistry.getConfigFiles()) {
if (configFile.getName().equals(fileName)) {
if (Objects.requireNonNull(packetContext.getPlayer().getServer()).getPermissionLevel(packetContext.getPlayer().getGameProfile()) == 4) {
configFile.syncToClient((ServerPlayerEntity) packetContext.getPlayer(), packetByteBuf.readEnumConstant(ConfigEnvironment.class), packetByteBuf.readEnumConstant(ConfigScope.class), packetByteBuf.readEnumConstant(ConfigOrigin.class));
} else {
packetByteBuf.readEnumConstant(ConfigEnvironment.class);
ConfigScope scope = packetByteBuf.readEnumConstant(ConfigScope.class);
packetByteBuf.readEnumConstant(ConfigOrigin.class);
configFile.syncToClient((ServerPlayerEntity) packetContext.getPlayer(), ConfigEnvironment.SYNCED, scope, ConfigOrigin.DATAPACK);
}
break;
}
}
});
ServerSidePacketRegistry.INSTANCE.register(TWEED_CLOTH_SYNC_C2S_PACKET, ((packetContext, packetByteBuf) -> {
String fileName = packetByteBuf.readString(32767);
for (ConfigFile configFile : TweedRegistry.getConfigFiles()) {
if (configFile.getName().equals(fileName)) {
if (Objects.requireNonNull(packetContext.getPlayer().getServer()).getPermissionLevel(packetContext.getPlayer().getGameProfile()) == 4) {
ConfigEnvironment environment = packetByteBuf.readEnumConstant(ConfigEnvironment.class);
ConfigScope scope = packetByteBuf.readEnumConstant(ConfigScope.class);
configFile.read(packetByteBuf, environment, ConfigScope.SMALLEST, ConfigOrigin.MAIN);
ConfigLoader.updateMainConfigFile(configFile, environment, scope);
} else {
packetByteBuf.clear();
}
break;
}
}
}));
}
Aggregations