2019-09-03 08:34:02 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
2020-05-23 14:02:38 +02:00
|
|
|
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
2021-02-18 19:43:22 +01:00
|
|
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
2021-08-16 00:10:35 +02:00
|
|
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.SBBContraptionManager;
|
2020-12-02 21:49:57 +01:00
|
|
|
import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivity;
|
2021-05-04 03:50:17 +02:00
|
|
|
import com.simibubi.create.content.curiosities.armor.CopperBacktankArmorLayer;
|
2021-06-27 17:46:56 +02:00
|
|
|
import com.simibubi.create.content.curiosities.bell.SoulPulseEffectHandler;
|
2021-06-26 16:32:56 +02:00
|
|
|
import com.simibubi.create.content.curiosities.weapons.PotatoCannonRenderHandler;
|
|
|
|
import com.simibubi.create.content.curiosities.zapper.ZapperRenderHandler;
|
2020-05-23 14:02:38 +02:00
|
|
|
import com.simibubi.create.content.schematics.ClientSchematicLoader;
|
|
|
|
import com.simibubi.create.content.schematics.client.SchematicAndQuillHandler;
|
|
|
|
import com.simibubi.create.content.schematics.client.SchematicHandler;
|
2021-04-06 00:05:29 +02:00
|
|
|
import com.simibubi.create.events.ClientEvents;
|
2021-10-16 10:46:49 +02:00
|
|
|
import com.simibubi.create.foundation.ClientResourceReloadListener;
|
2020-05-15 01:23:27 +02:00
|
|
|
import com.simibubi.create.foundation.block.render.SpriteShifter;
|
2021-03-25 02:27:10 +01:00
|
|
|
import com.simibubi.create.foundation.config.AllConfigs;
|
2021-03-04 12:53:24 +01:00
|
|
|
import com.simibubi.create.foundation.gui.UIRenderHelper;
|
2021-02-16 19:35:26 +01:00
|
|
|
import com.simibubi.create.foundation.ponder.content.PonderIndex;
|
|
|
|
import com.simibubi.create.foundation.ponder.elements.WorldSectionElement;
|
2021-06-23 22:19:03 +02:00
|
|
|
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
|
|
|
import com.simibubi.create.foundation.render.CreateContexts;
|
2021-01-13 21:14:01 +01:00
|
|
|
import com.simibubi.create.foundation.render.SuperByteBufferCache;
|
2021-10-16 10:46:49 +02:00
|
|
|
import com.simibubi.create.foundation.utility.ModelSwapper;
|
2021-02-16 00:48:13 +01:00
|
|
|
import com.simibubi.create.foundation.utility.ghost.GhostBlocks;
|
2020-05-15 17:13:38 +02:00
|
|
|
import com.simibubi.create.foundation.utility.outliner.Outliner;
|
2021-04-08 19:22:11 +02:00
|
|
|
|
2019-09-22 20:23:26 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2021-11-02 00:08:20 +01:00
|
|
|
import net.minecraft.client.gui.screens.Screen;
|
|
|
|
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
|
|
|
import net.minecraft.client.GraphicsStatus;
|
|
|
|
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
|
|
|
import net.minecraft.server.packs.resources.ResourceManager;
|
|
|
|
import net.minecraft.network.chat.ChatType;
|
|
|
|
import net.minecraft.network.chat.MutableComponent;
|
|
|
|
import net.minecraft.network.chat.TextComponent;
|
|
|
|
import net.minecraft.network.chat.ComponentUtils;
|
|
|
|
import net.minecraft.ChatFormatting;
|
|
|
|
import net.minecraft.network.chat.ClickEvent;
|
|
|
|
import net.minecraft.network.chat.HoverEvent;
|
2019-10-15 22:22:19 +02:00
|
|
|
import net.minecraftforge.eventbus.api.IEventBus;
|
2019-09-03 08:34:02 +02:00
|
|
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
|
|
|
|
|
|
|
public class CreateClient {
|
|
|
|
|
2021-05-23 03:00:10 +02:00
|
|
|
public static final SuperByteBufferCache BUFFER_CACHE = new SuperByteBufferCache();
|
|
|
|
public static final Outliner OUTLINER = new Outliner();
|
|
|
|
public static final GhostBlocks GHOST_BLOCKS = new GhostBlocks();
|
2021-11-02 00:08:20 +01:00
|
|
|
public static final Screen EMPTY_SCREEN = new Screen(new TextComponent("")) {};
|
2021-10-16 10:46:49 +02:00
|
|
|
public static final ModelSwapper MODEL_SWAPPER = new ModelSwapper();
|
|
|
|
public static final CasingConnectivity CASING_CONNECTIVITY = new CasingConnectivity();
|
|
|
|
|
|
|
|
public static final ClientSchematicLoader SCHEMATIC_SENDER = new ClientSchematicLoader();
|
|
|
|
public static final SchematicHandler SCHEMATIC_HANDLER = new SchematicHandler();
|
|
|
|
public static final SchematicAndQuillHandler SCHEMATIC_AND_QUILL_HANDLER = new SchematicAndQuillHandler();
|
2020-05-28 01:29:26 +02:00
|
|
|
|
2021-06-26 16:32:56 +02:00
|
|
|
public static final ZapperRenderHandler ZAPPER_RENDER_HANDLER = new ZapperRenderHandler();
|
|
|
|
public static final PotatoCannonRenderHandler POTATO_CANNON_RENDER_HANDLER = new PotatoCannonRenderHandler();
|
2021-06-27 17:46:56 +02:00
|
|
|
public static final SoulPulseEffectHandler SOUL_PULSE_EFFECT_HANDLER = new SoulPulseEffectHandler();
|
2021-06-26 16:32:56 +02:00
|
|
|
|
2021-10-16 10:46:49 +02:00
|
|
|
public static final ClientResourceReloadListener RESOURCE_RELOAD_LISTENER = new ClientResourceReloadListener();
|
2019-11-17 21:25:59 +01:00
|
|
|
|
2021-10-16 10:46:49 +02:00
|
|
|
public static void onCtorClient(IEventBus modEventBus, IEventBus forgeEventBus) {
|
2020-08-05 22:10:05 +02:00
|
|
|
modEventBus.addListener(CreateClient::clientInit);
|
2021-04-06 00:05:29 +02:00
|
|
|
modEventBus.addListener(ClientEvents::loadCompleted);
|
2021-10-16 10:46:49 +02:00
|
|
|
modEventBus.addListener(SpriteShifter::onTextureStitchPre);
|
|
|
|
modEventBus.addListener(SpriteShifter::onTextureStitchPost);
|
|
|
|
modEventBus.addListener(AllParticleTypes::registerFactories);
|
2021-06-23 22:19:03 +02:00
|
|
|
modEventBus.addListener(CreateContexts::flwInit);
|
|
|
|
modEventBus.addListener(AllMaterialSpecs::flwInit);
|
2021-07-29 04:25:25 +02:00
|
|
|
modEventBus.addListener(ContraptionRenderDispatcher::gatherContext);
|
2021-06-27 17:46:56 +02:00
|
|
|
|
2021-10-16 10:46:49 +02:00
|
|
|
MODEL_SWAPPER.registerListeners(modEventBus);
|
|
|
|
|
|
|
|
ZAPPER_RENDER_HANDLER.registerListeners(forgeEventBus);
|
|
|
|
POTATO_CANNON_RENDER_HANDLER.registerListeners(forgeEventBus);
|
|
|
|
|
2021-10-20 00:29:04 +02:00
|
|
|
Minecraft mc = Minecraft.getInstance();
|
|
|
|
|
|
|
|
// null during datagen
|
|
|
|
if (mc == null) return;
|
|
|
|
|
2021-11-02 00:08:20 +01:00
|
|
|
ResourceManager resourceManager = mc.getResourceManager();
|
|
|
|
if (resourceManager instanceof ReloadableResourceManager)
|
|
|
|
((ReloadableResourceManager) resourceManager).registerReloadListener(RESOURCE_RELOAD_LISTENER);
|
2019-10-15 22:22:19 +02:00
|
|
|
}
|
2019-10-21 23:45:16 +02:00
|
|
|
|
2021-10-16 10:46:49 +02:00
|
|
|
public static void clientInit(final FMLClientSetupEvent event) {
|
2021-05-23 03:00:10 +02:00
|
|
|
BUFFER_CACHE.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE);
|
2021-08-16 00:10:35 +02:00
|
|
|
BUFFER_CACHE.registerCompartment(SBBContraptionManager.CONTRAPTION, 20);
|
2021-05-23 03:00:10 +02:00
|
|
|
BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20);
|
2021-02-16 00:48:13 +01:00
|
|
|
|
2019-09-03 08:34:02 +02:00
|
|
|
AllKeys.register();
|
2021-05-23 03:00:10 +02:00
|
|
|
// AllFluids.assignRenderLayers();
|
2021-10-16 10:46:49 +02:00
|
|
|
AllBlockPartials.init();
|
2021-06-09 09:26:54 +02:00
|
|
|
AllStitchedTextures.init();
|
2021-05-23 03:00:10 +02:00
|
|
|
|
2021-02-16 19:35:26 +01:00
|
|
|
PonderIndex.register();
|
2021-03-04 12:53:24 +01:00
|
|
|
PonderIndex.registerTags();
|
|
|
|
|
|
|
|
UIRenderHelper.init();
|
2019-09-22 20:23:26 +02:00
|
|
|
|
2021-05-04 03:50:17 +02:00
|
|
|
event.enqueueWork(() -> {
|
2021-07-25 23:08:46 +02:00
|
|
|
registerLayerRenderers(Minecraft.getInstance()
|
|
|
|
.getEntityRenderDispatcher());
|
2021-05-04 03:50:17 +02:00
|
|
|
});
|
2019-09-03 08:34:02 +02:00
|
|
|
}
|
2020-05-28 01:29:26 +02:00
|
|
|
|
2021-11-02 00:08:20 +01:00
|
|
|
protected static void registerLayerRenderers(EntityRenderDispatcher renderManager) {
|
2021-07-25 23:08:46 +02:00
|
|
|
CopperBacktankArmorLayer.registerOnAll(renderManager);
|
|
|
|
}
|
|
|
|
|
2021-01-11 09:29:02 +01:00
|
|
|
public static void invalidateRenderers() {
|
2021-05-23 03:00:10 +02:00
|
|
|
BUFFER_CACHE.invalidate();
|
2021-03-15 23:58:41 +01:00
|
|
|
|
2021-07-29 04:25:25 +02:00
|
|
|
ContraptionRenderDispatcher.reset();
|
2021-01-11 09:29:02 +01:00
|
|
|
}
|
2021-03-25 02:27:10 +01:00
|
|
|
|
|
|
|
public static void checkGraphicsFanciness() {
|
|
|
|
Minecraft mc = Minecraft.getInstance();
|
|
|
|
if (mc.player == null)
|
|
|
|
return;
|
|
|
|
|
2021-11-02 00:08:20 +01:00
|
|
|
if (mc.options.graphicsMode != GraphicsStatus.FABULOUS)
|
2021-03-25 02:27:10 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (AllConfigs.CLIENT.ignoreFabulousWarning.get())
|
|
|
|
return;
|
|
|
|
|
2021-11-02 00:08:20 +01:00
|
|
|
MutableComponent text = ComponentUtils.wrapInSquareBrackets(new TextComponent("WARN"))
|
|
|
|
.withStyle(ChatFormatting.GOLD)
|
|
|
|
.append(new TextComponent(
|
2021-04-08 19:22:11 +02:00
|
|
|
" Some of Create's visual features will not be available while Fabulous graphics are enabled!"))
|
2021-07-15 11:32:03 +02:00
|
|
|
.withStyle(style -> style
|
2021-04-08 19:22:11 +02:00
|
|
|
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/create dismissFabulousWarning"))
|
|
|
|
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
2021-11-02 00:08:20 +01:00
|
|
|
new TextComponent("Click here to disable this warning"))));
|
2021-03-25 02:27:10 +01:00
|
|
|
|
2021-07-15 11:32:03 +02:00
|
|
|
mc.gui.handleChat(ChatType.CHAT, text, mc.player.getUUID());
|
2021-03-25 02:27:10 +01:00
|
|
|
}
|
2021-10-16 10:46:49 +02:00
|
|
|
|
2019-09-03 08:34:02 +02:00
|
|
|
}
|