Skip to content

Commit

Permalink
Fix build system, mod jars should work now (also fix dedicated servers)
Browse files Browse the repository at this point in the history
  • Loading branch information
FoundationGames committed Nov 19, 2022
1 parent 936ce18 commit 23702eb
Show file tree
Hide file tree
Showing 30 changed files with 337 additions and 614 deletions.
13 changes: 0 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@ subprojects {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}

manifest {
attributes([
'Specification-Title' : project.archives_base_name,
'Specification-Vendor' : 'FoundationGames',
'Specification-Version' : project.version,
'Implementation-Title' : project.name,
'Implementation-Version' : project.version,
'Implementation-Vendor' : 'FoundationGames',
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Timestamp' : System.currentTimeMillis()
])
}
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,184 @@
package io.github.foundationgames.automobility;

import io.github.foundationgames.automobility.automobile.AutomobileComponent;
import io.github.foundationgames.automobility.automobile.AutomobileData;
import io.github.foundationgames.automobility.automobile.render.AutomobileRenderer;
import io.github.foundationgames.automobility.automobile.render.ExhaustFumesModel;
import io.github.foundationgames.automobility.automobile.render.SkidEffectModel;
import io.github.foundationgames.automobility.automobile.render.attachment.front.HarvesterFrontAttachmentModel;
import io.github.foundationgames.automobility.automobile.render.attachment.front.MobControllerFrontAttachmentModel;
import io.github.foundationgames.automobility.automobile.render.attachment.rear.BannerPostRearAttachmentModel;
import io.github.foundationgames.automobility.automobile.render.attachment.rear.BlockRearAttachmentModel;
import io.github.foundationgames.automobility.automobile.render.attachment.rear.ChestRearAttachmentModel;
import io.github.foundationgames.automobility.automobile.render.attachment.rear.GrindstoneRearAttachmentModel;
import io.github.foundationgames.automobility.automobile.render.attachment.rear.PassengerSeatRearAttachmentModel;
import io.github.foundationgames.automobility.automobile.render.attachment.rear.PlowRearAttachmentModel;
import io.github.foundationgames.automobility.automobile.render.attachment.rear.StonecutterRearAttachmentModel;
import io.github.foundationgames.automobility.automobile.render.engine.CopperEngineModel;
import io.github.foundationgames.automobility.automobile.render.engine.CreativeEngineModel;
import io.github.foundationgames.automobility.automobile.render.engine.DiamondEngineModel;
import io.github.foundationgames.automobility.automobile.render.engine.GoldEngineModel;
import io.github.foundationgames.automobility.automobile.render.engine.IronEngineModel;
import io.github.foundationgames.automobility.automobile.render.engine.StoneEngineModel;
import io.github.foundationgames.automobility.automobile.render.frame.CARRFrameModel;
import io.github.foundationgames.automobility.automobile.render.frame.MotorcarFrameModel;
import io.github.foundationgames.automobility.automobile.render.frame.PineappleFrameModel;
import io.github.foundationgames.automobility.automobile.render.frame.RickshawFrameModel;
import io.github.foundationgames.automobility.automobile.render.frame.ShoppingCartFrameModel;
import io.github.foundationgames.automobility.automobile.render.frame.StandardFrameModel;
import io.github.foundationgames.automobility.automobile.render.frame.TractorFrameModel;
import io.github.foundationgames.automobility.automobile.render.item.ItemRenderableAutomobile;
import io.github.foundationgames.automobility.automobile.render.wheel.CarriageWheelModel;
import io.github.foundationgames.automobility.automobile.render.wheel.OffRoadWheelModel;
import io.github.foundationgames.automobility.automobile.render.wheel.StandardWheelModel;
import io.github.foundationgames.automobility.automobile.render.wheel.SteelWheelModel;
import io.github.foundationgames.automobility.automobile.render.wheel.TractorWheelModel;
import io.github.foundationgames.automobility.block.AutomobilityBlocks;
import io.github.foundationgames.automobility.block.entity.render.AutomobileAssemblerBlockEntityRenderer;
import io.github.foundationgames.automobility.entity.AutomobileEntity;
import io.github.foundationgames.automobility.entity.AutomobilityEntities;
import io.github.foundationgames.automobility.entity.render.AutomobileEntityRenderer;
import io.github.foundationgames.automobility.item.AutomobileComponentItem;
import io.github.foundationgames.automobility.item.AutomobilityItems;
import io.github.foundationgames.automobility.particle.AutomobilityParticles;
import io.github.foundationgames.automobility.platform.Platform;
import io.github.foundationgames.automobility.render.AutomobilityModels;
import io.github.foundationgames.automobility.automobile.render.AutomobileModels;
import io.github.foundationgames.automobility.screen.AutoMechanicTableScreen;
import io.github.foundationgames.automobility.screen.SingleSlotScreen;
import io.github.foundationgames.automobility.sound.AutomobileSoundInstance;
import io.github.foundationgames.automobility.util.FloatFunc;
import io.github.foundationgames.automobility.util.network.ClientPackets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.client.model.Model;
import net.minecraft.client.renderer.BiomeColors;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.GrassColor;

import java.util.function.Function;

public class AutomobilityClient {
public static final BlockColor GRASS_COLOR = (state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getAverageGrassColor(world, pos) : GrassColor.get(0.5D, 1.0D);
public static final ItemColor GRASS_ITEM_COLOR = (stack, tintIndex) -> GrassColor.get(0.5D, 1.0D);

public static void init() {
AutomobilityModels.init();
AutomobilityBlocks.initClient();
AutomobilityItems.initClient();
AutomobilityEntities.initClient();
ClientPackets.initClient();
AutomobileModels.init();

//AutomobilityAssets.setup();
initBlocks();
initItems();
initEntities();
ClientPackets.initClient();

Platform.get().registerMenuScreen(Automobility.AUTO_MECHANIC_SCREEN.require(), AutoMechanicTableScreen::new);
Platform.get().registerMenuScreen(Automobility.SINGLE_SLOT_SCREEN.require(), SingleSlotScreen::new);
}

public static void initBlocks() {
Platform.get().blockRenderType(AutomobilityBlocks.LAUNCH_GEL.require(), RenderType.translucent());
Platform.get().blockRenderType(AutomobilityBlocks.AUTOMOBILE_ASSEMBLER.require(), RenderType.cutout());

Platform.get().blockEntityRenderer(AutomobilityBlocks.AUTOMOBILE_ASSEMBLER_ENTITY.require(), AutomobileAssemblerBlockEntityRenderer::new);
}

public static void initItems() {
var automobileReader = new AutomobileData();
var itemAutomobile = new ItemRenderableAutomobile(automobileReader);

Platform.get().builtinItemRenderer(AutomobilityItems.AUTOMOBILE.require(), (stack, type, pose, buffers, light, overlay) -> {
automobileReader.read(stack.getOrCreateTagElement("Automobile"));
float wheelDist = automobileReader.getFrame().model().lengthPx() / 16;
float scale = 1;
scale /= wheelDist * 0.77f;
pose.scale(scale, scale, scale);
AutomobileRenderer.render(pose, buffers, light, overlay, Minecraft.getInstance().getFrameTime(), itemAutomobile);
});
componentItemRenderer(AutomobilityItems.AUTOMOBILE_FRAME.require(),
t -> AutomobileModels.getModel(t.model().modelId()),
t -> t.model().texture(), t -> 1 / ((t.model().lengthPx() / 16) * 0.77f)
);
componentItemRenderer(AutomobilityItems.AUTOMOBILE_WHEEL.require(),
t -> AutomobileModels.getModel(t.model().modelId()),
t -> t.model().texture(), t -> 6 / t.model().radius()
);
componentItemRenderer(AutomobilityItems.AUTOMOBILE_ENGINE.require(),
t -> AutomobileModels.getModel(t.model().modelId()),
t -> t.model().texture(), t -> 1
);
componentItemRenderer(AutomobilityItems.REAR_ATTACHMENT.require(),
t -> AutomobileModels.getModel(t.model().modelId()),
t -> t.model().texture(), t -> 1
);
componentItemRenderer(AutomobilityItems.FRONT_ATTACHMENT.require(),
t -> AutomobileModels.getModel(t.model().modelId()),
t -> t.model().texture(), t -> t.model().scale()
);
}

public static <T extends AutomobileComponent<T>> void componentItemRenderer(AutomobileComponentItem<T> item, Function<T, Model> modelProvider, Function<T, ResourceLocation> textureProvider, FloatFunc<T> scaleProvider) {
Platform.get().builtinItemRenderer(item, (stack, mode, matrices, vertexConsumers, light, overlay) -> {
var component = item.getComponent(stack);
if (item.isVisible(component)) {
var model = modelProvider.apply(component);
float scale = scaleProvider.apply(component);
matrices.translate(0.5, 0, 0.5);
matrices.scale(scale, -scale, -scale);
model.renderToBuffer(matrices, vertexConsumers.getBuffer(model.renderType(textureProvider.apply(component))), light, overlay, 1, 1, 1, 1);
}
});
}

public static void initEntities() {
var libs = Platform.get();

libs.entityRenderer(AutomobilityEntities.AUTOMOBILE.require(), AutomobileEntityRenderer::new);

libs.modelLayer(StandardFrameModel.MODEL_LAYER);
libs.modelLayer(TractorFrameModel.MODEL_LAYER);
libs.modelLayer(MotorcarFrameModel.MODEL_LAYER);
libs.modelLayer(ShoppingCartFrameModel.MODEL_LAYER);
libs.modelLayer(CARRFrameModel.MODEL_LAYER);
libs.modelLayer(PineappleFrameModel.MODEL_LAYER);
libs.modelLayer(RickshawFrameModel.MODEL_LAYER);

libs.modelLayer(StandardWheelModel.MODEL_LAYER);
libs.modelLayer(OffRoadWheelModel.MODEL_LAYER);
libs.modelLayer(TractorWheelModel.MODEL_LAYER);
libs.modelLayer(CarriageWheelModel.MODEL_LAYER);
libs.modelLayer(SteelWheelModel.MODEL_LAYER);

libs.modelLayer(StoneEngineModel.MODEL_LAYER);
libs.modelLayer(IronEngineModel.MODEL_LAYER);
libs.modelLayer(CopperEngineModel.MODEL_LAYER);
libs.modelLayer(GoldEngineModel.MODEL_LAYER);
libs.modelLayer(DiamondEngineModel.MODEL_LAYER);
libs.modelLayer(CreativeEngineModel.MODEL_LAYER);

libs.modelLayer(PassengerSeatRearAttachmentModel.MODEL_LAYER);
libs.modelLayer(BlockRearAttachmentModel.MODEL_LAYER);
libs.modelLayer(GrindstoneRearAttachmentModel.MODEL_LAYER);
libs.modelLayer(StonecutterRearAttachmentModel.MODEL_LAYER);
libs.modelLayer(ChestRearAttachmentModel.MODEL_LAYER);
libs.modelLayer(BannerPostRearAttachmentModel.MODEL_LAYER);
libs.modelLayer(PlowRearAttachmentModel.MODEL_LAYER);

libs.modelLayer(MobControllerFrontAttachmentModel.MODEL_LAYER);
libs.modelLayer(HarvesterFrontAttachmentModel.MODEL_LAYER);

libs.modelLayer(SkidEffectModel.MODEL_LAYER);
libs.modelLayer(ExhaustFumesModel.MODEL_LAYER);

AutomobileEntity.engineSound = auto -> {
if (auto.getEngine().isEmpty()) {
return;
}

var client = Minecraft.getInstance();
client.getSoundManager().play(new AutomobileSoundInstance.EngineSound(client, auto));
};
AutomobileEntity.skidSound = auto -> {
var client = Minecraft.getInstance();
client.getSoundManager().play(new AutomobileSoundInstance.SkiddingSound(client, auto));
};
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
package io.github.foundationgames.automobility.automobile;

import io.github.foundationgames.automobility.Automobility;
import io.github.foundationgames.automobility.render.AutomobilityModels;
import io.github.foundationgames.automobility.sound.AutomobilitySounds;
import io.github.foundationgames.automobility.util.SimpleMapContentRegistry;
import net.minecraft.client.model.Model;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

public record AutomobileEngine(
Expand Down Expand Up @@ -130,12 +124,7 @@ public static record EngineModel(
ResourceLocation texture,
ResourceLocation modelId,
ExhaustPos ... exhausts
) {
@OnlyIn(Dist.CLIENT)
public Function<EntityRendererProvider.Context, Model> model() {
return AutomobilityModels.MODELS.get(modelId);
}
}
) {}

public static record ExhaustPos(
float x, float y, float z,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package io.github.foundationgames.automobility.automobile;

import io.github.foundationgames.automobility.Automobility;
import io.github.foundationgames.automobility.render.AutomobilityModels;
import io.github.foundationgames.automobility.util.SimpleMapContentRegistry;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraft.client.model.Model;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;

import java.util.function.Consumer;
import java.util.function.Function;

public record AutomobileFrame(
ResourceLocation id,
Expand Down Expand Up @@ -256,10 +250,5 @@ public static record FrameModel(
float enginePosUp,
float rearAttachmentPos,
float frontAttachmentPos
) {
@OnlyIn(Dist.CLIENT)
public Function<EntityRendererProvider.Context, Model> model() {
return AutomobilityModels.MODELS.get(modelId);
}
}
) {}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package io.github.foundationgames.automobility.automobile;

import io.github.foundationgames.automobility.Automobility;
import io.github.foundationgames.automobility.render.AutomobilityModels;
import io.github.foundationgames.automobility.util.SimpleMapContentRegistry;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraft.client.model.Model;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;

import java.util.function.Consumer;
import java.util.function.Function;

public record AutomobileWheel(
ResourceLocation id,
Expand Down Expand Up @@ -92,10 +86,5 @@ public static record WheelModel(
float width,
ResourceLocation texture,
ResourceLocation modelId
) {
@OnlyIn(Dist.CLIENT)
public Function<EntityRendererProvider.Context, Model> model() {
return AutomobilityModels.MODELS.get(modelId);
}
}
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@
import io.github.foundationgames.automobility.automobile.attachment.front.GrassCutterFrontAttachment;
import io.github.foundationgames.automobility.automobile.attachment.front.MobControllerFrontAttachment;
import io.github.foundationgames.automobility.entity.AutomobileEntity;
import io.github.foundationgames.automobility.render.AutomobilityModels;
import io.github.foundationgames.automobility.util.SimpleMapContentRegistry;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraft.client.model.Model;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;

import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;

public record FrontAttachmentType<T extends FrontAttachment>(
ResourceLocation id, BiFunction<FrontAttachmentType<T>, AutomobileEntity, T> constructor, FrontAttachmentModel model
Expand Down Expand Up @@ -70,10 +64,5 @@ private static <T extends FrontAttachment> FrontAttachmentType<T> register(Front
return entry;
}

public record FrontAttachmentModel(ResourceLocation texture, ResourceLocation modelId, float scale) {
@OnlyIn(Dist.CLIENT)
public Function<EntityRendererProvider.Context, Model> model() {
return AutomobilityModels.MODELS.get(modelId);
}
}
public record FrontAttachmentModel(ResourceLocation texture, ResourceLocation modelId, float scale) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@
import io.github.foundationgames.automobility.automobile.attachment.rear.RearAttachment;
import io.github.foundationgames.automobility.automobile.attachment.rear.BlockRearAttachment;
import io.github.foundationgames.automobility.entity.AutomobileEntity;
import io.github.foundationgames.automobility.render.AutomobilityModels;
import io.github.foundationgames.automobility.util.SimpleMapContentRegistry;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraft.client.model.Model;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;

import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;

public record RearAttachmentType<T extends RearAttachment>(
ResourceLocation id, BiFunction<RearAttachmentType<T>, AutomobileEntity, T> constructor, RearAttachmentModel model
Expand Down Expand Up @@ -105,10 +99,5 @@ private static <T extends RearAttachment> RearAttachmentType<T> register(RearAtt
return entry;
}

public record RearAttachmentModel(ResourceLocation texture, ResourceLocation modelId, float pivotDistPx) {
@OnlyIn(Dist.CLIENT)
public Function<EntityRendererProvider.Context, Model> model() {
return AutomobilityModels.MODELS.get(modelId);
}
}
public record RearAttachmentModel(ResourceLocation texture, ResourceLocation modelId, float pivotDistPx) {}
}
Loading

0 comments on commit 23702eb

Please sign in to comment.