From 9870431db8fbba5645766f0e2b67eabb8d3db28f Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 16 Oct 2021 01:46:49 -0700 Subject: [PATCH] Miscellaneous refactors - Refactor custom rendered items; The renderer now creates the model instead of the other way around - Only tick wrench cog rotation and linked controller renderer if client is not paused - Move all model swapping code from CreateClient to ModelSwapper - Register client resource reload listener before initial resource reload - Use TextureStitchEvent.Post event instead of resource reload listener for filling sprites of SpriteShiftEntries - Reuse Random instance in PartialItemModelRenderer - Make all config fields final - Merge package foundation.renderState into foundation.render - Move BreakProgressHook from package foundation to foundation.block - Rename ResourceReloadHandler to ClientResourceReloadListener - Rename ProperDirectionalBlock to WrenchableDirectionalBlock --- .../com/simibubi/create/AllBlockPartials.java | 8 +- .../java/com/simibubi/create/AllItems.java | 30 ++-- src/main/java/com/simibubi/create/Create.java | 15 +- .../com/simibubi/create/CreateClient.java | 148 +++--------------- .../actors/PortableStorageInterfaceBlock.java | 4 +- .../components/fan/NozzleBlock.java | 4 +- .../structureMovement/bearing/SailBlock.java | 4 +- .../chassis/StickerBlock.java | 4 +- .../piston/MechanicalPistonHeadBlock.java | 4 +- .../piston/PistonExtensionPoleBlock.java | 4 +- .../render/LightVolumeDebugger.java | 2 +- .../fluids/pipes/BracketBlock.java | 4 +- .../goggles/IHaveGoggleInformation.java | 2 +- .../contraptions/processing/BasinRecipe.java | 4 +- .../relays/encased/EncasedCTBehaviour.java | 2 +- .../wrench/WrenchItemRenderer.java | 6 + .../contraptions/wrench/WrenchModel.java | 6 - .../client/SymmetryWandItemRenderer.java | 6 + .../symmetry/client/SymmetryWandModel.java | 6 - .../tools/ExtendoGripItemRenderer.java | 6 + .../curiosities/tools/ExtendoGripModel.java | 6 - .../tools/SandPaperItemRenderer.java | 26 +-- .../weapons/PotatoCannonItemRenderer.java | 6 + .../weapons/PotatoCannonModel.java | 6 - .../zapper/ShootableGadgetRenderHandler.java | 2 +- .../zapper/terrainzapper/WorldshaperItem.java | 4 +- .../WorldshaperItemRenderer.java | 6 + .../terrainzapper/WorldshaperModel.java | 6 - .../block/inventories/CrateBlock.java | 4 +- .../block/redstone/RedstoneContactBlock.java | 4 +- .../block/redstone/RedstoneLinkBlock.java | 4 +- .../item/LinkedControllerItemRenderer.java | 9 ++ .../logistics/item/LinkedControllerModel.java | 6 - .../schematics/client/SchematicHandler.java | 2 +- .../schematics/client/SchematicRenderer.java | 2 +- .../schematics/client/tools/DeployTool.java | 2 +- .../schematics/client/tools/FlipTool.java | 2 +- .../client/tools/ISchematicTool.java | 2 +- .../client/tools/PlacementToolBase.java | 2 +- .../schematics/client/tools/RotateTool.java | 2 +- .../client/tools/SchematicToolBase.java | 2 +- .../simibubi/create/events/ClientEvents.java | 12 +- ...java => ClientResourceReloadListener.java} | 8 +- .../{ => block}/BreakProgressHook.java | 2 +- ...k.java => WrenchableDirectionalBlock.java} | 4 +- .../block/render/CustomBlockModels.java | 2 +- .../block/render/SpriteShiftEntry.java | 25 ++- .../block/render/SpriteShifter.java | 29 +++- .../create/foundation/config/AllConfigs.java | 28 ++-- .../create/foundation/config/CClient.java | 59 +++---- .../create/foundation/config/CCommon.java | 2 +- .../foundation/config/CCuriosities.java | 16 +- .../create/foundation/config/CFluids.java | 12 +- .../create/foundation/config/CKinetics.java | 74 ++++----- .../create/foundation/config/CLogistics.java | 10 +- .../create/foundation/config/CRecipes.java | 24 +-- .../create/foundation/config/CSchematics.java | 20 +-- .../create/foundation/config/CServer.java | 16 +- .../create/foundation/config/CStress.java | 6 +- .../create/foundation/config/CWorldGen.java | 2 +- .../foundation/data/CreateRegistrate.java | 32 ++-- .../data/recipe/StandardRecipeGen.java | 1 - .../foundation/fluid/FluidRenderer.java | 2 +- .../item/render/CustomItemModels.java | 2 +- .../item/render/CustomRenderedItemModel.java | 30 ++-- .../CustomRenderedItemModelRenderer.java | 7 +- .../item/render/CustomRenderedItems.java | 2 +- .../item/render/PartialItemModelRenderer.java | 33 ++-- .../foundation/mixin/BreakProgressMixin.java | 2 +- .../create/foundation/ponder/PonderScene.java | 2 +- .../create/foundation/ponder/PonderUI.java | 2 +- .../create/foundation/ponder/PonderWorld.java | 2 +- .../{renderState => render}/RenderTypes.java | 2 +- .../SuperRenderTypeBuffer.java | 2 +- .../create/foundation/sound/SoundScape.java | 2 +- .../tileEntity/behaviour/ValueBox.java | 2 +- .../fluid/SmartFluidTankBehaviour.java | 8 +- .../scrollvalue/ScrollValueHandler.java | 9 +- .../foundation/utility/ModelSwapper.java | 94 +++++++++++ .../utility/ghost/GhostBlockRenderer.java | 2 +- .../foundation/utility/ghost/GhostBlocks.java | 2 +- .../utility/outliner/AABBOutline.java | 4 +- .../utility/outliner/BlockClusterOutline.java | 4 +- .../utility/outliner/ChasingAABBOutline.java | 2 +- .../utility/outliner/LineOutline.java | 2 +- .../foundation/utility/outliner/Outline.java | 4 +- .../foundation/utility/outliner/Outliner.java | 2 +- 87 files changed, 498 insertions(+), 485 deletions(-) rename src/main/java/com/simibubi/create/foundation/{ResourceReloadHandler.java => ClientResourceReloadListener.java} (67%) rename src/main/java/com/simibubi/create/foundation/{ => block}/BreakProgressHook.java (94%) rename src/main/java/com/simibubi/create/foundation/block/{ProperDirectionalBlock.java => WrenchableDirectionalBlock.java} (91%) rename src/main/java/com/simibubi/create/foundation/{renderState => render}/RenderTypes.java (98%) rename src/main/java/com/simibubi/create/foundation/{renderState => render}/SuperRenderTypeBuffer.java (98%) create mode 100644 src/main/java/com/simibubi/create/foundation/utility/ModelSwapper.java diff --git a/src/main/java/com/simibubi/create/AllBlockPartials.java b/src/main/java/com/simibubi/create/AllBlockPartials.java index caecd14a2..e1624bb5c 100644 --- a/src/main/java/com/simibubi/create/AllBlockPartials.java +++ b/src/main/java/com/simibubi/create/AllBlockPartials.java @@ -11,7 +11,6 @@ import com.simibubi.create.foundation.utility.Lang; import net.minecraft.item.DyeColor; import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; public class AllBlockPartials { @@ -145,14 +144,15 @@ public class AllBlockPartials { } private static PartialModel getEntity(String path) { - return new PartialModel(new ResourceLocation(Create.ID, "entity/" + path)); + return new PartialModel(Create.asResource("entity/" + path)); } private static PartialModel get(String path) { - return new PartialModel(new ResourceLocation(Create.ID, "block/" + path)); + return new PartialModel(Create.asResource("block/" + path)); } - public static void clientInit() { + public static void init() { // init static fields } + } diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index 5afe68f88..90a9e2030 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -21,7 +21,7 @@ import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlo import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorItem; import com.simibubi.create.content.contraptions.relays.gearbox.VerticalGearboxItem; import com.simibubi.create.content.contraptions.wrench.WrenchItem; -import com.simibubi.create.content.contraptions.wrench.WrenchModel; +import com.simibubi.create.content.contraptions.wrench.WrenchItemRenderer; import com.simibubi.create.content.curiosities.BuildersTeaItem; import com.simibubi.create.content.curiosities.ChromaticCompoundColor; import com.simibubi.create.content.curiosities.ChromaticCompoundItem; @@ -34,18 +34,18 @@ import com.simibubi.create.content.curiosities.armor.CopperBacktankItem; import com.simibubi.create.content.curiosities.armor.DivingBootsItem; import com.simibubi.create.content.curiosities.armor.DivingHelmetItem; import com.simibubi.create.content.curiosities.symmetry.SymmetryWandItem; -import com.simibubi.create.content.curiosities.symmetry.client.SymmetryWandModel; +import com.simibubi.create.content.curiosities.symmetry.client.SymmetryWandItemRenderer; import com.simibubi.create.content.curiosities.tools.BlueprintItem; import com.simibubi.create.content.curiosities.tools.ExtendoGripItem; -import com.simibubi.create.content.curiosities.tools.ExtendoGripModel; +import com.simibubi.create.content.curiosities.tools.ExtendoGripItemRenderer; import com.simibubi.create.content.curiosities.tools.SandPaperItem; -import com.simibubi.create.content.curiosities.tools.SandPaperItemRenderer.SandPaperModel; +import com.simibubi.create.content.curiosities.tools.SandPaperItemRenderer; import com.simibubi.create.content.curiosities.weapons.PotatoCannonItem; -import com.simibubi.create.content.curiosities.weapons.PotatoCannonModel; +import com.simibubi.create.content.curiosities.weapons.PotatoCannonItemRenderer; import com.simibubi.create.content.curiosities.zapper.terrainzapper.WorldshaperItem; -import com.simibubi.create.content.curiosities.zapper.terrainzapper.WorldshaperModel; +import com.simibubi.create.content.curiosities.zapper.terrainzapper.WorldshaperItemRenderer; import com.simibubi.create.content.logistics.item.LinkedControllerItem; -import com.simibubi.create.content.logistics.item.LinkedControllerModel; +import com.simibubi.create.content.logistics.item.LinkedControllerItemRenderer; import com.simibubi.create.content.logistics.item.filter.FilterItem; import com.simibubi.create.content.schematics.item.SchematicAndQuillItem; import com.simibubi.create.content.schematics.item.SchematicItem; @@ -227,19 +227,19 @@ public class AllItems { .register(); public static final ItemEntry SAND_PAPER = REGISTRATE.item("sand_paper", SandPaperItem::new) - .transform(CreateRegistrate.customRenderedItem(() -> SandPaperModel::new)) + .transform(CreateRegistrate.customRenderedItem(() -> SandPaperItemRenderer::new)) .tag(AllTags.AllItemTags.SANDPAPER.tag) .register(); public static final ItemEntry RED_SAND_PAPER = REGISTRATE.item("red_sand_paper", SandPaperItem::new) - .transform(CreateRegistrate.customRenderedItem(() -> SandPaperModel::new)) + .transform(CreateRegistrate.customRenderedItem(() -> SandPaperItemRenderer::new)) .tag(AllTags.AllItemTags.SANDPAPER.tag) .onRegister(s -> TooltipHelper.referTo(s, SAND_PAPER)) .register(); public static final ItemEntry WRENCH = REGISTRATE.item("wrench", WrenchItem::new) .properties(p -> p.stacksTo(1)) - .transform(CreateRegistrate.customRenderedItem(() -> WrenchModel::new)) + .transform(CreateRegistrate.customRenderedItem(() -> WrenchItemRenderer::new)) .model(AssetLookup.itemModelWithPartials()) .register(); @@ -264,32 +264,32 @@ public class AllItems { public static final ItemEntry LINKED_CONTROLLER = REGISTRATE.item("linked_controller", LinkedControllerItem::new) .properties(p -> p.stacksTo(1)) - .transform(CreateRegistrate.customRenderedItem(() -> LinkedControllerModel::new)) + .transform(CreateRegistrate.customRenderedItem(() -> LinkedControllerItemRenderer::new)) .model(AssetLookup.itemModelWithPartials()) .register(); public static final ItemEntry POTATO_CANNON = REGISTRATE.item("potato_cannon", PotatoCannonItem::new) .properties(p -> p.stacksTo(1)) - .transform(CreateRegistrate.customRenderedItem(() -> PotatoCannonModel::new)) + .transform(CreateRegistrate.customRenderedItem(() -> PotatoCannonItemRenderer::new)) .model(AssetLookup.itemModelWithPartials()) .register(); public static final ItemEntry EXTENDO_GRIP = REGISTRATE.item("extendo_grip", ExtendoGripItem::new) - .transform(CreateRegistrate.customRenderedItem(() -> ExtendoGripModel::new)) + .transform(CreateRegistrate.customRenderedItem(() -> ExtendoGripItemRenderer::new)) .model(AssetLookup.itemModelWithPartials()) .register(); public static final ItemEntry WAND_OF_SYMMETRY = REGISTRATE.item("wand_of_symmetry", SymmetryWandItem::new) - .transform(CreateRegistrate.customRenderedItem(() -> SymmetryWandModel::new)) + .transform(CreateRegistrate.customRenderedItem(() -> SymmetryWandItemRenderer::new)) .model(AssetLookup.itemModelWithPartials()) .register(); public static final ItemEntry WORLDSHAPER = REGISTRATE.item("handheld_worldshaper", WorldshaperItem::new) .properties(p -> p.rarity(Rarity.EPIC)) - .transform(CreateRegistrate.customRenderedItem(() -> WorldshaperModel::new)) + .transform(CreateRegistrate.customRenderedItem(() -> WorldshaperItemRenderer::new)) .lang("Creative Worldshaper") .model(AssetLookup.itemModelWithPartials()) .register(); diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index 1a4302196..b9d0d8609 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -80,6 +80,12 @@ public class Create { private static final NonNullLazyValue REGISTRATE = CreateRegistrate.lazy(ID); public Create() { + onCtor(); + } + + public static void onCtor() { + ModLoadingContext modLoadingContext = ModLoadingContext.get(); + AllSoundEvents.prepare(); AllBlocks.register(); AllItems.register(); @@ -92,7 +98,7 @@ public class Create { AllMovementBehaviours.register(); AllWorldFeatures.register(); AllEnchantments.register(); - AllConfigs.register(ModLoadingContext.get()); + AllConfigs.register(modLoadingContext); BlockSpoutingBehaviour.register(); ForgeMod.enableMilkFluid(); @@ -109,12 +115,13 @@ public class Create { modEventBus.addGenericListener(SoundEvent.class, AllSoundEvents::register); modEventBus.addListener(AllConfigs::onLoad); modEventBus.addListener(AllConfigs::onReload); - modEventBus.addListener(EventPriority.LOWEST, this::gatherData); + modEventBus.addListener(EventPriority.LOWEST, Create::gatherData); + forgeEventBus.addListener(EventPriority.HIGH, Create::onBiomeLoad); forgeEventBus.register(CHUNK_UTIL); DistExecutor.unsafeRunWhenOn(Dist.CLIENT, - () -> () -> CreateClient.addClientListeners(forgeEventBus, modEventBus)); + () -> () -> CreateClient.onCtorClient(modEventBus, forgeEventBus)); } public static void init(final FMLCommonSetupEvent event) { @@ -132,7 +139,7 @@ public class Create { }); } - public void gatherData(GatherDataEvent event) { + public static void gatherData(GatherDataEvent event) { DataGenerator gen = event.getGenerator(); gen.addProvider(new AllAdvancements(gen)); gen.addProvider(new LangMerger(gen)); diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 88c5b0194..b803d1794 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -1,10 +1,5 @@ package com.simibubi.create; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.content.contraptions.components.structureMovement.render.SBBContraptionManager; @@ -17,34 +12,25 @@ import com.simibubi.create.content.schematics.ClientSchematicLoader; import com.simibubi.create.content.schematics.client.SchematicAndQuillHandler; import com.simibubi.create.content.schematics.client.SchematicHandler; import com.simibubi.create.events.ClientEvents; -import com.simibubi.create.foundation.ResourceReloadHandler; -import com.simibubi.create.foundation.block.render.CustomBlockModels; +import com.simibubi.create.foundation.ClientResourceReloadListener; import com.simibubi.create.foundation.block.render.SpriteShifter; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.gui.UIRenderHelper; -import com.simibubi.create.foundation.item.render.CustomItemModels; -import com.simibubi.create.foundation.item.render.CustomRenderedItems; import com.simibubi.create.foundation.ponder.content.PonderIndex; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.render.CreateContexts; import com.simibubi.create.foundation.render.SuperByteBufferCache; +import com.simibubi.create.foundation.utility.ModelSwapper; import com.simibubi.create.foundation.utility.ghost.GhostBlocks; import com.simibubi.create.foundation.utility.outliner.Outliner; -import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.client.settings.GraphicsFanciness; -import net.minecraft.inventory.container.PlayerContainer; -import net.minecraft.item.Item; import net.minecraft.resources.IReloadableResourceManager; import net.minecraft.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ChatType; import net.minecraft.util.text.IFormattableTextComponent; import net.minecraft.util.text.StringTextComponent; @@ -52,55 +38,57 @@ import net.minecraft.util.text.TextComponentUtils; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.event.ClickEvent; import net.minecraft.util.text.event.HoverEvent; -import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.client.event.ModelRegistryEvent; -import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; public class CreateClient { - 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(); public static final SuperByteBufferCache BUFFER_CACHE = new SuperByteBufferCache(); public static final Outliner OUTLINER = new Outliner(); public static final GhostBlocks GHOST_BLOCKS = new GhostBlocks(); public static final Screen EMPTY_SCREEN = new Screen(new StringTextComponent("")) {}; + 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(); public static final ZapperRenderHandler ZAPPER_RENDER_HANDLER = new ZapperRenderHandler(); public static final PotatoCannonRenderHandler POTATO_CANNON_RENDER_HANDLER = new PotatoCannonRenderHandler(); public static final SoulPulseEffectHandler SOUL_PULSE_EFFECT_HANDLER = new SoulPulseEffectHandler(); - private static CustomBlockModels customBlockModels; - private static CustomItemModels customItemModels; - private static CustomRenderedItems customRenderedItems; - private static CasingConnectivity casingConnectivity; + public static final ClientResourceReloadListener RESOURCE_RELOAD_LISTENER = new ClientResourceReloadListener(); - public static void addClientListeners(IEventBus forgeEventBus, IEventBus modEventBus) { + public static void onCtorClient(IEventBus modEventBus, IEventBus forgeEventBus) { modEventBus.addListener(CreateClient::clientInit); - modEventBus.addListener(CreateClient::onTextureStitch); - modEventBus.addListener(CreateClient::onModelRegistry); - modEventBus.addListener(CreateClient::onModelBake); - modEventBus.addListener(AllParticleTypes::registerFactories); modEventBus.addListener(ClientEvents::loadCompleted); + modEventBus.addListener(SpriteShifter::onTextureStitchPre); + modEventBus.addListener(SpriteShifter::onTextureStitchPost); + modEventBus.addListener(AllParticleTypes::registerFactories); modEventBus.addListener(CreateContexts::flwInit); modEventBus.addListener(AllMaterialSpecs::flwInit); modEventBus.addListener(ContraptionRenderDispatcher::gatherContext); - ZAPPER_RENDER_HANDLER.register(forgeEventBus); - POTATO_CANNON_RENDER_HANDLER.register(forgeEventBus); + MODEL_SWAPPER.registerListeners(modEventBus); + + ZAPPER_RENDER_HANDLER.registerListeners(forgeEventBus); + POTATO_CANNON_RENDER_HANDLER.registerListeners(forgeEventBus); + + IResourceManager resourceManager = Minecraft.getInstance() + .getResourceManager(); + if (resourceManager instanceof IReloadableResourceManager) + ((IReloadableResourceManager) resourceManager).registerReloadListener(RESOURCE_RELOAD_LISTENER); } - public static void clientInit(FMLClientSetupEvent event) { + public static void clientInit(final FMLClientSetupEvent event) { BUFFER_CACHE.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE); BUFFER_CACHE.registerCompartment(SBBContraptionManager.CONTRAPTION, 20); BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20); AllKeys.register(); // AllFluids.assignRenderLayers(); - AllBlockPartials.clientInit(); + AllBlockPartials.init(); AllStitchedTextures.init(); PonderIndex.register(); @@ -109,102 +97,15 @@ public class CreateClient { UIRenderHelper.init(); event.enqueueWork(() -> { - IResourceManager resourceManager = Minecraft.getInstance() - .getResourceManager(); - if (resourceManager instanceof IReloadableResourceManager) - ((IReloadableResourceManager) resourceManager).registerReloadListener(new ResourceReloadHandler()); - registerLayerRenderers(Minecraft.getInstance() .getEntityRenderDispatcher()); }); } - public static void onTextureStitch(TextureStitchEvent.Pre event) { - if (!event.getMap() - .location() - .equals(PlayerContainer.BLOCK_ATLAS)) - return; - SpriteShifter.getAllTargetSprites() - .forEach(event::addSprite); - } - - public static void onModelRegistry(ModelRegistryEvent event) { - getCustomRenderedItems().foreach((item, modelFunc) -> modelFunc.apply(null) - .getModelLocations() - .forEach(ModelLoader::addSpecialModel)); - } - - public static void onModelBake(ModelBakeEvent event) { - Map modelRegistry = event.getModelRegistry(); - - getCustomBlockModels() - .foreach((block, modelFunc) -> swapModels(modelRegistry, getAllBlockStateModelLocations(block), modelFunc)); - getCustomItemModels() - .foreach((item, modelFunc) -> swapModels(modelRegistry, getItemModelLocation(item), modelFunc)); - getCustomRenderedItems().foreach((item, modelFunc) -> { - swapModels(modelRegistry, getItemModelLocation(item), m -> modelFunc.apply(m) - .loadPartials(event)); - }); - } - - protected static ModelResourceLocation getItemModelLocation(Item item) { - return new ModelResourceLocation(item.getRegistryName(), "inventory"); - } - - protected static List getAllBlockStateModelLocations(Block block) { - List models = new ArrayList<>(); - block.getStateDefinition() - .getPossibleStates() - .forEach(state -> { - models.add(getBlockModelLocation(block, BlockModelShapes.statePropertiesToString(state.getValues()))); - }); - return models; - } - - protected static ModelResourceLocation getBlockModelLocation(Block block, String suffix) { - return new ModelResourceLocation(block.getRegistryName(), suffix); - } - - protected static void swapModels(Map modelRegistry, - List locations, Function factory) { - locations.forEach(location -> { - swapModels(modelRegistry, location, factory); - }); - } - - protected static void swapModels(Map modelRegistry, - ModelResourceLocation location, Function factory) { - modelRegistry.put(location, factory.apply(modelRegistry.get(location))); - } - protected static void registerLayerRenderers(EntityRendererManager renderManager) { CopperBacktankArmorLayer.registerOnAll(renderManager); } - public static CustomItemModels getCustomItemModels() { - if (customItemModels == null) - customItemModels = new CustomItemModels(); - return customItemModels; - } - - public static CustomRenderedItems getCustomRenderedItems() { - if (customRenderedItems == null) - customRenderedItems = new CustomRenderedItems(); - return customRenderedItems; - } - - public static CustomBlockModels getCustomBlockModels() { - if (customBlockModels == null) - customBlockModels = new CustomBlockModels(); - return customBlockModels; - } - - public static CasingConnectivity getCasingConnectivity() { - if (casingConnectivity == null) - casingConnectivity = new CasingConnectivity(); - return casingConnectivity; - } - public static void invalidateRenderers() { BUFFER_CACHE.invalidate(); @@ -233,4 +134,5 @@ public class CreateClient { mc.gui.handleChat(ChatType.CHAT, text, mc.player.getUUID()); } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceBlock.java index 6d93e5c95..147ae09bf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceBlock.java @@ -5,7 +5,7 @@ import javax.annotation.ParametersAreNonnullByDefault; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; -import com.simibubi.create.foundation.block.ProperDirectionalBlock; +import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import mcp.MethodsReturnNonnullByDefault; import net.minecraft.block.Block; @@ -20,7 +20,7 @@ import net.minecraft.world.World; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public class PortableStorageInterfaceBlock extends ProperDirectionalBlock +public class PortableStorageInterfaceBlock extends WrenchableDirectionalBlock implements ITE { boolean fluids; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleBlock.java index dc943711a..f37c808c2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleBlock.java @@ -4,7 +4,7 @@ import javax.annotation.ParametersAreNonnullByDefault; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; -import com.simibubi.create.foundation.block.ProperDirectionalBlock; +import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import mcp.MethodsReturnNonnullByDefault; import net.minecraft.block.Block; @@ -24,7 +24,7 @@ import net.minecraft.world.World; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -public class NozzleBlock extends ProperDirectionalBlock { +public class NozzleBlock extends WrenchableDirectionalBlock { public NozzleBlock(Properties p_i48415_1_) { super(p_i48415_1_); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/SailBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/SailBlock.java index 73fd3b67e..75370e103 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/SailBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/SailBlock.java @@ -10,7 +10,7 @@ import javax.annotation.Nullable; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; -import com.simibubi.create.foundation.block.ProperDirectionalBlock; +import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import com.simibubi.create.foundation.utility.DyeHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.placement.IPlacementHelper; @@ -41,7 +41,7 @@ import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -public class SailBlock extends ProperDirectionalBlock { +public class SailBlock extends WrenchableDirectionalBlock { public static SailBlock frame(Properties properties) { return new SailBlock(properties, true); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerBlock.java index ba22c9f79..fab3a2e05 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerBlock.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch import com.simibubi.create.AllBlocks; import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; -import com.simibubi.create.foundation.block.ProperDirectionalBlock; +import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -25,7 +25,7 @@ import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; -public class StickerBlock extends ProperDirectionalBlock implements ITE { +public class StickerBlock extends WrenchableDirectionalBlock implements ITE { public static final BooleanProperty POWERED = BlockStateProperties.POWERED; public static final BooleanProperty EXTENDED = BlockStateProperties.EXTENDED; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonHeadBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonHeadBlock.java index ac665c58f..09678c268 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonHeadBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonHeadBlock.java @@ -5,7 +5,7 @@ import static com.simibubi.create.content.contraptions.components.structureMovem import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState; -import com.simibubi.create.foundation.block.ProperDirectionalBlock; +import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -30,7 +30,7 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; -public class MechanicalPistonHeadBlock extends ProperDirectionalBlock implements IWaterLoggable { +public class MechanicalPistonHeadBlock extends WrenchableDirectionalBlock implements IWaterLoggable { public static final EnumProperty TYPE = BlockStateProperties.PISTON_TYPE; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java index 79f82e7f4..c944cb4ec 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java @@ -10,7 +10,7 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState; import com.simibubi.create.content.contraptions.wrench.IWrenchable; -import com.simibubi.create.foundation.block.ProperDirectionalBlock; +import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import com.simibubi.create.foundation.utility.placement.IPlacementHelper; import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import com.simibubi.create.foundation.utility.placement.util.PoleHelper; @@ -44,7 +44,7 @@ import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraftforge.common.ToolType; -public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements IWrenchable, IWaterLoggable { +public class PistonExtensionPoleBlock extends WrenchableDirectionalBlock implements IWrenchable, IWaterLoggable { private static final int placementHelperId = PlacementHelpers.register(PlacementHelper.get()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/LightVolumeDebugger.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/LightVolumeDebugger.java index c495e0dbe..b63caab74 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/LightVolumeDebugger.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/LightVolumeDebugger.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; public class LightVolumeDebugger { public static void render(MatrixStack ms, SuperRenderTypeBuffer buffer) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlock.java index 9a096c2f9..588f3f620 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/BracketBlock.java @@ -7,7 +7,7 @@ import com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.content.contraptions.fluids.FluidPropagator; import com.simibubi.create.content.contraptions.relays.elementary.AbstractShaftBlock; import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock; -import com.simibubi.create.foundation.block.ProperDirectionalBlock; +import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.block.Block; @@ -19,7 +19,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.IStringSerializable; -public class BracketBlock extends ProperDirectionalBlock { +public class BracketBlock extends WrenchableDirectionalBlock { public static final BooleanProperty AXIS_ALONG_FIRST_COORDINATE = DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE; diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveGoggleInformation.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveGoggleInformation.java index b67227e94..f9a34b0eb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveGoggleInformation.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/IHaveGoggleInformation.java @@ -95,7 +95,7 @@ public interface IHaveGoggleInformation { class Format { - private NumberFormat format = NumberFormat.getNumberInstance(Locale.ROOT);; + private NumberFormat format = NumberFormat.getNumberInstance(Locale.ROOT); private Format() {} diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRecipe.java index a45124772..b7e57b5bd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRecipe.java @@ -145,9 +145,9 @@ public class BasinRecipe extends ProcessingRecipe { if (fluidsAffected) { basin.getBehaviour(SmartFluidTankBehaviour.INPUT) - .foreach(TankSegment::onFluidStackChanged); + .forEach(TankSegment::onFluidStackChanged); basin.getBehaviour(SmartFluidTankBehaviour.OUTPUT) - .foreach(TankSegment::onFluidStackChanged); + .forEach(TankSegment::onFluidStackChanged); } if (simulate) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCTBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCTBehaviour.java index 0676729fa..566a6f150 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCTBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCTBehaviour.java @@ -22,7 +22,7 @@ public class EncasedCTBehaviour extends ConnectedTextureBehaviour { Direction face) { if (isBeingBlocked(state, reader, pos, otherPos, face)) return false; - CasingConnectivity cc = CreateClient.getCasingConnectivity(); + CasingConnectivity cc = CreateClient.CASING_CONNECTIVITY; CasingConnectivity.Entry entry = cc.get(state); CasingConnectivity.Entry otherEntry = cc.get(other); if (entry == null || otherEntry == null) diff --git a/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java index 41ae4fec9..dbc677fd0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java @@ -7,6 +7,7 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollVal import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.item.ItemStack; import net.minecraft.util.math.vector.Vector3f; @@ -26,4 +27,9 @@ public class WrenchItemRenderer extends CustomRenderedItemModelRenderer { @Override - public void renderByItem(ItemStack stack, TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + protected void render(ItemStack stack, SandPaperModel model, PartialItemModelRenderer renderer, + TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); ClientPlayerEntity player = Minecraft.getInstance().player; - SandPaperModel mainModel = (SandPaperModel) itemRenderer.getModel(stack, Minecraft.getInstance().level, null); float partialTicks = AnimationTickHolder.getPartialTicks(); boolean leftHand = transformType == TransformType.FIRST_PERSON_LEFT_HAND; boolean firstPerson = leftHand || transformType == TransformType.FIRST_PERSON_RIGHT_HAND; - ms.pushPose(); - ms.translate(.5f, .5f, .5f); - CompoundNBT tag = stack.getOrCreateTag(); boolean jeiMode = tag.contains("JEI"); + ms.pushPose(); + if (tag.contains("Polishing")) { ms.pushPose(); @@ -74,22 +74,22 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer { } } - itemRenderer.render(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getOriginalModel()); + itemRenderer.render(stack, TransformType.NONE, false, ms, buffer, light, overlay, model.getOriginalModel()); ms.popPose(); } + @Override + public SandPaperModel createModel(IBakedModel originalModel) { + return new SandPaperModel(originalModel); + } + public static class SandPaperModel extends CreateCustomRenderedItemModel { public SandPaperModel(IBakedModel template) { super(template, ""); } - @Override - public ItemStackTileEntityRenderer createRenderer() { - return new SandPaperItemRenderer(); - } - } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonItemRenderer.java index 25911adbc..b4280d984 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/weapons/PotatoCannonItemRenderer.java @@ -11,6 +11,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.item.ItemStack; @@ -62,4 +63,9 @@ public class PotatoCannonItemRenderer extends CustomRenderedItemModelRenderer { +public class RedstoneLinkBlock extends WrenchableDirectionalBlock implements ITE { public static final BooleanProperty POWERED = BlockStateProperties.POWERED; public static final BooleanProperty RECEIVER = BooleanProperty.create("receiver"); diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java index b67e280e5..6ce89cff4 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java @@ -36,6 +36,10 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere } static void tick() { + if (Minecraft.getInstance() + .isPaused()) + return; + boolean active = LinkedControllerClientHandler.MODE != Mode.IDLE; equipProgress.chase(active ? 1 : 0, .2f, Chaser.EXP); equipProgress.tickChaser(); @@ -164,6 +168,11 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere ms.popPose(); } + @Override + public LinkedControllerModel createModel(IBakedModel originalModel) { + return new LinkedControllerModel(originalModel); + } + protected enum RenderType { NORMAL, LECTERN; } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java index e864ed5e5..347940f8a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java @@ -3,7 +3,6 @@ package com.simibubi.create.content.logistics.item; import com.simibubi.create.foundation.item.render.CreateCustomRenderedItemModel; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; public class LinkedControllerModel extends CreateCustomRenderedItemModel { @@ -12,9 +11,4 @@ public class LinkedControllerModel extends CreateCustomRenderedItemModel { addPartials("powered", "button"); } - @Override - public ItemStackTileEntityRenderer createRenderer() { - return new LinkedControllerItemRenderer(); - } - } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java index 305a11982..ded000796 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java @@ -16,7 +16,7 @@ import com.simibubi.create.content.schematics.packet.SchematicPlacePacket; import com.simibubi.create.content.schematics.packet.SchematicSyncPacket; import com.simibubi.create.foundation.gui.ToolSelectionScreen; import com.simibubi.create.foundation.networking.AllPackets; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.outliner.AABBOutline; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java index dc85da723..8ec5e3210 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java @@ -13,8 +13,8 @@ import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.schematics.SchematicWorld; import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.render.TileEntityRenderHelper; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java index b04dba764..7ac1bc580 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/DeployTool.java @@ -4,7 +4,7 @@ import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllKeys; import com.simibubi.create.content.schematics.client.SchematicTransformation; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.outliner.AABBOutline; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/FlipTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/FlipTool.java index 82b6b0f2f..100dd7a57 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/FlipTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/FlipTool.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.schematics.client.tools; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllSpecialTextures; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.outliner.AABBOutline; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/ISchematicTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/ISchematicTool.java index 2349dc64c..cd53c8227 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/ISchematicTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/ISchematicTool.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.schematics.client.tools; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/PlacementToolBase.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/PlacementToolBase.java index df43de4f1..d9960aac6 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/PlacementToolBase.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/PlacementToolBase.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.schematics.client.tools; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java index bc793d1ec..9287a681b 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.schematics.client.tools; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.outliner.LineOutline; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java index 9340d82a6..a9635e375 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java @@ -9,7 +9,7 @@ import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.CreateClient; import com.simibubi.create.content.schematics.client.SchematicHandler; import com.simibubi.create.content.schematics.client.SchematicTransformation; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.RaycastHelper; import com.simibubi.create.foundation.utility.RaycastHelper.PredicateTraceResult; diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index f239fc4c2..1dad6f595 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -22,7 +22,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.tra import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController; import com.simibubi.create.content.contraptions.components.turntable.TurntableHandler; import com.simibubi.create.content.contraptions.goggles.GoggleOverlayRenderer; -import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; import com.simibubi.create.content.contraptions.itemAssembly.SequencedAssemblyRecipe; import com.simibubi.create.content.contraptions.relays.belt.BeltSlicer; import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorHandler; @@ -43,7 +42,7 @@ import com.simibubi.create.foundation.item.TooltipHelper; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.LeftClickPacket; import com.simibubi.create.foundation.ponder.PonderTooltipHandler; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.sound.SoundScapes; import com.simibubi.create.foundation.tileEntity.behaviour.edgeInteraction.EdgeInteractionRenderer; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; @@ -98,10 +97,10 @@ public class ClientEvents { @SubscribeEvent public static void onTick(ClientTickEvent event) { - World world = Minecraft.getInstance().level; if (!isGameActive()) return; + World world = Minecraft.getInstance().level; if (event.phase == Phase.START) { LinkedControllerClientHandler.tick(); AirCurrent.tickClientPlayerSounds(); @@ -161,13 +160,6 @@ public class ClientEvents { CreateClient.invalidateRenderers(); AnimationTickHolder.reset(); } - - /* - * i was getting nullPointers when trying to call this during client setup, - * so i assume minecraft's language manager isn't yet fully loaded at that time. - * not sure where else to call this tho :S - */ - IHaveGoggleInformation.numberFormat.update(); } @SubscribeEvent diff --git a/src/main/java/com/simibubi/create/foundation/ResourceReloadHandler.java b/src/main/java/com/simibubi/create/foundation/ClientResourceReloadListener.java similarity index 67% rename from src/main/java/com/simibubi/create/foundation/ResourceReloadHandler.java rename to src/main/java/com/simibubi/create/foundation/ClientResourceReloadListener.java index ed9a32a7e..b8824cc96 100644 --- a/src/main/java/com/simibubi/create/foundation/ResourceReloadHandler.java +++ b/src/main/java/com/simibubi/create/foundation/ClientResourceReloadListener.java @@ -2,21 +2,19 @@ package com.simibubi.create.foundation; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; -import com.simibubi.create.foundation.block.render.SpriteShifter; import com.simibubi.create.foundation.sound.SoundScapes; import com.simibubi.create.foundation.utility.ISimpleReloadListener; import net.minecraft.profiler.IProfiler; import net.minecraft.resources.IResourceManager; -public class ResourceReloadHandler implements ISimpleReloadListener { +public class ClientResourceReloadListener implements ISimpleReloadListener { @Override - public void onReload(IResourceManager resourceManagerIn, IProfiler profilerIn) { - SpriteShifter.reloadUVs(); + public void onReload(IResourceManager resourceManager, IProfiler profiler) { CreateClient.invalidateRenderers(); - IHaveGoggleInformation.numberFormat.update(); SoundScapes.invalidateAll(); + IHaveGoggleInformation.numberFormat.update(); } } diff --git a/src/main/java/com/simibubi/create/foundation/BreakProgressHook.java b/src/main/java/com/simibubi/create/foundation/block/BreakProgressHook.java similarity index 94% rename from src/main/java/com/simibubi/create/foundation/BreakProgressHook.java rename to src/main/java/com/simibubi/create/foundation/block/BreakProgressHook.java index c77691c83..99d30de2c 100644 --- a/src/main/java/com/simibubi/create/foundation/BreakProgressHook.java +++ b/src/main/java/com/simibubi/create/foundation/block/BreakProgressHook.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation; +package com.simibubi.create.foundation.block; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; diff --git a/src/main/java/com/simibubi/create/foundation/block/ProperDirectionalBlock.java b/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java similarity index 91% rename from src/main/java/com/simibubi/create/foundation/block/ProperDirectionalBlock.java rename to src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java index 1d294eb84..8847e125c 100644 --- a/src/main/java/com/simibubi/create/foundation/block/ProperDirectionalBlock.java +++ b/src/main/java/com/simibubi/create/foundation/block/WrenchableDirectionalBlock.java @@ -12,9 +12,9 @@ import net.minecraft.util.Direction; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; -public class ProperDirectionalBlock extends DirectionalBlock implements IWrenchable { +public class WrenchableDirectionalBlock extends DirectionalBlock implements IWrenchable { - public ProperDirectionalBlock(Properties p_i48415_1_) { + public WrenchableDirectionalBlock(Properties p_i48415_1_) { super(p_i48415_1_); } diff --git a/src/main/java/com/simibubi/create/foundation/block/render/CustomBlockModels.java b/src/main/java/com/simibubi/create/foundation/block/render/CustomBlockModels.java index 3653f4615..f3414bc10 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/CustomBlockModels.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/CustomBlockModels.java @@ -29,7 +29,7 @@ public class CustomBlockModels { registered.add(Pair.of(entry, behaviour)); } - public void foreach(NonNullBiConsumer> consumer) { + public void forEach(NonNullBiConsumer> consumer) { loadEntriesIfMissing(); customModels.forEach(consumer); } diff --git a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java index dd5593034..1dc17a7fc 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java @@ -1,10 +1,7 @@ package com.simibubi.create.foundation.block.render; -import java.util.function.Function; - -import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.util.ResourceLocation; public class SpriteShiftEntry { @@ -18,26 +15,24 @@ public class SpriteShiftEntry { this.targetTextureLocation = targetTextureLocation; } - protected void loadTextures() { - Function textureMap = Minecraft.getInstance() - .getTextureAtlas(PlayerContainer.BLOCK_ATLAS); - original = textureMap.apply(originalTextureLocation); - target = textureMap.apply(targetTextureLocation); + public ResourceLocation getOriginalResourceLocation() { + return originalTextureLocation; } public ResourceLocation getTargetResourceLocation() { return targetTextureLocation; } + public TextureAtlasSprite getOriginal() { + return original; + } + public TextureAtlasSprite getTarget() { - if (target == null) - loadTextures(); return target; } - public TextureAtlasSprite getOriginal() { - if (original == null) - loadTextures(); - return original; + protected void loadTextures(AtlasTexture atlas) { + original = atlas.getSprite(originalTextureLocation); + target = atlas.getSprite(targetTextureLocation); } } \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java index d1e88676e..f91b80dc3 100644 --- a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java +++ b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java @@ -7,7 +7,10 @@ import java.util.stream.Collectors; import com.simibubi.create.Create; +import net.minecraft.client.renderer.texture.AtlasTexture; +import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.TextureStitchEvent; public class SpriteShifter { @@ -28,12 +31,30 @@ public class SpriteShifter { return get(Create.asResource(originalLocation), Create.asResource(targetLocation)); } - public static void reloadUVs() { - ENTRY_CACHE.values().forEach(SpriteShiftEntry::loadTextures); - } - public static List getAllTargetSprites() { return ENTRY_CACHE.values().stream().map(SpriteShiftEntry::getTargetResourceLocation).collect(Collectors.toList()); } + public static void onTextureStitchPre(TextureStitchEvent.Pre event) { + if (!event.getMap() + .location() + .equals(PlayerContainer.BLOCK_ATLAS)) + return; + + getAllTargetSprites() + .forEach(event::addSprite); + } + + public static void onTextureStitchPost(TextureStitchEvent.Post event) { + if (!event.getMap() + .location() + .equals(PlayerContainer.BLOCK_ATLAS)) + return; + + AtlasTexture atlas = event.getMap(); + for (SpriteShiftEntry entry : ENTRY_CACHE.values()) { + entry.loadTextures(atlas); + } + } + } diff --git a/src/main/java/com/simibubi/create/foundation/config/AllConfigs.java b/src/main/java/com/simibubi/create/foundation/config/AllConfigs.java index 881f37a48..e0d35d364 100644 --- a/src/main/java/com/simibubi/create/foundation/config/AllConfigs.java +++ b/src/main/java/com/simibubi/create/foundation/config/AllConfigs.java @@ -12,16 +12,19 @@ import com.simibubi.create.foundation.block.BlockStressValues; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fml.config.ModConfig.Type; public class AllConfigs { - static Map configs = new HashMap<>(); + private static final Map CONFIGS = new HashMap<>(); public static CClient CLIENT; public static CCommon COMMON; public static CServer SERVER; + public static ConfigBase byType(ModConfig.Type type) { + return CONFIGS.get(type); + } + private static T register(Supplier factory, ModConfig.Type side) { Pair specPair = new ForgeConfigSpec.Builder().configure(builder -> { T config = factory.get(); @@ -31,7 +34,7 @@ public class AllConfigs { T config = specPair.getLeft(); config.specification = specPair.getRight(); - configs.put(config, side); + CONFIGS.put(side, config); return config; } @@ -40,25 +43,24 @@ public class AllConfigs { COMMON = register(CCommon::new, ModConfig.Type.COMMON); SERVER = register(CServer::new, ModConfig.Type.SERVER); - for (Entry pair : configs.entrySet()) - context.registerConfig(pair.getValue(), pair.getKey().specification); + for (Entry pair : CONFIGS.entrySet()) + context.registerConfig(pair.getKey(), pair.getValue().specification); BlockStressValues.registerProvider(context.getActiveNamespace(), SERVER.kinetics.stressValues); } public static void onLoad(ModConfig.Loading event) { - for (Entry pair : configs.entrySet()) - if (pair.getKey().specification == event.getConfig() + for (ConfigBase config : CONFIGS.values()) + if (config.specification == event.getConfig() .getSpec()) - pair.getKey() - .onLoad(); + config.onLoad(); } public static void onReload(ModConfig.Reloading event) { - for (Entry pair : configs.entrySet()) - if (pair.getKey().specification == event.getConfig() + for (ConfigBase config : CONFIGS.values()) + if (config.specification == event.getConfig() .getSpec()) - pair.getKey() - .onReload(); + config.onReload(); } + } diff --git a/src/main/java/com/simibubi/create/foundation/config/CClient.java b/src/main/java/com/simibubi/create/foundation/config/CClient.java index a88b30df8..34822c896 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CClient.java +++ b/src/main/java/com/simibubi/create/foundation/config/CClient.java @@ -4,73 +4,73 @@ import com.simibubi.create.foundation.config.ui.ConfigAnnotations; public class CClient extends ConfigBase { - public ConfigGroup client = group(0, "client", + public final ConfigGroup client = group(0, "client", Comments.client); //no group - public ConfigBool tooltips = b(true, "enableTooltips", + public final ConfigBool tooltips = b(true, "enableTooltips", Comments.tooltips); - public ConfigBool enableOverstressedTooltip = b(true, "enableOverstressedTooltip", + public final ConfigBool enableOverstressedTooltip = b(true, "enableOverstressedTooltip", Comments.enableOverstressedTooltip); - public ConfigBool explainRenderErrors = b(false, "explainRenderErrors", + public final ConfigBool explainRenderErrors = b(false, "explainRenderErrors", Comments.explainRenderErrors); - public ConfigFloat fanParticleDensity = f(.5f, 0, 1, "fanParticleDensity", + public final ConfigFloat fanParticleDensity = f(.5f, 0, 1, "fanParticleDensity", Comments.fanParticleDensity); - public ConfigFloat filterItemRenderDistance = f(10f, 1, "filterItemRenderDistance", Comments.filterItemRenderDistance); - public ConfigBool rainbowDebug = b(true, "enableRainbowDebug", + public final ConfigFloat filterItemRenderDistance = f(10f, 1, "filterItemRenderDistance", Comments.filterItemRenderDistance); + public final ConfigBool rainbowDebug = b(true, "enableRainbowDebug", Comments.rainbowDebug); - public ConfigBool experimentalRendering = b(true, "experimentalRendering", + public final ConfigBool experimentalRendering = b(true, "experimentalRendering", Comments.experimentalRendering); - public ConfigInt maxContraptionLightVolume = i(16384, 0, Integer.MAX_VALUE, "maximumContraptionLightVolume", + public final ConfigInt maxContraptionLightVolume = i(16384, 0, Integer.MAX_VALUE, "maximumContraptionLightVolume", Comments.maxContraptionLightVolume); // no group - public ConfigInt mainMenuConfigButtonRow = i(2, 0, 4, "mainMenuConfigButtonRow", + public final ConfigInt mainMenuConfigButtonRow = i(2, 0, 4, "mainMenuConfigButtonRow", Comments.mainMenuConfigButtonRow); - public ConfigInt mainMenuConfigButtonOffsetX = i(-4, Integer.MIN_VALUE, Integer.MAX_VALUE, "mainMenuConfigButtonOffsetX", + public final ConfigInt mainMenuConfigButtonOffsetX = i(-4, Integer.MIN_VALUE, Integer.MAX_VALUE, "mainMenuConfigButtonOffsetX", Comments.mainMenuConfigButtonOffsetX); - public ConfigInt ingameMenuConfigButtonRow = i(3, 0, 5, "ingameMenuConfigButtonRow", + public final ConfigInt ingameMenuConfigButtonRow = i(3, 0, 5, "ingameMenuConfigButtonRow", Comments.ingameMenuConfigButtonRow); - public ConfigInt ingameMenuConfigButtonOffsetX = i(-4, Integer.MIN_VALUE, Integer.MAX_VALUE, "ingameMenuConfigButtonOffsetX", + public final ConfigInt ingameMenuConfigButtonOffsetX = i(-4, Integer.MIN_VALUE, Integer.MAX_VALUE, "ingameMenuConfigButtonOffsetX", Comments.ingameMenuConfigButtonOffsetX); - public ConfigBool ignoreFabulousWarning = b(false, "ignoreFabulousWarning", + public final ConfigBool ignoreFabulousWarning = b(false, "ignoreFabulousWarning", Comments.ignoreFabulousWarning); //overlay group - public ConfigGroup overlay = group(1, "goggleOverlay", + public final ConfigGroup overlay = group(1, "goggleOverlay", Comments.overlay); - public ConfigInt overlayOffsetX = i(20, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetX", + public final ConfigInt overlayOffsetX = i(20, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetX", Comments.overlayOffset); - public ConfigInt overlayOffsetY = i(0, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetY", + public final ConfigInt overlayOffsetY = i(0, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetY", Comments.overlayOffset); - public ConfigBool overlayCustomColor = b(false, "customColorsOverlay", + public final ConfigBool overlayCustomColor = b(false, "customColorsOverlay", Comments.overlayCustomColor); - public ConfigInt overlayBackgroundColor = i(0xf0_100010, Integer.MIN_VALUE, Integer.MAX_VALUE, "customBackgroundOverlay", + public final ConfigInt overlayBackgroundColor = i(0xf0_100010, Integer.MIN_VALUE, Integer.MAX_VALUE, "customBackgroundOverlay", Comments.overlayBackgroundColor); - public ConfigInt overlayBorderColorTop = i(0x50_5000ff, Integer.MIN_VALUE, Integer.MAX_VALUE, "customBorderTopOverlay", + public final ConfigInt overlayBorderColorTop = i(0x50_5000ff, Integer.MIN_VALUE, Integer.MAX_VALUE, "customBorderTopOverlay", Comments.overlayBorderColorTop); - public ConfigInt overlayBorderColorBot = i(0x50_28007f, Integer.MIN_VALUE, Integer.MAX_VALUE, "customBorderBotOverlay", + public final ConfigInt overlayBorderColorBot = i(0x50_28007f, Integer.MIN_VALUE, Integer.MAX_VALUE, "customBorderBotOverlay", Comments.overlayBorderColorBot); //placement assist group - public ConfigGroup placementAssist = group(1, "placementAssist", + public final ConfigGroup placementAssist = group(1, "placementAssist", Comments.placementAssist); - public ConfigEnum placementIndicator = e(PlacementIndicatorSetting.TEXTURE, "indicatorType", + public final ConfigEnum placementIndicator = e(PlacementIndicatorSetting.TEXTURE, "indicatorType", Comments.placementIndicator); - public ConfigFloat indicatorScale = f(1.0f, 0f, "indicatorScale", + public final ConfigFloat indicatorScale = f(1.0f, 0f, "indicatorScale", Comments.indicatorScale); //ponder group - public ConfigGroup ponder = group(1, "ponder", + public final ConfigGroup ponder = group(1, "ponder", Comments.ponder); - public ConfigBool comfyReading = b(false, "comfyReading", + public final ConfigBool comfyReading = b(false, "comfyReading", Comments.comfyReading); //sound group - public ConfigGroup sound = group(1, "sound", + public final ConfigGroup sound = group(1, "sound", Comments.sound); - public ConfigBool enableAmbientSounds = b(true, "enableAmbientSounds", + public final ConfigBool enableAmbientSounds = b(true, "enableAmbientSounds", Comments.enableAmbientSounds); - public ConfigFloat ambientVolumeCap = f(.1f, 0, 1, "ambientVolumeCap", + public final ConfigFloat ambientVolumeCap = f(.1f, 0, 1, "ambientVolumeCap", Comments.ambientVolumeCap); @Override @@ -139,4 +139,5 @@ public class CClient extends ConfigBase { static String enableAmbientSounds = "Make cogs rumble and machines clatter."; static String ambientVolumeCap = "Maximum volume modifier of Ambient noise"; } + } diff --git a/src/main/java/com/simibubi/create/foundation/config/CCommon.java b/src/main/java/com/simibubi/create/foundation/config/CCommon.java index beeb7f897..13847bc11 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CCommon.java +++ b/src/main/java/com/simibubi/create/foundation/config/CCommon.java @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.config; public class CCommon extends ConfigBase { - public CWorldGen worldGen = nested(0, CWorldGen::new, Comments.worldGen); + public final CWorldGen worldGen = nested(0, CWorldGen::new, Comments.worldGen); @Override public String getName() { diff --git a/src/main/java/com/simibubi/create/foundation/config/CCuriosities.java b/src/main/java/com/simibubi/create/foundation/config/CCuriosities.java index 24f38f7b9..14ddacd56 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CCuriosities.java +++ b/src/main/java/com/simibubi/create/foundation/config/CCuriosities.java @@ -2,14 +2,14 @@ package com.simibubi.create.foundation.config; public class CCuriosities extends ConfigBase { - public ConfigInt maxSymmetryWandRange = i(50, 10, "maxSymmetryWandRange", Comments.symmetryRange); - public ConfigInt placementAssistRange = i(12, 3, "placementAssistRange", Comments.placementRange); - public ConfigInt toolboxRange = i(10, 1, "toolboxRange", Comments.toolboxRange); - public ConfigInt airInBacktank = i(900, 1, "airInBacktank", Comments.maxAirInBacktank); - public ConfigInt enchantedBacktankCapacity = i(300, 1, "enchantedBacktankCapacity", Comments.enchantedBacktankCapacity); + public final ConfigInt maxSymmetryWandRange = i(50, 10, "maxSymmetryWandRange", Comments.symmetryRange); + public final ConfigInt placementAssistRange = i(12, 3, "placementAssistRange", Comments.placementRange); + public final ConfigInt toolboxRange = i(10, 1, "toolboxRange", Comments.toolboxRange); + public final ConfigInt airInBacktank = i(900, 1, "airInBacktank", Comments.maxAirInBacktank); + public final ConfigInt enchantedBacktankCapacity = i(300, 1, "enchantedBacktankCapacity", Comments.enchantedBacktankCapacity); - public ConfigInt maxExtendoGripActions = i(1000, 0, "maxExtendoGripActions", Comments.maxExtendoGripActions); - public ConfigInt maxPotatoCannonShots = i(200, 0, "maxPotatoCannonShots", Comments.maxPotatoCannonShots); + public final ConfigInt maxExtendoGripActions = i(1000, 0, "maxExtendoGripActions", Comments.maxExtendoGripActions); + public final ConfigInt maxPotatoCannonShots = i(200, 0, "maxPotatoCannonShots", Comments.maxPotatoCannonShots); // public ConfigInt zapperUndoLogLength = i(10, 0, "zapperUndoLogLength", Comments.zapperUndoLogLength); NYI @@ -32,7 +32,7 @@ public class CCuriosities extends ConfigBase { "Amount of free Extendo Grip actions provided by one filled Copper Backtank. Set to 0 makes Extendo Grips unbreakable"; static String maxPotatoCannonShots = "Amount of free Potato Cannon shots provided by one filled Copper Backtank. Set to 0 makes Potato Cannons unbreakable"; -// static String zapperUndoLogLength = "The maximum amount of operations, a blockzapper can remember for undoing. (0 to disable undo)"; +// static String zapperUndoLogLength = "The maximum amount of operations a blockzapper can remember for undoing. (0 to disable undo)"; } } diff --git a/src/main/java/com/simibubi/create/foundation/config/CFluids.java b/src/main/java/com/simibubi/create/foundation/config/CFluids.java index 2b56185d2..af554e15b 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CFluids.java +++ b/src/main/java/com/simibubi/create/foundation/config/CFluids.java @@ -2,15 +2,15 @@ package com.simibubi.create.foundation.config; public class CFluids extends ConfigBase { - public ConfigInt fluidTankCapacity = i(8, 1, "fluidTankCapacity", Comments.buckets, Comments.fluidTankCapacity); - public ConfigInt fluidTankMaxHeight = i(32, 1, "fluidTankMaxHeight", Comments.blocks, Comments.fluidTankMaxHeight); - public ConfigInt mechanicalPumpRange = + public final ConfigInt fluidTankCapacity = i(8, 1, "fluidTankCapacity", Comments.buckets, Comments.fluidTankCapacity); + public final ConfigInt fluidTankMaxHeight = i(32, 1, "fluidTankMaxHeight", Comments.blocks, Comments.fluidTankMaxHeight); + public final ConfigInt mechanicalPumpRange = i(16, 1, "mechanicalPumpRange", Comments.blocks, Comments.mechanicalPumpRange); - public ConfigInt hosePulleyBlockThreshold = i(10000, -1, "hosePulleyBlockThreshold", Comments.blocks, + public final ConfigInt hosePulleyBlockThreshold = i(10000, -1, "hosePulleyBlockThreshold", Comments.blocks, Comments.toDisable, Comments.hosePulleyBlockThreshold); - public ConfigBool fillInfinite = b(false, "fillInfinite", Comments.fillInfinite); - public ConfigInt hosePulleyRange = i(128, 1, "hosePulleyRange", Comments.blocks, Comments.hosePulleyRange); + public final ConfigBool fillInfinite = b(false, "fillInfinite", Comments.fillInfinite); + public final ConfigInt hosePulleyRange = i(128, 1, "hosePulleyRange", Comments.blocks, Comments.hosePulleyRange); @Override public String getName() { diff --git a/src/main/java/com/simibubi/create/foundation/config/CKinetics.java b/src/main/java/com/simibubi/create/foundation/config/CKinetics.java index 1ee7ec82c..aae9b379c 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CKinetics.java +++ b/src/main/java/com/simibubi/create/foundation/config/CKinetics.java @@ -4,51 +4,51 @@ import com.simibubi.create.foundation.config.ui.ConfigAnnotations; public class CKinetics extends ConfigBase { - public ConfigBool disableStress = b(false, "disableStress", Comments.disableStress); - public ConfigInt maxBeltLength = i(20, 5, "maxBeltLength", Comments.maxBeltLength); - public ConfigInt crushingDamage = i(4, 0, "crushingDamage", Comments.crushingDamage); - public ConfigInt maxMotorSpeed = i(256, 64, "maxMotorSpeed", Comments.rpm, Comments.maxMotorSpeed, ConfigAnnotations.RequiresRestart.BOTH.asComment()); - public ConfigInt waterWheelBaseSpeed = i(4, 1, "waterWheelBaseSpeed", Comments.rpm, Comments.waterWheelBaseSpeed); - public ConfigInt waterWheelFlowSpeed = i(4, 1, "waterWheelFlowSpeed", Comments.rpm, Comments.waterWheelFlowSpeed); - public ConfigInt furnaceEngineSpeed = i(16, 1, "furnaceEngineSpeed", Comments.rpm, Comments.furnaceEngineSpeed); - public ConfigInt maxRotationSpeed = i(256, 64, "maxRotationSpeed", Comments.rpm, Comments.maxRotationSpeed); - public ConfigEnum ignoreDeployerAttacks = + public final ConfigBool disableStress = b(false, "disableStress", Comments.disableStress); + public final ConfigInt maxBeltLength = i(20, 5, "maxBeltLength", Comments.maxBeltLength); + public final ConfigInt crushingDamage = i(4, 0, "crushingDamage", Comments.crushingDamage); + public final ConfigInt maxMotorSpeed = i(256, 64, "maxMotorSpeed", Comments.rpm, Comments.maxMotorSpeed, ConfigAnnotations.RequiresRestart.BOTH.asComment()); + public final ConfigInt waterWheelBaseSpeed = i(4, 1, "waterWheelBaseSpeed", Comments.rpm, Comments.waterWheelBaseSpeed); + public final ConfigInt waterWheelFlowSpeed = i(4, 1, "waterWheelFlowSpeed", Comments.rpm, Comments.waterWheelFlowSpeed); + public final ConfigInt furnaceEngineSpeed = i(16, 1, "furnaceEngineSpeed", Comments.rpm, Comments.furnaceEngineSpeed); + public final ConfigInt maxRotationSpeed = i(256, 64, "maxRotationSpeed", Comments.rpm, Comments.maxRotationSpeed); + public final ConfigEnum ignoreDeployerAttacks = e(DeployerAggroSetting.CREEPERS, "ignoreDeployerAttacks", Comments.ignoreDeployerAttacks); - public ConfigInt kineticValidationFrequency = + public final ConfigInt kineticValidationFrequency = i(60, 5, "kineticValidationFrequency", Comments.kineticValidationFrequency); - public ConfigFloat crankHungerMultiplier = f(.01f, 0, 1, "crankHungerMultiplier", Comments.crankHungerMultiplier); - public ConfigInt minimumWindmillSails = i(8, 0, "minimumWindmillSails", Comments.minimumWindmillSails); - public ConfigInt windmillSailsPerRPM = i(8, 1, "windmillSailsPerRPM", Comments.windmillSailsPerRPM); - public ConfigInt maxEjectorDistance = i(32, 0, "maxEjectorDistance", Comments.maxEjectorDistance); - public ConfigInt ejectorScanInterval = i(120, 10, "ejectorScanInterval", Comments.ejectorScanInterval); + public final ConfigFloat crankHungerMultiplier = f(.01f, 0, 1, "crankHungerMultiplier", Comments.crankHungerMultiplier); + public final ConfigInt minimumWindmillSails = i(8, 0, "minimumWindmillSails", Comments.minimumWindmillSails); + public final ConfigInt windmillSailsPerRPM = i(8, 1, "windmillSailsPerRPM", Comments.windmillSailsPerRPM); + public final ConfigInt maxEjectorDistance = i(32, 0, "maxEjectorDistance", Comments.maxEjectorDistance); + public final ConfigInt ejectorScanInterval = i(120, 10, "ejectorScanInterval", Comments.ejectorScanInterval); - public ConfigGroup fan = group(1, "encasedFan", "Encased Fan"); - public ConfigInt fanPushDistance = i(20, 5, "fanPushDistance", Comments.fanPushDistance); - public ConfigInt fanPullDistance = i(20, 5, "fanPullDistance", Comments.fanPullDistance); - public ConfigInt fanBlockCheckRate = i(30, 10, "fanBlockCheckRate", Comments.fanBlockCheckRate); - public ConfigInt fanRotationArgmax = i(256, 64, "fanRotationArgmax", Comments.rpm, Comments.fanRotationArgmax); - public ConfigInt generatingFanSpeed = i(4, 0, "generatingFanSpeed", Comments.rpm, Comments.generatingFanSpeed); - public ConfigInt inWorldProcessingTime = i(150, 0, "inWorldProcessingTime", Comments.inWorldProcessingTime); + public final ConfigGroup fan = group(1, "encasedFan", "Encased Fan"); + public final ConfigInt fanPushDistance = i(20, 5, "fanPushDistance", Comments.fanPushDistance); + public final ConfigInt fanPullDistance = i(20, 5, "fanPullDistance", Comments.fanPullDistance); + public final ConfigInt fanBlockCheckRate = i(30, 10, "fanBlockCheckRate", Comments.fanBlockCheckRate); + public final ConfigInt fanRotationArgmax = i(256, 64, "fanRotationArgmax", Comments.rpm, Comments.fanRotationArgmax); + public final ConfigInt generatingFanSpeed = i(4, 0, "generatingFanSpeed", Comments.rpm, Comments.generatingFanSpeed); + public final ConfigInt inWorldProcessingTime = i(150, 0, "inWorldProcessingTime", Comments.inWorldProcessingTime); - public ConfigGroup contraptions = group(1, "contraptions", "Moving Contraptions"); - public ConfigInt maxBlocksMoved = i(2048, 1, "maxBlocksMoved", Comments.maxBlocksMoved); - public ConfigInt maxChassisRange = i(16, 1, "maxChassisRange", Comments.maxChassisRange); - public ConfigInt maxPistonPoles = i(64, 1, "maxPistonPoles", Comments.maxPistonPoles); - public ConfigInt maxRopeLength = i(128, 1, "maxRopeLength", Comments.maxRopeLength); - public ConfigInt maxCartCouplingLength = i(32, 1, "maxCartCouplingLength", Comments.maxCartCouplingLength); - public ConfigEnum spawnerMovement = + public final ConfigGroup contraptions = group(1, "contraptions", "Moving Contraptions"); + public final ConfigInt maxBlocksMoved = i(2048, 1, "maxBlocksMoved", Comments.maxBlocksMoved); + public final ConfigInt maxChassisRange = i(16, 1, "maxChassisRange", Comments.maxChassisRange); + public final ConfigInt maxPistonPoles = i(64, 1, "maxPistonPoles", Comments.maxPistonPoles); + public final ConfigInt maxRopeLength = i(128, 1, "maxRopeLength", Comments.maxRopeLength); + public final ConfigInt maxCartCouplingLength = i(32, 1, "maxCartCouplingLength", Comments.maxCartCouplingLength); + public final ConfigEnum spawnerMovement = e(SpawnerMovementSetting.NO_PICKUP, "movableSpawners", Comments.spawnerMovement); - public CStress stressValues = nested(1, CStress::new, Comments.stress); + public final CStress stressValues = nested(1, CStress::new, Comments.stress); - public ConfigGroup state = group(1, "stats", Comments.stats); - public ConfigFloat mediumSpeed = f(30, 0, 4096, "mediumSpeed", Comments.rpm, Comments.mediumSpeed); - public ConfigFloat fastSpeed = f(100, 0, 65535, "fastSpeed", Comments.rpm, Comments.fastSpeed); - public ConfigFloat mediumStressImpact = + public final ConfigGroup state = group(1, "stats", Comments.stats); + public final ConfigFloat mediumSpeed = f(30, 0, 4096, "mediumSpeed", Comments.rpm, Comments.mediumSpeed); + public final ConfigFloat fastSpeed = f(100, 0, 65535, "fastSpeed", Comments.rpm, Comments.fastSpeed); + public final ConfigFloat mediumStressImpact = f(4, 0, 4096, "mediumStressImpact", Comments.su, Comments.mediumStressImpact); - public ConfigFloat highStressImpact = f(8, 0, 65535, "highStressImpact", Comments.su, Comments.highStressImpact); - public ConfigFloat mediumCapacity = f(128, 0, 4096, "mediumCapacity", Comments.su, Comments.mediumCapacity); - public ConfigFloat highCapacity = f(512, 0, 65535, "highCapacity", Comments.su, Comments.highCapacity); + public final ConfigFloat highStressImpact = f(8, 0, 65535, "highStressImpact", Comments.su, Comments.highStressImpact); + public final ConfigFloat mediumCapacity = f(128, 0, 4096, "mediumCapacity", Comments.su, Comments.mediumCapacity); + public final ConfigFloat highCapacity = f(512, 0, 65535, "highCapacity", Comments.su, Comments.highCapacity); @Override public String getName() { diff --git a/src/main/java/com/simibubi/create/foundation/config/CLogistics.java b/src/main/java/com/simibubi/create/foundation/config/CLogistics.java index 33e4333cb..8f299b039 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CLogistics.java +++ b/src/main/java/com/simibubi/create/foundation/config/CLogistics.java @@ -2,11 +2,11 @@ package com.simibubi.create.foundation.config; public class CLogistics extends ConfigBase { - public ConfigInt defaultExtractionLimit = i(64, 1, 64, "defaultExtractionLimit", Comments.defaultExtractionLimit); - public ConfigInt defaultExtractionTimer = i(8, 1, "defaultExtractionTimer", Comments.defaultExtractionTimer); - public ConfigInt psiTimeout = i(20, 1, "psiTimeout", Comments.psiTimeout); - public ConfigInt mechanicalArmRange = i(5, 1, "mechanicalArmRange", Comments.mechanicalArmRange); - public ConfigInt linkRange = i(128, 1, "linkRange", Comments.linkRange); + public final ConfigInt defaultExtractionLimit = i(64, 1, 64, "defaultExtractionLimit", Comments.defaultExtractionLimit); + public final ConfigInt defaultExtractionTimer = i(8, 1, "defaultExtractionTimer", Comments.defaultExtractionTimer); + public final ConfigInt psiTimeout = i(20, 1, "psiTimeout", Comments.psiTimeout); + public final ConfigInt mechanicalArmRange = i(5, 1, "mechanicalArmRange", Comments.mechanicalArmRange); + public final ConfigInt linkRange = i(128, 1, "linkRange", Comments.linkRange); @Override public String getName() { diff --git a/src/main/java/com/simibubi/create/foundation/config/CRecipes.java b/src/main/java/com/simibubi/create/foundation/config/CRecipes.java index 62c2407df..8175e6b68 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CRecipes.java +++ b/src/main/java/com/simibubi/create/foundation/config/CRecipes.java @@ -2,22 +2,22 @@ package com.simibubi.create.foundation.config; public class CRecipes extends ConfigBase { - public ConfigBool bulkPressing = b(false, "bulkPressing", Comments.bulkPressing); - public ConfigBool bulkCutting = b(false, "bulkCutting", Comments.bulkCutting); - public ConfigBool allowShapelessInMixer = b(true, "allowShapelessInMixer", Comments.allowShapelessInMixer); - public ConfigBool allowShapedSquareInPress = b(true, "allowShapedSquareInPress", Comments.allowShapedSquareInPress); - public ConfigBool allowRegularCraftingInCrafter = + public final ConfigBool bulkPressing = b(false, "bulkPressing", Comments.bulkPressing); + public final ConfigBool bulkCutting = b(false, "bulkCutting", Comments.bulkCutting); + public final ConfigBool allowShapelessInMixer = b(true, "allowShapelessInMixer", Comments.allowShapelessInMixer); + public final ConfigBool allowShapedSquareInPress = b(true, "allowShapedSquareInPress", Comments.allowShapedSquareInPress); + public final ConfigBool allowRegularCraftingInCrafter = b(true, "allowRegularCraftingInCrafter", Comments.allowRegularCraftingInCrafter); - public ConfigBool allowBiggerFireworksInCrafter = + public final ConfigBool allowBiggerFireworksInCrafter = b(false, "allowBiggerFireworksInCrafter", Comments.allowBiggerFireworksInCrafter); - public ConfigBool allowStonecuttingOnSaw = b(true, "allowStonecuttingOnSaw", Comments.allowStonecuttingOnSaw); - public ConfigBool allowWoodcuttingOnSaw = b(true, "allowWoodcuttingOnSaw", Comments.allowWoodcuttingOnSaw); - public ConfigBool allowCastingBySpout = b(true, "allowCastingBySpout", Comments.allowCastingBySpout); - public ConfigInt lightSourceCountForRefinedRadiance = + public final ConfigBool allowStonecuttingOnSaw = b(true, "allowStonecuttingOnSaw", Comments.allowStonecuttingOnSaw); + public final ConfigBool allowWoodcuttingOnSaw = b(true, "allowWoodcuttingOnSaw", Comments.allowWoodcuttingOnSaw); + public final ConfigBool allowCastingBySpout = b(true, "allowCastingBySpout", Comments.allowCastingBySpout); + public final ConfigInt lightSourceCountForRefinedRadiance = i(10, 1, "lightSourceCountForRefinedRadiance", Comments.refinedRadiance); - public ConfigBool enableRefinedRadianceRecipe = + public final ConfigBool enableRefinedRadianceRecipe = b(true, "enableRefinedRadianceRecipe", Comments.refinedRadianceRecipe); - public ConfigBool enableShadowSteelRecipe = b(true, "enableShadowSteelRecipe", Comments.shadowSteelRecipe); + public final ConfigBool enableShadowSteelRecipe = b(true, "enableShadowSteelRecipe", Comments.shadowSteelRecipe); @Override public String getName() { diff --git a/src/main/java/com/simibubi/create/foundation/config/CSchematics.java b/src/main/java/com/simibubi/create/foundation/config/CSchematics.java index 9745a8b84..3409a41fc 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CSchematics.java +++ b/src/main/java/com/simibubi/create/foundation/config/CSchematics.java @@ -2,19 +2,19 @@ package com.simibubi.create.foundation.config; public class CSchematics extends ConfigBase { - public ConfigBool creativePrintIncludesAir = b(false, "creativePrintIncludesAir", Comments.creativePrintIncludesAir); - public ConfigInt maxSchematics = i(10, 1, "maxSchematics", Comments.maxSchematics); - public ConfigInt maxTotalSchematicSize = i(256, 16, "maxSchematics", Comments.kb, Comments.maxSize); - public ConfigInt maxSchematicPacketSize = + public final ConfigBool creativePrintIncludesAir = b(false, "creativePrintIncludesAir", Comments.creativePrintIncludesAir); + public final ConfigInt maxSchematics = i(10, 1, "maxSchematics", Comments.maxSchematics); + public final ConfigInt maxTotalSchematicSize = i(256, 16, "maxSchematics", Comments.kb, Comments.maxSize); + public final ConfigInt maxSchematicPacketSize = i(1024, 256, 32767, "maxSchematicPacketSize", Comments.b, Comments.maxPacketSize); - public ConfigInt schematicIdleTimeout = i(600, 100, "schematicIdleTimeout", Comments.idleTimeout); + public final ConfigInt schematicIdleTimeout = i(600, 100, "schematicIdleTimeout", Comments.idleTimeout); - public ConfigGroup schematicannon = group(0, "schematicannon", "Schematicannon"); - public ConfigInt schematicannonDelay = i(10, 1, "schematicannonDelay", Comments.delay); - public ConfigInt schematicannonSkips = i(10, 1, "schematicannonSkips", Comments.skips); - public ConfigFloat schematicannonGunpowderWorth = + public final ConfigGroup schematicannon = group(0, "schematicannon", "Schematicannon"); + public final ConfigInt schematicannonDelay = i(10, 1, "schematicannonDelay", Comments.delay); + public final ConfigInt schematicannonSkips = i(10, 1, "schematicannonSkips", Comments.skips); + public final ConfigFloat schematicannonGunpowderWorth = f(20, 0, 100, "schematicannonGunpowderWorth", Comments.gunpowderWorth); - public ConfigFloat schematicannonFuelUsage = f(0.05f, 0, 100, "schematicannonFuelUsage", Comments.fuelUsage); + public final ConfigFloat schematicannonFuelUsage = f(0.05f, 0, 100, "schematicannonFuelUsage", Comments.fuelUsage); @Override public String getName() { diff --git a/src/main/java/com/simibubi/create/foundation/config/CServer.java b/src/main/java/com/simibubi/create/foundation/config/CServer.java index e5cf81cfd..6692839b6 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CServer.java +++ b/src/main/java/com/simibubi/create/foundation/config/CServer.java @@ -2,16 +2,16 @@ package com.simibubi.create.foundation.config; public class CServer extends ConfigBase { - public ConfigGroup infrastructure = group(0, "infrastructure", Comments.infrastructure); - public ConfigInt tickrateSyncTimer = + public final ConfigGroup infrastructure = group(0, "infrastructure", Comments.infrastructure); + public final ConfigInt tickrateSyncTimer = i(20, 5, "tickrateSyncTimer", "[in Ticks]", Comments.tickrateSyncTimer, Comments.tickrateSyncTimer2); - public CRecipes recipes = nested(0, CRecipes::new, Comments.recipes); - public CKinetics kinetics = nested(0, CKinetics::new, Comments.kinetics); - public CFluids fluids = nested(0, CFluids::new, Comments.fluids); - public CLogistics logistics = nested(0, CLogistics::new, Comments.logistics); - public CSchematics schematics = nested(0, CSchematics::new, Comments.schematics); - public CCuriosities curiosities = nested(0, CCuriosities::new, Comments.curiosities); + public final CRecipes recipes = nested(0, CRecipes::new, Comments.recipes); + public final CKinetics kinetics = nested(0, CKinetics::new, Comments.kinetics); + public final CFluids fluids = nested(0, CFluids::new, Comments.fluids); + public final CLogistics logistics = nested(0, CLogistics::new, Comments.logistics); + public final CSchematics schematics = nested(0, CSchematics::new, Comments.schematics); + public final CCuriosities curiosities = nested(0, CCuriosities::new, Comments.curiosities); @Override public String getName() { diff --git a/src/main/java/com/simibubi/create/foundation/config/CStress.java b/src/main/java/com/simibubi/create/foundation/config/CStress.java index 1f722d79f..037218a4f 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CStress.java +++ b/src/main/java/com/simibubi/create/foundation/config/CStress.java @@ -16,8 +16,8 @@ import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; public class CStress extends ConfigBase implements IStressValueProvider { - private Map> capacities = new HashMap<>(); - private Map> impacts = new HashMap<>(); + private final Map> capacities = new HashMap<>(); + private final Map> impacts = new HashMap<>(); @Override protected void registerAll(Builder builder) { @@ -62,12 +62,14 @@ public class CStress extends ConfigBase implements IStressValueProvider { return 0; } + @Override public boolean hasImpact(Block block) { block = redirectValues(block); ResourceLocation key = block.getRegistryName(); return getImpacts().containsKey(key); } + @Override public boolean hasCapacity(Block block) { block = redirectValues(block); ResourceLocation key = block.getRegistryName(); diff --git a/src/main/java/com/simibubi/create/foundation/config/CWorldGen.java b/src/main/java/com/simibubi/create/foundation/config/CWorldGen.java index f90afb0a0..8220e50df 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CWorldGen.java +++ b/src/main/java/com/simibubi/create/foundation/config/CWorldGen.java @@ -6,7 +6,7 @@ import net.minecraftforge.common.ForgeConfigSpec.Builder; public class CWorldGen extends ConfigBase { - public ConfigBool disable = b(false, "disableWorldGen", Comments.disable); + public final ConfigBool disable = b(false, "disableWorldGen", Comments.disable); @Override protected void registerAll(Builder builder) { diff --git a/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java b/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java index 37042954f..8f7490658 100644 --- a/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java +++ b/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java @@ -19,7 +19,7 @@ import com.simibubi.create.foundation.block.connected.CTModel; import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; import com.simibubi.create.foundation.block.render.ColoredVertexModel; import com.simibubi.create.foundation.block.render.IBlockVertexColor; -import com.simibubi.create.foundation.item.render.CustomRenderedItemModel; +import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer; import com.tterrag.registrate.AbstractRegistrate; import com.tterrag.registrate.builders.BlockBuilder; import com.tterrag.registrate.builders.Builder; @@ -36,6 +36,7 @@ import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; import net.minecraft.block.AbstractBlock.Properties; import net.minecraft.block.Block; import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; @@ -216,11 +217,14 @@ public class CreateRegistrate extends AbstractRegistrate { } public static NonNullUnaryOperator> customRenderedItem( - Supplier> func) { - return b -> b.properties(p -> p.setISTER(() -> () -> func.get() - .apply(null) - .createRenderer())) - .onRegister(entry -> onClient(() -> () -> registerCustomRenderedItem(entry, func))); + Supplier>> supplier) { + return b -> b.properties(p -> p.setISTER(() -> () -> supplier.get().get())) + .onRegister(entry -> onClient(() -> () -> { + ItemStackTileEntityRenderer ister = entry.getItemStackTileEntityRenderer(); + if (ister instanceof CustomRenderedItemModelRenderer) { + registerCustomRenderedItem(entry, (CustomRenderedItemModelRenderer) ister); + } + })); } protected static void onClient(Supplier toRun) { @@ -229,41 +233,41 @@ public class CreateRegistrate extends AbstractRegistrate { @OnlyIn(Dist.CLIENT) private static void registerCTBehviour(Block entry, ConnectedTextureBehaviour behavior) { - CreateClient.getCustomBlockModels() + CreateClient.MODEL_SWAPPER.getCustomBlockModels() .register(entry.delegate, model -> new CTModel(model, behavior)); } @OnlyIn(Dist.CLIENT) private static void registerCasingConnectivity(T entry, BiConsumer consumer) { - consumer.accept(entry, CreateClient.getCasingConnectivity()); + consumer.accept(entry, CreateClient.CASING_CONNECTIVITY); } @OnlyIn(Dist.CLIENT) private static void registerBlockVertexColor(Block entry, IBlockVertexColor colorFunc) { - CreateClient.getCustomBlockModels() + CreateClient.MODEL_SWAPPER.getCustomBlockModels() .register(entry.delegate, model -> new ColoredVertexModel(model, colorFunc)); } @OnlyIn(Dist.CLIENT) private static void registerBlockModel(Block entry, Supplier> func) { - CreateClient.getCustomBlockModels() + CreateClient.MODEL_SWAPPER.getCustomBlockModels() .register(entry.delegate, func.get()); } @OnlyIn(Dist.CLIENT) private static void registerItemModel(Item entry, Supplier> func) { - CreateClient.getCustomItemModels() + CreateClient.MODEL_SWAPPER.getCustomItemModels() .register(entry.delegate, func.get()); } @OnlyIn(Dist.CLIENT) private static void registerCustomRenderedItem(Item entry, - Supplier> func) { - CreateClient.getCustomRenderedItems() - .register(entry.delegate, func.get()); + CustomRenderedItemModelRenderer renderer) { + CreateClient.MODEL_SWAPPER.getCustomRenderedItems() + .register(entry.delegate, renderer::createModel); } } diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java index dc38069e4..6a7c376f6 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/StandardRecipeGen.java @@ -23,7 +23,6 @@ import com.simibubi.create.AllTags.AllItemTags; import com.simibubi.create.Create; import com.simibubi.create.content.AllSections; import com.simibubi.create.content.palettes.AllPaletteBlocks; -import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.I; import com.simibubi.create.foundation.utility.Lang; import com.tterrag.registrate.util.entry.BlockEntry; import com.tterrag.registrate.util.entry.ItemEntry; diff --git a/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java b/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java index d0f0d475f..7fae09669 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java @@ -6,7 +6,7 @@ import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack.Entry; import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.simibubi.create.foundation.renderState.RenderTypes; +import com.simibubi.create.foundation.render.RenderTypes; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/foundation/item/render/CustomItemModels.java b/src/main/java/com/simibubi/create/foundation/item/render/CustomItemModels.java index 8f7ed04f6..121bfa895 100644 --- a/src/main/java/com/simibubi/create/foundation/item/render/CustomItemModels.java +++ b/src/main/java/com/simibubi/create/foundation/item/render/CustomItemModels.java @@ -29,7 +29,7 @@ public class CustomItemModels { registered.add(Pair.of(entry, behaviour)); } - public void foreach(NonNullBiConsumer> consumer) { + public void forEach(NonNullBiConsumer> consumer) { loadEntriesIfMissing(); customModels.forEach(consumer); } diff --git a/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModel.java b/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModel.java index 3324b383a..fca2995ab 100644 --- a/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModel.java +++ b/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModel.java @@ -10,23 +10,21 @@ import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.ModelRotation; -import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.model.BakedModelWrapper; +import net.minecraftforge.client.model.ModelLoader; public abstract class CustomRenderedItemModel extends BakedModelWrapper { protected String namespace; protected String basePath; protected Map partials = new HashMap<>(); - protected ItemStackTileEntityRenderer renderer; public CustomRenderedItemModel(IBakedModel template, String namespace, String basePath) { super(template); this.namespace = namespace; this.basePath = basePath; - this.renderer = createRenderer(); } @Override @@ -36,7 +34,8 @@ public abstract class CustomRenderedItemModel extends BakedModelWrapper getModelLocations() { return partials.keySet().stream().map(this::getPartialModelLocation).collect(Collectors.toList()); } protected void addPartials(String... partials) { - this.partials.clear(); for (String name : partials) this.partials.put(name, null); } - public CustomRenderedItemModel loadPartials(ModelBakeEvent event) { + public void loadPartials(ModelBakeEvent event) { + ModelLoader modelLoader = event.getModelLoader(); for (String name : partials.keySet()) - partials.put(name, loadModel(event, name)); - return this; + partials.put(name, loadPartial(modelLoader, name)); } @SuppressWarnings("deprecation") - private IBakedModel loadModel(ModelBakeEvent event, String name) { - return event.getModelLoader().bake(getPartialModelLocation(name), ModelRotation.X0_Y0); + protected IBakedModel loadPartial(ModelLoader modelLoader, String name) { + return modelLoader.bake(getPartialModelLocation(name), ModelRotation.X0_Y0); } - private ResourceLocation getPartialModelLocation(String name) { + protected ResourceLocation getPartialModelLocation(String name) { return new ResourceLocation(namespace, "item/" + basePath + "/" + name); } - public IBakedModel getPartial(String name) { - return partials.get(name); - } - } diff --git a/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModelRenderer.java b/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModelRenderer.java index 9efd95ede..09885f667 100644 --- a/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModelRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/item/render/CustomRenderedItemModelRenderer.java @@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; import net.minecraft.item.ItemStack; @@ -13,9 +14,9 @@ public abstract class CustomRenderedItemModelRenderer> consumer) { loadEntriesIfMissing(); customModels.forEach(consumer); diff --git a/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java b/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java index 13be1833c..32cf9b714 100644 --- a/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java @@ -4,7 +4,7 @@ import java.util.Random; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.simibubi.create.foundation.renderState.RenderTypes; +import com.simibubi.create.foundation.render.RenderTypes; import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.client.Minecraft; @@ -20,27 +20,23 @@ import net.minecraftforge.client.model.data.IModelData; public class PartialItemModelRenderer { - static PartialItemModelRenderer instance; + private static final PartialItemModelRenderer INSTANCE = new PartialItemModelRenderer(); - ItemStack stack; - int overlay; - MatrixStack ms; - ItemCameraTransforms.TransformType transformType; - IRenderTypeBuffer buffer; + private final Random random = new Random(); - static PartialItemModelRenderer get() { - if (instance == null) - instance = new PartialItemModelRenderer(); - return instance; - } + private ItemStack stack; + private ItemCameraTransforms.TransformType transformType; + private MatrixStack ms; + private IRenderTypeBuffer buffer; + private int overlay; public static PartialItemModelRenderer of(ItemStack stack, ItemCameraTransforms.TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int overlay) { - PartialItemModelRenderer instance = get(); + PartialItemModelRenderer instance = INSTANCE; instance.stack = stack; - instance.buffer = buffer; - instance.ms = ms; instance.transformType = transformType; + instance.ms = ms; + instance.buffer = buffer; instance.overlay = overlay; return instance; } @@ -79,20 +75,19 @@ public class PartialItemModelRenderer { ms.popPose(); } - private void renderBakedItemModel(IBakedModel model, int light, MatrixStack ms, IVertexBuilder p_229114_6_) { + private void renderBakedItemModel(IBakedModel model, int light, MatrixStack ms, IVertexBuilder buffer) { ItemRenderer ir = Minecraft.getInstance() .getItemRenderer(); - Random random = new Random(); IModelData data = EmptyModelData.INSTANCE; for (Direction direction : Iterate.directions) { random.setSeed(42L); - ir.renderQuadList(ms, p_229114_6_, model.getQuads(null, direction, random, data), stack, light, + ir.renderQuadList(ms, buffer, model.getQuads(null, direction, random, data), stack, light, overlay); } random.setSeed(42L); - ir.renderQuadList(ms, p_229114_6_, model.getQuads(null, null, random, data), stack, light, overlay); + ir.renderQuadList(ms, buffer, model.getQuads(null, null, random, data), stack, light, overlay); } } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java index 1ff9b0efe..4ff137f5a 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.simibubi.create.foundation.BreakProgressHook; +import com.simibubi.create.foundation.block.BreakProgressHook; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.world.ClientWorld; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java index c6a644f22..4f2ab9a83 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java @@ -26,7 +26,7 @@ import com.simibubi.create.foundation.ponder.elements.PonderOverlayElement; import com.simibubi.create.foundation.ponder.elements.PonderSceneElement; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.ponder.instructions.HideAllInstruction; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.VecHelper; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java index 2a5584127..248104947 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java @@ -29,7 +29,7 @@ import com.simibubi.create.foundation.ponder.content.PonderTag; import com.simibubi.create.foundation.ponder.content.PonderTagScreen; import com.simibubi.create.foundation.ponder.elements.TextWindowElement; import com.simibubi.create.foundation.ponder.ui.PonderButton; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.FontHelper; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderWorld.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderWorld.java index 2bcb2ce3c..b3b1e7bd1 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderWorld.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderWorld.java @@ -14,7 +14,7 @@ import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity; import com.simibubi.create.content.schematics.SchematicWorld; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.utility.worldWrappers.WrappedClientWorld; diff --git a/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java b/src/main/java/com/simibubi/create/foundation/render/RenderTypes.java similarity index 98% rename from src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java rename to src/main/java/com/simibubi/create/foundation/render/RenderTypes.java index 761271ddb..21bf27add 100644 --- a/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java +++ b/src/main/java/com/simibubi/create/foundation/render/RenderTypes.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.renderState; +package com.simibubi.create.foundation.render; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/com/simibubi/create/foundation/renderState/SuperRenderTypeBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperRenderTypeBuffer.java similarity index 98% rename from src/main/java/com/simibubi/create/foundation/renderState/SuperRenderTypeBuffer.java rename to src/main/java/com/simibubi/create/foundation/render/SuperRenderTypeBuffer.java index 7a9224afc..f55ad3870 100644 --- a/src/main/java/com/simibubi/create/foundation/renderState/SuperRenderTypeBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperRenderTypeBuffer.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.renderState; +package com.simibubi.create.foundation.render; import java.util.SortedMap; diff --git a/src/main/java/com/simibubi/create/foundation/sound/SoundScape.java b/src/main/java/com/simibubi/create/foundation/sound/SoundScape.java index cdd7c4794..ab95e1a48 100644 --- a/src/main/java/com/simibubi/create/foundation/sound/SoundScape.java +++ b/src/main/java/com/simibubi/create/foundation/sound/SoundScape.java @@ -95,4 +95,4 @@ class SoundScape { return MathHelper.clamp(soundCount / (argMax * 10f), 0.025f, max) * distanceMultiplier; } -} \ No newline at end of file +} diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java index 5913293b5..0fd48ee01 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java @@ -3,7 +3,7 @@ package com.simibubi.create.foundation.tileEntity.behaviour; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.logistics.item.filter.FilterItem; import com.simibubi.create.foundation.gui.AllIcons; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform.Sided; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.INamedIconOptions; import com.simibubi.create.foundation.utility.Color; diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/fluid/SmartFluidTankBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/fluid/SmartFluidTankBehaviour.java index 96be1251a..f004b8529 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/fluid/SmartFluidTankBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/fluid/SmartFluidTankBehaviour.java @@ -90,7 +90,7 @@ public class SmartFluidTankBehaviour extends TileEntityBehaviour { super.initialize(); if (getWorld().isClientSide) return; - foreach(ts -> { + forEach(ts -> { ts.fluidLevel.forceNextSync(); ts.onFluidStackChanged(); }); @@ -106,7 +106,7 @@ public class SmartFluidTankBehaviour extends TileEntityBehaviour { updateFluids(); } - foreach(te -> { + forEach(te -> { LerpedFloat fluidLevel = te.getFluidLevel(); if (fluidLevel != null) fluidLevel.tickChaser(); @@ -160,7 +160,7 @@ public class SmartFluidTankBehaviour extends TileEntityBehaviour { return true; } - public void foreach(Consumer action) { + public void forEach(Consumer action) { for (TankSegment tankSegment : tanks) action.accept(tankSegment); } @@ -173,7 +173,7 @@ public class SmartFluidTankBehaviour extends TileEntityBehaviour { public void write(CompoundNBT nbt, boolean clientPacket) { super.write(nbt, clientPacket); ListNBT tanksNBT = new ListNBT(); - foreach(ts -> tanksNBT.add(ts.writeNBT())); + forEach(ts -> tanksNBT.add(ts.writeNBT())); nbt.put(getType().getName() + "Tanks", tanksNBT); } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueHandler.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueHandler.java index 9ccd62138..0f7f15667 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueHandler.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueHandler.java @@ -83,9 +83,12 @@ public class ScrollValueHandler { @OnlyIn(Dist.CLIENT) public static void tick() { - lastPassiveScroll = passiveScroll; - wrenchCog.tick(); - passiveScroll += passiveScrollDirection * 0.5; + if (!Minecraft.getInstance() + .isPaused()) { + lastPassiveScroll = passiveScroll; + wrenchCog.tick(); + passiveScroll += passiveScrollDirection * 0.5; + } } protected static void applyTo(double delta, ScrollValueBehaviour scrolling) { diff --git a/src/main/java/com/simibubi/create/foundation/utility/ModelSwapper.java b/src/main/java/com/simibubi/create/foundation/utility/ModelSwapper.java new file mode 100644 index 000000000..df5244978 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/utility/ModelSwapper.java @@ -0,0 +1,94 @@ +package com.simibubi.create.foundation.utility; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +import com.simibubi.create.foundation.block.render.CustomBlockModels; +import com.simibubi.create.foundation.item.render.CustomItemModels; +import com.simibubi.create.foundation.item.render.CustomRenderedItemModel; +import com.simibubi.create.foundation.item.render.CustomRenderedItems; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.BlockModelShapes; +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.model.ModelResourceLocation; +import net.minecraft.item.Item; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.ModelBakeEvent; +import net.minecraftforge.client.event.ModelRegistryEvent; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.eventbus.api.IEventBus; + +public class ModelSwapper { + + protected CustomBlockModels customBlockModels = new CustomBlockModels(); + protected CustomItemModels customItemModels = new CustomItemModels(); + protected CustomRenderedItems customRenderedItems = new CustomRenderedItems(); + + public CustomBlockModels getCustomBlockModels() { + return customBlockModels; + } + + public CustomItemModels getCustomItemModels() { + return customItemModels; + } + + public CustomRenderedItems getCustomRenderedItems() { + return customRenderedItems; + } + + public void onModelRegistry(ModelRegistryEvent event) { + customRenderedItems.forEach((item, modelFunc) -> modelFunc.apply(null) + .getModelLocations() + .forEach(ModelLoader::addSpecialModel)); + } + + public void onModelBake(ModelBakeEvent event) { + Map modelRegistry = event.getModelRegistry(); + + customBlockModels.forEach((block, modelFunc) -> swapModels(modelRegistry, getAllBlockStateModelLocations(block), modelFunc)); + customItemModels.forEach((item, modelFunc) -> swapModels(modelRegistry, getItemModelLocation(item), modelFunc)); + customRenderedItems.forEach((item, modelFunc) -> { + swapModels(modelRegistry, getItemModelLocation(item), m -> { + CustomRenderedItemModel swapped = modelFunc.apply(m); + swapped.loadPartials(event); + return swapped; + }); + }); + } + + public void registerListeners(IEventBus modEventBus) { + modEventBus.addListener(this::onModelRegistry); + modEventBus.addListener(this::onModelBake); + } + + public static void swapModels(Map modelRegistry, + List locations, Function factory) { + locations.forEach(location -> { + swapModels(modelRegistry, location, factory); + }); + } + + public static void swapModels(Map modelRegistry, + ModelResourceLocation location, Function factory) { + modelRegistry.put(location, factory.apply(modelRegistry.get(location))); + } + + public static List getAllBlockStateModelLocations(Block block) { + List models = new ArrayList<>(); + ResourceLocation blockRl = block.getRegistryName(); + block.getStateDefinition() + .getPossibleStates() + .forEach(state -> { + models.add(BlockModelShapes.stateToModelLocation(blockRl, state)); + }); + return models; + } + + public static ModelResourceLocation getItemModelLocation(Item item) { + return new ModelResourceLocation(item.getRegistryName(), "inventory"); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java index 96e2b4ab3..f55febbb2 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java @@ -13,7 +13,7 @@ import org.lwjgl.system.MemoryStack; import com.jozufozu.flywheel.util.VirtualEmptyModelData; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlocks.java b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlocks.java index 1ef7f0c01..240afe3a4 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlocks.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlocks.java @@ -4,7 +4,7 @@ import java.util.HashMap; import java.util.Map; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import net.minecraft.block.BlockState; import net.minecraft.util.math.MathHelper; diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/AABBOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/AABBOutline.java index 6d7998c7b..059fbbc2b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/AABBOutline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/AABBOutline.java @@ -2,8 +2,8 @@ package com.simibubi.create.foundation.utility.outliner; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.simibubi.create.foundation.renderState.RenderTypes; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.RenderTypes; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderType; diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java index d1ceb3b23..9e17f3e39 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java @@ -9,8 +9,8 @@ import java.util.Set; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllSpecialTextures; -import com.simibubi.create.foundation.renderState.RenderTypes; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.RenderTypes; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.renderer.RenderType; diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/ChasingAABBOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/ChasingAABBOutline.java index c3d2204e2..66d0140fc 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/ChasingAABBOutline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/ChasingAABBOutline.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.utility.outliner; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.MathHelper; diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/LineOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/LineOutline.java index 6085a76a6..5b16d2b66 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/LineOutline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/LineOutline.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.utility.outliner; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java index 995e3766b..22a8f86bc 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java @@ -9,8 +9,8 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack.Entry; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllSpecialTextures; -import com.simibubi.create.foundation.renderState.RenderTypes; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.RenderTypes; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.VecHelper; diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java index 64ae8334f..776663486 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java @@ -8,7 +8,7 @@ import java.util.Optional; import java.util.Set; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox; import com.simibubi.create.foundation.utility.outliner.LineOutline.EndChasingLineOutline; import com.simibubi.create.foundation.utility.outliner.Outline.OutlineParams;