mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-16 22:53:41 +01:00
facef0ddb1
- Fixed id downcasing not working properly in non-english environments #25 - Removed event subscriber annotations for mod & registry events - Added more displayable slots in the Washing JEI view - Fixed Windowed blocks referencing IBakedModel on the server - Changed stairs to use blockstate supplier - Fixed Symmetry Wand crashing when configured in the off-hand - Fixed "Hold Shift" in tooltips not being translated - Chassis now drop applied slime balls - Slime Balls are now craftable - Mechanical Belts now lock living entities in place - Blockzapper recipes can now be viewed from the uses of their ingredient materials - Configured FlexPeaters now synchronize with other players - Fixed client crash when rendering lava in a deployed schematic #15 - Made encased fans a little less expensive - Added other coral types to tree fertilizer recipe
119 lines
4.7 KiB
Java
119 lines
4.7 KiB
Java
package com.simibubi.create;
|
|
|
|
import java.util.Map;
|
|
import java.util.function.Function;
|
|
|
|
import com.simibubi.create.modules.contraptions.CachedBufferReloader;
|
|
import com.simibubi.create.modules.contraptions.receivers.EncasedFanParticleHandler;
|
|
import com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockModel;
|
|
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunModel;
|
|
import com.simibubi.create.modules.curiosities.symmetry.client.SymmetryWandModel;
|
|
import com.simibubi.create.modules.schematics.ClientSchematicLoader;
|
|
import com.simibubi.create.modules.schematics.client.SchematicAndQuillHandler;
|
|
import com.simibubi.create.modules.schematics.client.SchematicHandler;
|
|
import com.simibubi.create.modules.schematics.client.SchematicHologram;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.renderer.BlockModelShapes;
|
|
import net.minecraft.client.renderer.model.IBakedModel;
|
|
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
|
import net.minecraft.resources.IReloadableResourceManager;
|
|
import net.minecraft.resources.IResourceManager;
|
|
import net.minecraft.state.properties.BlockStateProperties;
|
|
import net.minecraft.util.ResourceLocation;
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
|
import net.minecraftforge.eventbus.api.IEventBus;
|
|
import net.minecraftforge.fml.DistExecutor;
|
|
import net.minecraftforge.fml.config.ModConfig;
|
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
|
|
|
public class CreateClient {
|
|
|
|
public static ClientSchematicLoader schematicSender;
|
|
public static SchematicHandler schematicHandler;
|
|
public static SchematicHologram schematicHologram;
|
|
public static SchematicAndQuillHandler schematicAndQuillHandler;
|
|
public static EncasedFanParticleHandler fanParticles;
|
|
|
|
public static ModConfig config;
|
|
|
|
public static void addListeners(IEventBus modEventBus) {
|
|
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
|
|
modEventBus.addListener(CreateClient::clientInit);
|
|
modEventBus.addListener(CreateClient::createConfigs);
|
|
modEventBus.addListener(CreateClient::onModelBake);
|
|
});
|
|
}
|
|
|
|
public static void clientInit(FMLClientSetupEvent event) {
|
|
schematicSender = new ClientSchematicLoader();
|
|
schematicHandler = new SchematicHandler();
|
|
schematicHologram = new SchematicHologram();
|
|
schematicAndQuillHandler = new SchematicAndQuillHandler();
|
|
fanParticles = new EncasedFanParticleHandler();
|
|
|
|
AllKeys.register();
|
|
AllContainers.registerScreenFactories();
|
|
AllTileEntities.registerRenderers();
|
|
AllItems.registerColorHandlers();
|
|
AllBlocks.registerColorHandlers();
|
|
|
|
IResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
|
|
if (resourceManager instanceof IReloadableResourceManager)
|
|
((IReloadableResourceManager) resourceManager).addReloadListener(new CachedBufferReloader());
|
|
}
|
|
|
|
public static void createConfigs(ModConfig.ModConfigEvent event) {
|
|
if (event.getConfig().getSpec() == CreateConfig.specification)
|
|
return;
|
|
|
|
config = event.getConfig();
|
|
}
|
|
|
|
public static void gameTick() {
|
|
schematicSender.tick();
|
|
schematicAndQuillHandler.tick();
|
|
schematicHandler.tick();
|
|
schematicHologram.tick();
|
|
}
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
public static void onModelBake(ModelBakeEvent event) {
|
|
Map<ResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
|
|
|
|
swapModels(modelRegistry, getItemModelLocation(AllItems.SYMMETRY_WAND),
|
|
t -> new SymmetryWandModel(t).loadPartials(event));
|
|
swapModels(modelRegistry, getItemModelLocation(AllItems.PLACEMENT_HANDGUN),
|
|
t -> new BuilderGunModel(t).loadPartials(event));
|
|
swapModels(modelRegistry,
|
|
getBlockModelLocation(AllBlocks.WINDOW_IN_A_BLOCK,
|
|
BlockModelShapes
|
|
.getPropertyMapString(AllBlocks.WINDOW_IN_A_BLOCK.get().getDefaultState().getValues())),
|
|
WindowInABlockModel::new);
|
|
swapModels(modelRegistry,
|
|
getBlockModelLocation(AllBlocks.WINDOW_IN_A_BLOCK,
|
|
BlockModelShapes.getPropertyMapString(AllBlocks.WINDOW_IN_A_BLOCK.get().getDefaultState()
|
|
.with(BlockStateProperties.WATERLOGGED, true).getValues())),
|
|
WindowInABlockModel::new);
|
|
|
|
}
|
|
|
|
protected static ModelResourceLocation getItemModelLocation(AllItems item) {
|
|
return new ModelResourceLocation(item.item.getRegistryName(), "inventory");
|
|
}
|
|
|
|
protected static ModelResourceLocation getBlockModelLocation(AllBlocks block, String suffix) {
|
|
return new ModelResourceLocation(block.block.getRegistryName(), suffix);
|
|
}
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
protected static <T extends IBakedModel> void swapModels(Map<ResourceLocation, IBakedModel> modelRegistry,
|
|
ModelResourceLocation location, Function<IBakedModel, T> factory) {
|
|
modelRegistry.put(location, factory.apply(modelRegistry.get(location)));
|
|
}
|
|
|
|
|
|
|
|
}
|