Skip to content

Commit

Permalink
Update to 1.20.1
Browse files Browse the repository at this point in the history
Creative tab ordering looks janky on Forge, but is otherwise functional.

Transportation tab has been removed in vanilla. Automobility items
don't occupy any vanilla tab at the moment.
  • Loading branch information
spiralhalo committed Jun 25, 2023
1 parent dfe0b09 commit 2e026b1
Show file tree
Hide file tree
Showing 58 changed files with 415 additions and 324 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.github.foundationgames.automobility.block.AutomobilityBlocks;
import io.github.foundationgames.automobility.entity.AutomobilityEntities;
import io.github.foundationgames.automobility.item.AutomobilityItems;
import io.github.foundationgames.automobility.item.DynamicCreativeItem;
import io.github.foundationgames.automobility.particle.AutomobilityParticles;
import io.github.foundationgames.automobility.platform.Platform;
import io.github.foundationgames.automobility.recipe.AutoMechanicTableRecipe;
Expand All @@ -15,28 +16,34 @@
import io.github.foundationgames.automobility.util.InitlessConstants;
import io.github.foundationgames.automobility.util.RegistryQueue;
import io.github.foundationgames.automobility.util.network.CommonPackets;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;

import java.util.ArrayList;
import java.util.List;

public class Automobility {
public static final String MOD_ID = InitlessConstants.AUTOMOBILITY;

public static final CreativeModeTab GROUP = Platform.get().creativeTab(rl("automobility"), AUtils::createGroupIcon);
public static final CreativeModeTab PREFABS = Platform.get().creativeTab(rl("automobility_prefabs"), AUtils::createPrefabsIcon);
public static ItemGroup GROUP = new ItemGroup(rl("automobility"));
public static ItemGroup PREFABS = new ItemGroup(rl("automobility_prefabs"));

public static final TagKey<Block> SLOPES = TagKey.create(Registry.BLOCK_REGISTRY, rl("slopes"));
public static final TagKey<Block> STEEP_SLOPES = TagKey.create(Registry.BLOCK_REGISTRY, rl("steep_slopes"));
public static final TagKey<Block> NON_STEEP_SLOPES = TagKey.create(Registry.BLOCK_REGISTRY, rl("non_steep_slopes"));
public static final TagKey<Block> STICKY_SLOPES = TagKey.create(Registry.BLOCK_REGISTRY, rl("sticky_slopes"));
public static final TagKey<Block> SLOPES = TagKey.create(Registries.BLOCK, rl("slopes"));
public static final TagKey<Block> STEEP_SLOPES = TagKey.create(Registries.BLOCK, rl("steep_slopes"));
public static final TagKey<Block> NON_STEEP_SLOPES = TagKey.create(Registries.BLOCK, rl("non_steep_slopes"));
public static final TagKey<Block> STICKY_SLOPES = TagKey.create(Registries.BLOCK, rl("sticky_slopes"));

public static final Eventual<MenuType<AutoMechanicTableScreenHandler>> AUTO_MECHANIC_SCREEN =
RegistryQueue.register(Registry.MENU, Automobility.rl("auto_mechanic_table"), () -> Platform.get().menuType(AutoMechanicTableScreenHandler::new));
RegistryQueue.register(BuiltInRegistries.MENU, Automobility.rl("auto_mechanic_table"), () -> Platform.get().menuType(AutoMechanicTableScreenHandler::new));
public static final Eventual<MenuType<SingleSlotScreenHandler>> SINGLE_SLOT_SCREEN =
RegistryQueue.register(Registry.MENU, Automobility.rl("single_slot"), () -> Platform.get().menuType(SingleSlotScreenHandler::new));
RegistryQueue.register(BuiltInRegistries.MENU, Automobility.rl("single_slot"), () -> Platform.get().menuType(SingleSlotScreenHandler::new));

public static void init() {
AutomobilitySounds.init();
Expand All @@ -50,11 +57,39 @@ public static void init() {
}

public static void initOther() {
RegistryQueue.register(Registry.RECIPE_TYPE, AutoMechanicTableRecipe.ID, () -> AutoMechanicTableRecipe.TYPE);
RegistryQueue.register(Registry.RECIPE_SERIALIZER, AutoMechanicTableRecipe.ID, () -> AutoMechanicTableRecipeSerializer.INSTANCE);
RegistryQueue.register(BuiltInRegistries.RECIPE_TYPE, AutoMechanicTableRecipe.ID, () -> AutoMechanicTableRecipe.TYPE);
RegistryQueue.register(BuiltInRegistries.RECIPE_SERIALIZER, AutoMechanicTableRecipe.ID, () -> AutoMechanicTableRecipeSerializer.INSTANCE);
RegistryQueue.register(BuiltInRegistries.CREATIVE_MODE_TAB, GROUP.rl, () -> Platform.get().creativeTab(GROUP.rl, AUtils::createGroupIcon, GROUP));
RegistryQueue.register(BuiltInRegistries.CREATIVE_MODE_TAB, PREFABS.rl, () -> Platform.get().creativeTab(PREFABS.rl, AUtils::createPrefabsIcon, PREFABS));
}

public static ResourceLocation rl(String path) {
return new ResourceLocation(MOD_ID, path);
}

public static void addToItemGroup(ItemGroup group, Eventual<? extends Item> itemPromise) {
group.list.add((Eventual<Item>) itemPromise);
}

public static class ItemGroup implements CreativeModeTab.DisplayItemsGenerator {
private final List<Eventual<Item>> list = new ArrayList<>();
private final ResourceLocation rl;

private ItemGroup(ResourceLocation rl) {
this.rl = rl;
}

@Override
public void accept(CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) {
list.forEach(i -> {
if (i.require() instanceof DynamicCreativeItem dynamic) {
var array = new ArrayList<ItemStack>();
dynamic.fillItemCategory(array);
array.forEach(output::accept);
} else {
output.accept(i.require());
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final AutomobileEntity automobile() {
}

protected final Level world() {
return this.automobile.level;
return this.automobile.level();
}

public abstract Vec3 pos();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f;
import com.mojang.math.Axis;
import io.github.foundationgames.automobility.automobile.AutomobileEngine;
import io.github.foundationgames.automobility.automobile.WheelBase;
import io.github.foundationgames.automobility.automobile.render.attachment.front.FrontAttachmentRenderModel;
Expand All @@ -27,8 +27,8 @@ public static void render(

pose.pushPose();

pose.mulPose(Vector3f.ZP.rotationDegrees(180));
pose.mulPose(Vector3f.YP.rotationDegrees(automobile.getAutomobileYaw(tickDelta) + 180));
pose.mulPose(Axis.ZP.rotationDegrees(180));
pose.mulPose(Axis.YP.rotationDegrees(automobile.getAutomobileYaw(tickDelta) + 180));

float chassisRaise = wheels.model().radius() / 16;
float bounce = automobile.getSuspensionBounce(tickDelta) * 0.048f;
Expand Down Expand Up @@ -57,7 +57,7 @@ public static void render(
float eBack = frame.model().enginePosBack() / 16;
float eUp = frame.model().enginePosUp() / 16;
pose.translate(0, -eUp, eBack);
pose.mulPose(Vector3f.YP.rotationDegrees(180));
pose.mulPose(Axis.YP.rotationDegrees(180));
if (!engine.isEmpty() && engineModel != null) {
engineModel.renderToBuffer(pose, buffers.getBuffer(engineModel.renderType(engineTexture)), light, overlay, 1, 1, 1, 1);
if (engineModel instanceof BaseModel base) {
Expand All @@ -81,8 +81,8 @@ public static void render(
pose.pushPose();

pose.translate(exhaust.x() / 16, -exhaust.y() / 16, exhaust.z() / 16);
pose.mulPose(Vector3f.YP.rotationDegrees(exhaust.yaw()));
pose.mulPose(Vector3f.XP.rotationDegrees(exhaust.pitch()));
pose.mulPose(Axis.YP.rotationDegrees(exhaust.yaw()));
pose.mulPose(Axis.XP.rotationDegrees(exhaust.pitch()));
exhaustFumesModel.renderToBuffer(pose, exhaustBuffer, light, overlay, 1, 1, 1, 1);

pose.popPose();
Expand All @@ -95,7 +95,7 @@ public static void render(
if (!rearAtt.isEmpty()) {
pose.pushPose();
pose.translate(0, chassisRaise, frame.model().rearAttachmentPos() / 16);
pose.mulPose(Vector3f.YN.rotationDegrees(automobile.getAutomobileYaw(tickDelta) - automobile.getRearAttachmentYaw(tickDelta)));
pose.mulPose(Axis.YN.rotationDegrees(automobile.getAutomobileYaw(tickDelta) - automobile.getRearAttachmentYaw(tickDelta)));

pose.translate(0, 0, rearAtt.model().pivotDistPx() / 16);
if (rearAttachmentModel instanceof RearAttachmentRenderModel rm) {
Expand Down Expand Up @@ -146,12 +146,12 @@ public static void render(

pose.translate(pos.right() / 16, wheelRadius / 16, -pos.forward() / 16);

if (pos.end() == WheelBase.WheelEnd.FRONT) pose.mulPose(Vector3f.YP.rotationDegrees(automobile.getSteering(tickDelta) * 27));
if (pos.end() == WheelBase.WheelEnd.FRONT) pose.mulPose(Axis.YP.rotationDegrees(automobile.getSteering(tickDelta) * 27));
pose.translate(0, -chassisRaise, 0);
pose.mulPose(Vector3f.XP.rotationDegrees(wheelAngle));
pose.mulPose(Axis.XP.rotationDegrees(wheelAngle));
pose.scale(scale, scale, scale);

pose.mulPose(Vector3f.YP.rotationDegrees(180 + pos.yaw()));
pose.mulPose(Axis.YP.rotationDegrees(180 + pos.yaw()));

wheelModel.renderToBuffer(pose, wheelBuffer, light, overlay, 1, 1, 1, 1);
if (wheelModel instanceof BaseModel base) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.foundationgames.automobility.automobile.render;

import com.mojang.math.Vector3f;
import io.github.foundationgames.automobility.automobile.AutomobileEngine;
import io.github.foundationgames.automobility.automobile.AutomobileFrame;
import io.github.foundationgames.automobility.automobile.AutomobileWheel;
Expand All @@ -9,6 +8,7 @@
import io.github.foundationgames.automobility.automobile.attachment.front.FrontAttachment;
import io.github.foundationgames.automobility.automobile.attachment.rear.RearAttachment;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;

public interface RenderableAutomobile {
AutomobileFrame getFrame();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.foundationgames.automobility.automobile.render.engine;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.mojang.math.Axis;
import io.github.foundationgames.automobility.Automobility;
import io.github.foundationgames.automobility.automobile.render.BaseModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
Expand All @@ -17,6 +17,6 @@ public CopperEngineModel(EntityRendererProvider.Context ctx) {

@Override
protected void prepare(PoseStack matrices) {
matrices.mulPose(Vector3f.YP.rotationDegrees(180));
matrices.mulPose(Axis.YP.rotationDegrees(180));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.foundationgames.automobility.automobile.render.engine;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.mojang.math.Axis;
import io.github.foundationgames.automobility.Automobility;
import io.github.foundationgames.automobility.automobile.render.BaseModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
Expand All @@ -17,6 +17,6 @@ public CreativeEngineModel(EntityRendererProvider.Context ctx) {

@Override
protected void prepare(PoseStack matrices) {
matrices.mulPose(Vector3f.YP.rotationDegrees(180));
matrices.mulPose(Axis.YP.rotationDegrees(180));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.foundationgames.automobility.automobile.render.frame;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.mojang.math.Axis;
import io.github.foundationgames.automobility.Automobility;
import io.github.foundationgames.automobility.automobile.render.BaseModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
Expand All @@ -17,6 +17,6 @@ public CARRFrameModel(EntityRendererProvider.Context ctx) {

@Override
protected void prepare(PoseStack matrices) {
matrices.mulPose(Vector3f.YP.rotationDegrees(-90));
matrices.mulPose(Axis.YP.rotationDegrees(-90));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.foundationgames.automobility.automobile.render.frame;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.mojang.math.Axis;
import io.github.foundationgames.automobility.Automobility;
import io.github.foundationgames.automobility.automobile.render.BaseModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
Expand All @@ -17,6 +17,6 @@ public StandardFrameModel(EntityRendererProvider.Context ctx) {

@Override
protected void prepare(PoseStack matrices) {
matrices.mulPose(Vector3f.YP.rotationDegrees(-90));
matrices.mulPose(Axis.YP.rotationDegrees(-90));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.foundationgames.automobility.automobile.render.item;

import com.mojang.math.Vector3f;
import io.github.foundationgames.automobility.automobile.AutomobileData;
import io.github.foundationgames.automobility.automobile.AutomobileEngine;
import io.github.foundationgames.automobility.automobile.AutomobileFrame;
Expand All @@ -9,6 +8,7 @@
import io.github.foundationgames.automobility.automobile.attachment.rear.RearAttachment;
import io.github.foundationgames.automobility.automobile.render.RenderableAutomobile;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;

public class ItemRenderableAutomobile implements RenderableAutomobile {
private final AutomobileData reader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.foundationgames.automobility.automobile.render.wheel;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.mojang.math.Axis;
import io.github.foundationgames.automobility.Automobility;
import io.github.foundationgames.automobility.automobile.render.BaseModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
Expand All @@ -17,6 +17,6 @@ public OffRoadWheelModel(EntityRendererProvider.Context ctx) {

@Override
protected void prepare(PoseStack matrices) {
matrices.mulPose(Vector3f.YP.rotationDegrees(-90));
matrices.mulPose(Axis.YP.rotationDegrees(-90));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.foundationgames.automobility.automobile.render.wheel;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.mojang.math.Axis;
import io.github.foundationgames.automobility.Automobility;
import io.github.foundationgames.automobility.automobile.render.BaseModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
Expand All @@ -17,6 +17,6 @@ public StandardWheelModel(EntityRendererProvider.Context ctx) {

@Override
protected void prepare(PoseStack matrices) {
matrices.mulPose(Vector3f.YP.rotationDegrees(-90));
matrices.mulPose(Axis.YP.rotationDegrees(-90));
}
}
Loading

0 comments on commit 2e026b1

Please sign in to comment.