Skip to content

Commit

Permalink
Use split source sets and refactor materials
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Nov 21, 2022
1 parent 51ba28a commit 7713aa2
Show file tree
Hide file tree
Showing 199 changed files with 3,885 additions and 2,863 deletions.
19 changes: 14 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ processResources {
}
}

loom {
splitEnvironmentSourceSets()
}

sourceSets {
main {
java {
Expand All @@ -271,23 +275,28 @@ sourceSets {
}
}
datagen {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
compileClasspath += main.output
runtimeClasspath += main.output
compileClasspath += client.compileClasspath
runtimeClasspath += client.runtimeClasspath
compileClasspath += client.output
runtimeClasspath += client.output
}
}

loom {
accessWidenerPath = file("src/main/resources/modern_industrialization.accesswidener")
mods {
moderndynamics {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
runs {
autoTestServer {
server()
name = "Autotest Server"
vmArg "-Dmodern_industrialization.autoTest"

ideConfigGenerated = true
source sourceSets.main
}
datagenClient {
client()
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ pluginManagement {
gradlePluginPortal()
}
}

rootProject.name = "Modern-Industrialization"
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,23 @@
import aztech.modern_industrialization.blocks.storage.barrel.client.CreativeBarrelClientSetup;
import aztech.modern_industrialization.blocks.storage.tank.creativetank.CreativeTankClientSetup;
import aztech.modern_industrialization.client.model.MachineModelLoader;
import aztech.modern_industrialization.inventory.ConfigurableInventoryPacketHandlers;
import aztech.modern_industrialization.inventory.ConfigurableInventoryPackets;
import aztech.modern_industrialization.inventory.ConfigurableInventoryS2CPacketHandlers;
import aztech.modern_industrialization.items.ConfigCardItem;
import aztech.modern_industrialization.items.SteamDrillItem;
import aztech.modern_industrialization.items.SteamDrillTooltipComponent;
import aztech.modern_industrialization.items.armor.ClientKeyHandler;
import aztech.modern_industrialization.items.armor.HudRenderer;
import aztech.modern_industrialization.items.armor.JetpackParticleAdder;
import aztech.modern_industrialization.items.client.ClientConfigCardTooltip;
import aztech.modern_industrialization.machines.ClientMachinePackets;
import aztech.modern_industrialization.machines.MachineOverlay;
import aztech.modern_industrialization.machines.MachineOverlayClient;
import aztech.modern_industrialization.machines.MachinePackets;
import aztech.modern_industrialization.machines.components.FuelBurningComponent;
import aztech.modern_industrialization.machines.gui.MachineMenuClient;
import aztech.modern_industrialization.machines.gui.MachineScreen;
import aztech.modern_industrialization.machines.init.MultiblockMachines;
import aztech.modern_industrialization.machines.models.MachineModels;
import aztech.modern_industrialization.machines.init.MultiblockMachinesClient;
import aztech.modern_industrialization.machines.models.MachineRendering;
import aztech.modern_industrialization.machines.multiblocks.MultiblockErrorHighlight;
import aztech.modern_industrialization.misc.version.VersionEvents;
import aztech.modern_industrialization.pipes.MIPipesClient;
Expand Down Expand Up @@ -78,11 +79,11 @@ public void onInitializeClient() {
setupPackets();
CreativeTankClientSetup.setupClient();
CreativeBarrelClientSetup.setupClient();
MachineModels.init();
MachineRendering.init();
MachineModelLoader.init();
MultiblockMachines.clientInit();
MultiblockMachinesClient.clientInit();
MultiblockErrorHighlight.init();
WorldRenderEvents.BEFORE_BLOCK_OUTLINE.register(MachineOverlay::onBlockOutline);
WorldRenderEvents.BEFORE_BLOCK_OUTLINE.register(MachineOverlayClient::onBlockOutline);
(new MIPipesClient()).setupClient();
ClientKeyHandler.setup();
WorldRenderEvents.START.register(renderer -> JetpackParticleAdder.addJetpackParticles(Minecraft.getInstance()));
Expand Down Expand Up @@ -113,9 +114,9 @@ private void setupScreens() {

private void setupPackets() {
ClientPlayNetworking.registerGlobalReceiver(ConfigurableInventoryPackets.UPDATE_ITEM_SLOT,
ConfigurableInventoryPacketHandlers.S2C.UPDATE_ITEM_SLOT);
ConfigurableInventoryS2CPacketHandlers.UPDATE_ITEM_SLOT);
ClientPlayNetworking.registerGlobalReceiver(ConfigurableInventoryPackets.UPDATE_FLUID_SLOT,
ConfigurableInventoryPacketHandlers.S2C.UPDATE_FLUID_SLOT);
ConfigurableInventoryS2CPacketHandlers.UPDATE_FLUID_SLOT);
ClientPlayNetworking.registerGlobalReceiver(MachinePackets.S2C.COMPONENT_SYNC, ClientMachinePackets.ON_COMPONENT_SYNC);
}

Expand Down Expand Up @@ -153,7 +154,7 @@ private void setupTooltips() {
if (data instanceof BarrelTooltipData barrelData) {
return new BarrelTooltipComponent(barrelData);
} else if (data instanceof SteamDrillItem.SteamDrillTooltipData steamDrillData) {
return new SteamDrillItem.SteamDrillTooltipComponent(steamDrillData);
return new SteamDrillTooltipComponent(steamDrillData);
} else if (data instanceof ConfigCardItem.TooltipData configCardData) {
return new ClientConfigCardTooltip(configCardData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.client.renderer.RenderStateShard;
import net.minecraft.client.renderer.RenderType;

public class MIRenderTypes {
Expand Down Expand Up @@ -57,20 +56,20 @@ private Factory(String string, VertexFormat vertexFormat, VertexFormat.Mode mode
private static RenderType makeMachineOverlay() {
return create("machine_overlay", DefaultVertexFormat.POSITION_COLOR_NORMAL, VertexFormat.Mode.QUADS, 65536, false, true,
CompositeState.builder()
.setTransparencyState(TransparencyStateShard.TRANSLUCENT_TRANSPARENCY)
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
.setTextureState(NO_TEXTURE)
.setLightmapState(NO_LIGHTMAP)
.setShaderState(RenderStateShard.POSITION_COLOR_SHADER)
.setShaderState(POSITION_COLOR_SHADER)
.createCompositeState(false));
}

private static RenderType makeSolidHighlight() {
return create("solid_highlight", DefaultVertexFormat.POSITION_COLOR_NORMAL, VertexFormat.Mode.QUADS, 65536, false, false,
CompositeState.builder()
.setTransparencyState(TransparencyStateShard.NO_TRANSPARENCY)
.setTransparencyState(NO_TRANSPARENCY)
.setTextureState(NO_TEXTURE)
.setLightmapState(NO_LIGHTMAP)
.setShaderState(RenderStateShard.POSITION_COLOR_SHADER)
.setShaderState(POSITION_COLOR_SHADER)
.createCompositeState(false));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package aztech.modern_industrialization.client.model;

import aztech.modern_industrialization.machines.models.MachineCasing;
import aztech.modern_industrialization.machines.models.MachineCasingModel;
import aztech.modern_industrialization.machines.models.MachineModelClientData;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -100,7 +101,7 @@ public void emitItemQuads(ItemStack itemStack, Supplier<RandomSource> supplier,

private TextureAtlasSprite[] renderBase(RenderContext renderContext, MachineCasing casing, Direction facingDirection) {
// Casing
renderContext.meshConsumer().accept(casing.mcm.getMesh());
renderContext.meshConsumer().accept(MachineCasingModel.get(casing).getMesh());
// Machine overlays
var sprites = getSprites(casing);
QuadEmitter emitter = renderContext.getEmitter();
Expand Down Expand Up @@ -179,7 +180,7 @@ public boolean isCustomRenderer() {

@Override
public TextureAtlasSprite getParticleIcon() {
return baseCasing.mcm.getSideSprite();
return MachineCasingModel.get(baseCasing).getSideSprite();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import aztech.modern_industrialization.compat.rei.machines.MachineCategoryParams;
import aztech.modern_industrialization.inventory.SlotPositions;
import aztech.modern_industrialization.machines.gui.MachineScreen;
import aztech.modern_industrialization.machines.guicomponents.EnergyBar;
import aztech.modern_industrialization.machines.guicomponents.ProgressBar;
import aztech.modern_industrialization.machines.guicomponents.EnergyBarClient;
import aztech.modern_industrialization.machines.guicomponents.ProgressBarClient;
import aztech.modern_industrialization.machines.init.MachineTier;
import aztech.modern_industrialization.machines.recipe.MachineRecipe;
import aztech.modern_industrialization.util.TextHelper;
Expand Down Expand Up @@ -199,7 +199,7 @@ public void draw(MachineRecipe recipe, IRecipeSlotsView recipeSlotsView, PoseSta

var offset = getOffset();

ProgressBar.RenderHelper.renderProgress(helper, stack, offset.x, offset.y, params.progressBarParams,
ProgressBarClient.renderProgress(helper, stack, offset.x, offset.y, params.progressBarParams,
(float) (System.currentTimeMillis() / recipeMillis % 1.0));

// Draw filled energy bar
Expand All @@ -216,7 +216,7 @@ public void draw(MachineRecipe recipe, IRecipeSlotsView recipeSlotsView, PoseSta
GuiComponent.blit(stack, 0, 0, helper.getBlitOffset(), 0, 0, 16, 16, 16, 16);
}
case ELECTRIC_ONLY -> {
EnergyBar.Client.Renderer.renderEnergy(helper, stack, 0, 0, 1);
EnergyBarClient.Renderer.renderEnergy(helper, stack, 0, 0, 1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import aztech.modern_industrialization.MIIdentifier;
import aztech.modern_industrialization.machines.MachinePackets;
import aztech.modern_industrialization.machines.gui.MachineMenuClient;
import aztech.modern_industrialization.machines.guicomponents.ReiSlotLocking;
import aztech.modern_industrialization.machines.guicomponents.ReiSlotLockingClient;
import aztech.modern_industrialization.machines.recipe.MachineRecipe;
import java.util.Optional;
import java.util.function.Supplier;
Expand Down Expand Up @@ -84,7 +84,7 @@ public mezz.jei.api.recipe.RecipeType<MachineRecipe> getRecipeType() {
boolean maxTransfer, boolean doTransfer) {
if (!canApply(menu))
return helper.createInternalError();
ReiSlotLocking.Client slotLocking = menu.getComponent(ReiSlotLocking.Client.class);
ReiSlotLockingClient slotLocking = menu.getComponent(ReiSlotLockingClient.class);
if (slotLocking == null || !slotLocking.isLockingAllowed())
return helper.createInternalError();
if (doTransfer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import aztech.modern_industrialization.MITooltips;
import aztech.modern_industrialization.inventory.SlotPositions;
import aztech.modern_industrialization.machines.gui.MachineScreen;
import aztech.modern_industrialization.machines.guicomponents.EnergyBar;
import aztech.modern_industrialization.machines.guicomponents.ProgressBar;
import aztech.modern_industrialization.machines.guicomponents.EnergyBarClient;
import aztech.modern_industrialization.machines.guicomponents.ProgressBarClient;
import aztech.modern_industrialization.machines.init.MachineTier;
import aztech.modern_industrialization.util.TextHelper;
import com.mojang.blaze3d.systems.RenderSystem;
Expand Down Expand Up @@ -133,7 +133,7 @@ public List<Widget> setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle b
// Draw progress bar
double recipeMillis = recipeDisplay.getSeconds() * 1000;
widgets.add(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
ProgressBar.RenderHelper.renderProgress(helper, matrices, xoffset, yoffset, params.progressBarParams,
ProgressBarClient.renderProgress(helper, matrices, xoffset, yoffset, params.progressBarParams,
(float) (System.currentTimeMillis() / recipeMillis % 1.0));
}));

Expand All @@ -153,7 +153,7 @@ public List<Widget> setupDisplay(MachineRecipeDisplay recipeDisplay, Rectangle b
GuiComponent.blit(matrices, 0, 0, helper.getBlitOffset(), 0, 0, 16, 16, 16, 16);
}
case ELECTRIC_ONLY -> {
EnergyBar.Client.Renderer.renderEnergy(helper, matrices, 0, 0, 1);
EnergyBarClient.Renderer.renderEnergy(helper, matrices, 0, 0, 1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void registerCategories(CategoryRegistry registry) {

MultiblockRecipeCategory multiblockCategory = new MultiblockRecipeCategory();
registry.add(multiblockCategory);
// noinspection removal
registry.removePlusButton(multiblockCategory.getCategoryIdentifier());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import aztech.modern_industrialization.MIIdentifier;
import aztech.modern_industrialization.machines.MachinePackets;
import aztech.modern_industrialization.machines.gui.MachineMenuClient;
import aztech.modern_industrialization.machines.guicomponents.ReiSlotLocking;
import aztech.modern_industrialization.machines.guicomponents.ReiSlotLockingClient;
import java.util.List;
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
import me.shedaniel.rei.api.client.registry.transfer.TransferHandler;
Expand All @@ -51,7 +51,7 @@ public class SlotLockingHandler implements TransferHandler {
MachineMenuClient handler = (MachineMenuClient) context.getMenu();
if (!canApply(handler, display))
return Result.createNotApplicable();
ReiSlotLocking.Client slotLocking = handler.getComponent(ReiSlotLocking.Client.class);
ReiSlotLockingClient slotLocking = handler.getComponent(ReiSlotLockingClient.class);
if (slotLocking == null || !slotLocking.isLockingAllowed())
return Result.createNotApplicable();
if (context.isActuallyCrafting()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* MIT License
*
* Copyright (c) 2020 Azercoco & Technici4n
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package aztech.modern_industrialization.inventory;

import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.Slot;

public class ConfigurableInventoryS2CPacketHandlers {
// sync id, slot id, slot tag
public static final ClientPlayNetworking.PlayChannelHandler UPDATE_ITEM_SLOT = (mc, handler, buf, sender) -> {
int syncId = buf.readInt();
int stackId = buf.readInt();
CompoundTag tag = buf.readNbt();
mc.execute(() -> {
AbstractContainerMenu sh = mc.player.containerMenu;
if (sh.containerId == syncId) {
ConfigurableScreenHandler csh = (ConfigurableScreenHandler) sh;
ConfigurableItemStack oldStack = csh.inventory.getItemStacks().get(stackId);
// update stack
ConfigurableItemStack newStack = new ConfigurableItemStack(tag);
csh.inventory.getItemStacks().set(stackId, newStack);
// update slot
for (int i = 0; i < csh.slots.size(); ++i) {
Slot slot = csh.slots.get(i);
if (slot instanceof ConfigurableItemStack.ConfigurableItemSlot is) {
if (is.getConfStack() == oldStack) {
csh.slots.set(i, newStack.new ConfigurableItemSlot(is));
return;
}
}
}
throw new RuntimeException("Could not find slot to replace!");
}
});
};
// sync id, slot id, slot tag
public static final ClientPlayNetworking.PlayChannelHandler UPDATE_FLUID_SLOT = (mc, handler, buf, sender) -> {
int syncId = buf.readInt();
int stackId = buf.readInt();
CompoundTag tag = buf.readNbt();
mc.execute(() -> {
AbstractContainerMenu sh = mc.player.containerMenu;
if (sh.containerId == syncId) {
ConfigurableScreenHandler csh = (ConfigurableScreenHandler) sh;
ConfigurableFluidStack oldStack = csh.inventory.getFluidStacks().get(stackId);
// update stack
ConfigurableFluidStack newStack = new ConfigurableFluidStack(tag);
csh.inventory.getFluidStacks().set(stackId, newStack);
// update slot
for (int i = 0; i < csh.slots.size(); ++i) {
Slot slot = csh.slots.get(i);
if (slot instanceof ConfigurableFluidStack.ConfigurableFluidSlot fs) {
if (fs.getConfStack() == oldStack) {
csh.slots.set(i, newStack.new ConfigurableFluidSlot(fs));
return;
}
}
}
throw new RuntimeException("Could not find slot to replace!");
}
});
};
}
Loading

0 comments on commit 7713aa2

Please sign in to comment.