Skip to content

Commit

Permalink
feat: port to MC 1.19.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTJP committed Dec 22, 2023
1 parent f35a326 commit 80f9621
Show file tree
Hide file tree
Showing 108 changed files with 535 additions and 555 deletions.
2 changes: 1 addition & 1 deletion api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

minecraft {
mappings channel: mcp_mappings, version: mc_version
mappings channel: mcp_mappings, version: mcp_mappings_version
// accessTransformer = file("../core/src/main/resources/META-INF/accesstransformer.cfg")
}

Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ subprojects { p ->
mavenLocal()
maven { url = "https://proxy-maven.covers1624.net/" }
maven { url = "https://squiddev.cc/maven/" }
maven { url = "https://maven.blamejared.com/" }
}

// Replace version tokens in mods.toml
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ String mod_id = 'projectred_core'
sourceSets.main.java.srcDirs += ['../api/src/main/java']

minecraft {
mappings channel: mcp_mappings, version: mc_version
mappings channel: mcp_mappings, version: mcp_mappings_version
accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg")
runs {
data {
Expand Down
25 changes: 11 additions & 14 deletions core/src/main/java/mrtjp/projectred/core/ProjectRedCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.OptionalMod;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.logging.log4j.LogManager;
Expand All @@ -36,8 +36,8 @@ public class ProjectRedCore {
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);

public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID);
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, MOD_ID);
public static final DeferredRegister<MenuType<?>> MENU_TYPES = DeferredRegister.create(ForgeRegistries.CONTAINERS, MOD_ID);
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MOD_ID);
public static final DeferredRegister<MenuType<?>> MENU_TYPES = DeferredRegister.create(ForgeRegistries.MENU_TYPES, MOD_ID);
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID);
public static final DeferredRegister<RecipeSerializer<?>> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, MOD_ID);
public static final DeferredRegister<MultipartType<?>> PART_TYPES = DeferredRegister.create(MultipartType.MULTIPART_TYPES, MOD_ID);
Expand Down Expand Up @@ -85,16 +85,13 @@ private void onGatherDataEvent(final GatherDataEvent event) {
DataGenerator generator = event.getGenerator();
ExistingFileHelper fileHelper = event.getExistingFileHelper();

if (event.includeClient()) {
generator.addProvider(new CoreBlockStateModelProvider(generator, fileHelper));
generator.addProvider(new CoreItemModelProvider(generator, fileHelper));
generator.addProvider(new CoreLanguageProvider(generator));
}
if (event.includeServer()) {
generator.addProvider(new CoreRecipeProvider(generator));
generator.addProvider(new CoreLootTableProvider(generator));
generator.addProvider(new CoreItemTagsProvider(generator, fileHelper));
generator.addProvider(new CoreBlockTagsProvider(generator, fileHelper));
}
generator.addProvider(event.includeClient(), new CoreBlockStateModelProvider(generator, fileHelper));
generator.addProvider(event.includeClient(), new CoreItemModelProvider(generator, fileHelper));
generator.addProvider(event.includeClient(), new CoreLanguageProvider(generator));

generator.addProvider(event.includeServer(), new CoreRecipeProvider(generator));
generator.addProvider(event.includeServer(), new CoreLootTableProvider(generator));
generator.addProvider(event.includeServer(), new CoreItemTagsProvider(generator, fileHelper));
generator.addProvider(event.includeServer(), new CoreBlockTagsProvider(generator, fileHelper));
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package mrtjp.projectred.core.client;

import codechicken.lib.model.PerspectiveModelState;
import codechicken.lib.render.CCModel;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.block.ICCBlockRenderer;
import codechicken.lib.render.buffer.TransformingVertexConsumer;
import codechicken.lib.render.item.IItemRenderer;
import codechicken.lib.util.TransformUtils;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Rotation;
import codechicken.lib.vec.Vector3;
Expand All @@ -17,15 +19,14 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelData;
import net.minecraftforge.client.model.generators.ConfiguredModel;

import javax.annotation.Nullable;
import java.util.Random;

/**
* Needs to exist because Vanilla's default {@link ConfiguredModel} only supports a single x rotation and y rotation,
Expand Down Expand Up @@ -62,14 +63,13 @@ private static int modelKey(int side, int rot) {
//endregion

@Override
public boolean renderBlock(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack mStack, VertexConsumer builder, Random random, IModelData data) {
public void renderBlock(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack mStack, VertexConsumer builder, RandomSource random, ModelData data, @Nullable RenderType renderType) {
CCRenderState ccrs = CCRenderState.instance();
ccrs.reset();
ccrs.bind(new TransformingVertexConsumer(builder, mStack), DefaultVertexFormat.BLOCK);
ccrs.lightMatrix.locate(world, pos);

render(ccrs, MinecraftForgeClient.getRenderType(), getBlockRenderData(state, pos, world));
return true;
render(ccrs, renderType, getBlockRenderData(state, pos, world));
}

@Override
Expand Down Expand Up @@ -104,6 +104,6 @@ public record RenderData(int side, int rotation, MultiIconTransformation iconT)
// @Override public boolean useAmbientOcclusion() { return true; }
// @Override public boolean isGui3d() { return true; }
// @Override public boolean usesBlockLight() { return true; }
// @Override public ModelState getModelTransform() { return TransformUtils.DEFAULT_BLOCK; }
// @Override public @Nullable PerspectiveModelState getModelState() { return TransformUtils.DEFAULT_BLOCK; }
// //@formatter:on
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private static void unloadPostChain() {
}

private static boolean isFabulous() {
return Configurator.fabulousLights && Minecraft.getInstance().options.graphicsMode.getId() >= GraphicsStatus.FABULOUS.getId();
return Configurator.fabulousLights && Minecraft.getInstance().options.graphicsMode().get().getId() >= GraphicsStatus.FABULOUS.getId();
}
//endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraftforge.client.model.generators.ConfiguredModel;
import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.ForgeRegistries;

import javax.annotation.Nonnull;

Expand Down Expand Up @@ -59,7 +60,7 @@ private void addRotatablePoweredMachineVariants(Block block, ModelFile idleModel
}

private BlockModelBuilder createFrontFacedPoweredMachineModel(Block block, int state) {
String texture = block.getRegistryName().getPath();
String texture = ForgeRegistries.BLOCKS.getKey(block).getPath();
String modelName = texture + (state > 0 ? "_state" + state : "");

return models().orientableWithBottom(modelName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.crafting.NBTIngredient;
import net.minecraftforge.common.crafting.StrictNBTIngredient;

import java.util.Objects;

import static mrtjp.projectred.core.init.CoreBlocks.ELECTROTINE_GENERATOR_BLOCK;
import static mrtjp.projectred.core.init.CoreItems.*;
Expand Down Expand Up @@ -199,8 +201,8 @@ protected void registerRecipes() {
}

shapedRecipe(DRAW_PLATE_ITEM.get())
.key('I', NBTIngredient.of(ItemMicroBlock.create(3, 2, MicroMaterialRegistry.getMaterial(BlockMicroMaterial.makeMaterialKey(Blocks.IRON_BLOCK.defaultBlockState())))))
.key('D', NBTIngredient.of(ItemMicroBlock.create(0, 2, MicroMaterialRegistry.getMaterial(BlockMicroMaterial.makeMaterialKey(Blocks.DIAMOND_BLOCK.defaultBlockState())))))
.key('I', StrictNBTIngredient.of(ItemMicroBlock.create(3, 2, Objects.requireNonNull(MicroMaterialRegistry.getMaterial(BlockMicroMaterial.makeMaterialKey(Blocks.IRON_BLOCK.defaultBlockState()))))))
.key('D', StrictNBTIngredient.of(ItemMicroBlock.create(0, 2, Objects.requireNonNull(MicroMaterialRegistry.getMaterial(BlockMicroMaterial.makeMaterialKey(Blocks.DIAMOND_BLOCK.defaultBlockState()))))))
.patternLine(" I ")
.patternLine("IDI")
.patternLine(" I ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import javax.annotation.Nullable;

public class BasePoweredTileContainer extends AbstractContainerMenu {
public abstract class BasePoweredTileContainer extends AbstractContainerMenu {

private final BasePoweredTile tile;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public CraftingDamageItem(Item.Properties properties) {
}

@Override
public boolean hasContainerItem(ItemStack stack) {
public boolean hasCraftingRemainingItem(ItemStack stack) {
return true;
}

@Override
public ItemStack getContainerItem(ItemStack itemStack) {
public ItemStack getCraftingRemainingItem(ItemStack itemStack) {
if (canBeDepleted()) {
ItemStack ret = itemStack.copy();
ret.setDamageValue(ret.getDamageValue() + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
Expand All @@ -23,6 +23,7 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.InvWrapper;
Expand Down Expand Up @@ -79,7 +80,7 @@ public InteractionResult onBlockActivated(Player player, InteractionHand hand, B
if (!getLevel().isClientSide) {
ServerUtils.openContainer((ServerPlayer) player, new SimpleMenuProvider(
(id, inv, p) -> new ElectrotineGeneratorContainer(inv, this, id),
new TranslatableComponent(getBlockState().getBlock().getDescriptionId())),
getBlockState().getBlock().getName()),
p -> p.writePos(getBlockPos()));
}

Expand Down Expand Up @@ -209,7 +210,7 @@ public boolean canConductorWork() {
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
if (!this.remove && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
if (!this.remove && cap == ForgeCapabilities.ITEM_HANDLER) {
return handler.cast();
}
return super.getCapability(cap, side);
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/mrtjp/projectred/lib/GuiLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.mojang.blaze3d.vertex.*;
import com.mojang.math.Matrix4f;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.resources.ResourceLocation;

import static com.mojang.blaze3d.vertex.VertexFormat.Mode.QUADS;
Expand Down Expand Up @@ -41,13 +42,13 @@ public static void drawLine(PoseStack stack, int x1, int y1, int x2, int y2, int
RenderSystem.enableBlend();
RenderSystem.disableTexture();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
bufferbuilder.begin(QUADS, DefaultVertexFormat.POSITION_COLOR);
bufferbuilder.vertex(p_238460_0_, (float) r1.dx, (float) r1.dy, 0.0F).color(f, f1, f2, f3).endVertex();
bufferbuilder.vertex(p_238460_0_, (float) r2.dx, (float) r2.dy, 0.0F).color(f, f1, f2, f3).endVertex();
bufferbuilder.vertex(p_238460_0_, (float) r3.dx, (float) r3.dy, 0.0F).color(f, f1, f2, f3).endVertex();
bufferbuilder.vertex(p_238460_0_, (float) r4.dx, (float) r4.dy, 0.0F).color(f, f1, f2, f3).endVertex();
bufferbuilder.end();
BufferUploader.end(bufferbuilder);
BufferUploader.draw(bufferbuilder.end());
RenderSystem.enableTexture();
RenderSystem.disableBlend();
}
Expand Down
5 changes: 1 addition & 4 deletions core/src/main/java/mrtjp/projectred/lib/ModelLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;

import java.io.*;
Expand Down Expand Up @@ -51,9 +50,7 @@ public static void exportVertsToJson(String filePath, Map<String, Vertex5[]> ver
}

public static Map<String, Vertex5[]> importVertsFromJson(ResourceManager resourceManager, ResourceLocation resource) {
try (
Resource res = resourceManager.getResource(resource);
InputStream stream = res.getInputStream()) {
try (InputStream stream = resourceManager.getResource(resource).get().open()) {

return importVertsFromJson(new InputStreamReader(stream));

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/mrtjp/projectred/redui/DebugRectNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import mrtjp.projectred.lib.Rect;
import mrtjp.projectred.lib.Size;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.Component;
import org.lwjgl.glfw.GLFW;

import java.util.Collections;
Expand Down Expand Up @@ -47,7 +47,7 @@ public void drawFront(PoseStack stack, Point mouse, float partialFrame) {
GuiComponent.fill(stack, cursorRect.x(), cursorRect.y(), cursorRect.maxX(), cursorRect.maxY(), EnumColour.WHITE.argb(clickDown ? 150 : 50));

// Tooltip showing name
renderTooltip(stack, mouse, Collections.singletonList(new TextComponent(name)));
renderTooltip(stack, mouse, Collections.singletonList(Component.literal(name)));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Redstone. The way it was meant to be.
[[dependencies.projectred_core]]
modId="minecraft"
mandatory=true
versionRange="[1.18.2]"
versionRange="[1.19.2]"
ordering="NONE"
side="BOTH"
[[dependencies.projectred_core]]
Expand Down
2 changes: 1 addition & 1 deletion expansion/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
String mod_id = 'projectred_expansion'

minecraft {
mappings channel: mcp_mappings, version: mc_version
mappings channel: mcp_mappings, version: mcp_mappings_version
accessTransformer = file("../core/src/main/resources/META-INF/accesstransformer.cfg")
runs {
data {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public class CraftingHelper {
public boolean stillValid(Player p_75145_1_) {
return false;
}

@Override
public ItemStack quickMoveStack(Player pPlayer, int pIndex) {
return ItemStack.EMPTY;
}
}, 3, 3);

private final ResultContainer craftResultInventory = new ResultContainer();
Expand Down
Loading

0 comments on commit 80f9621

Please sign in to comment.