diff --git a/build.gradle b/build.gradle index 6097e9b..cd55be1 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = '1.16.5-0.0.7' +version = '1.16.5-0.0.8' group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'MasterfulMachinery' @@ -146,6 +146,10 @@ dependencies { runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:generators")// Mekanism: Generators runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:tools")// Mekanism: Tools + + compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") + // at runtime, use the full JEI jar + runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" // compile "some.group:artifact:version" diff --git a/gradle.properties b/gradle.properties index 922c412..fa070cb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,6 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mekanism_version=1.16.5-10.0.20.447 \ No newline at end of file +mekanism_version=1.16.5-10.0.20.447 +mc_version=1.16.5 +jei_version=7.+ \ No newline at end of file diff --git a/src/main/java/com/ticticboooom/mods/mm/MM.java b/src/main/java/com/ticticboooom/mods/mm/MM.java index d6c4732..6ace8df 100644 --- a/src/main/java/com/ticticboooom/mods/mm/MM.java +++ b/src/main/java/com/ticticboooom/mods/mm/MM.java @@ -17,6 +17,7 @@ import com.ticticboooom.mods.mm.datagen.gen.MMLangProvider; import com.ticticboooom.mods.mm.network.PacketHandler; import com.ticticboooom.mods.mm.registration.MMLoader; import com.ticticboooom.mods.mm.registration.MMPorts; +import com.ticticboooom.mods.mm.registration.MMSetup; import com.ticticboooom.mods.mm.registration.RecipeTypes; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScreenManager; @@ -57,10 +58,10 @@ public class MM { PacketHandler.init(); registerDataGen(); IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); - MMLoader.BLOCKS_REG.register(bus); - MMLoader.ITEMS_REG.register(bus); - MMLoader.TILES_REG.register(bus); - MMLoader.CONTAINER_REG.register(bus); + MMSetup.BLOCKS_REG.register(bus); + MMSetup.ITEMS_REG.register(bus); + MMSetup.TILES_REG.register(bus); + MMSetup.CONTAINER_REG.register(bus); RecipeTypes.RECIPE_SERIALIZERS.register(bus); bus.addListener(this::clientEvents); if (FMLEnvironment.dist == Dist.CLIENT) { diff --git a/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MMJeiPlugin.java b/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MMJeiPlugin.java new file mode 100644 index 0000000..6dbe57f --- /dev/null +++ b/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MMJeiPlugin.java @@ -0,0 +1,36 @@ +package com.ticticboooom.mods.mm.client.jei.category; + +import com.ticticboooom.mods.mm.MM; +import com.ticticboooom.mods.mm.data.MachineStructureRecipe; +import com.ticticboooom.mods.mm.registration.RecipeTypes; +import mezz.jei.api.IModPlugin; +import mezz.jei.api.JeiPlugin; +import mezz.jei.api.registration.IRecipeCategoryRegistration; +import mezz.jei.api.registration.IRecipeRegistration; +import net.minecraft.client.Minecraft; +import net.minecraft.item.crafting.IRecipeType; +import net.minecraft.util.ResourceLocation; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@JeiPlugin +public class MMJeiPlugin implements IModPlugin { + @Override + public ResourceLocation getPluginUid() { + return new ResourceLocation(MM.ID, "jei_main"); + } + + @Override + public void registerRecipes(IRecipeRegistration registration) { + List structureRecipes = Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(RecipeTypes + .MACHINE_STRUCTURE); + registration.addRecipes(structureRecipes, new ResourceLocation(MM.ID, "machine_structure")); + } + + @Override + public void registerCategories(IRecipeCategoryRegistration registration) { + registration.addRecipeCategories(new MachineStructureRecipeCategory(registration.getJeiHelpers())); + } +} diff --git a/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MachineStructureRecipeCategory.java b/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MachineStructureRecipeCategory.java new file mode 100644 index 0000000..8539527 --- /dev/null +++ b/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MachineStructureRecipeCategory.java @@ -0,0 +1,217 @@ +package com.ticticboooom.mods.mm.client.jei.category; + +import com.mojang.blaze3d.matrix.MatrixStack; +import com.ticticboooom.mods.mm.MM; +import com.ticticboooom.mods.mm.block.ControllerBlock; +import com.ticticboooom.mods.mm.client.util.GuiBlockRenderBuilder; +import com.ticticboooom.mods.mm.data.MachineStructureRecipe; +import com.ticticboooom.mods.mm.data.model.structure.MachineStructureRecipeKeyModel; +import com.ticticboooom.mods.mm.registration.MMLoader; +import com.ticticboooom.mods.mm.registration.MMSetup; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.helpers.IJeiHelpers; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.DirectionalBlock; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.Direction; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Quaternion; +import net.minecraft.util.math.vector.Vector3f; +import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.registries.ForgeRegistries; +import org.lwjgl.glfw.GLFW; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class MachineStructureRecipeCategory implements IRecipeCategory { + + private static final ResourceLocation overlayRl = new ResourceLocation(MM.ID, "textures/gui/gui_large_jei.png"); + private static final ResourceLocation iconRl = new ResourceLocation(MM.ID, "textures/items/blueprint.png"); + private static final ResourceLocation slotRl = new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"); + private IJeiHelpers helpers; + private MachineStructureRecipe recipe; + private float xRotation = 0; + private double xLastMousePosition = 0; + private float yRotation = 0; + private double yLastMousePosition = 0; + private int sliceY = 0; + private boolean slicingActive = false; + + public MachineStructureRecipeCategory(IJeiHelpers helpers) { + this.helpers = helpers; + } + + @Override + public ResourceLocation getUid() { + return new ResourceLocation(MM.ID, "machine_structure"); + } + + @Override + public Class getRecipeClass() { + return MachineStructureRecipe.class; + } + + @Override + public String getTitle() { + return "Machine Structures"; + } + + @Override + public IDrawable getBackground() { + return helpers.getGuiHelper().createDrawable(overlayRl, 0, 0, 162, 150); + } + + @Override + public IDrawable getIcon() { + return helpers.getGuiHelper().createDrawableIngredient(new ItemStack(MMSetup.BLUEPRINT.get(), 1)); + } + + private IDrawable getButton() {return helpers.getGuiHelper().createDrawable(slotRl, 0, 44, 18, 18);} + + @Override + public void setIngredients(MachineStructureRecipe machineStructureRecipe, IIngredients iIngredients) { + Ingredient ingredient = Ingredient.of(new ItemStack(MMSetup.BLUEPRINT.get())); + ArrayList objects = new ArrayList<>(); + objects.add(ingredient); + iIngredients.setInputIngredients(objects); + } + + @Override + public void setRecipe(IRecipeLayout iRecipeLayout, MachineStructureRecipe machineStructureRecipe, IIngredients iIngredients) { + + } + + @Override + public void draw(MachineStructureRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) { + if (this.recipe != recipe) { + this.recipe = null; + xRotation = 0; + yRotation = 0; + sliceY = 0; + slicingActive = false; + } + Minecraft mc = Minecraft.getInstance(); + if (xLastMousePosition == 0) { + xLastMousePosition = mouseX; + } + if (yLastMousePosition == 0) { + yLastMousePosition = mouseY; + } + + if (GLFW.glfwGetMouseButton(mc.getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_1) != 0) { + double relMoveX = mouseX - xLastMousePosition; + double relMoveY = mouseY - yLastMousePosition; + xRotation += relMoveX; + yRotation += relMoveY; + } + int furthestX = Integer.MAX_VALUE; + int nearestX = Integer.MIN_VALUE; + int furthestZ = Integer.MAX_VALUE; + int nearestZ = Integer.MIN_VALUE; + + int topY = Integer.MIN_VALUE; + int bottomY = Integer.MAX_VALUE; + + for (MachineStructureRecipeKeyModel part : recipe.getModels().get(0)) { + furthestX = Math.min(part.getPos().getX(), furthestX); + nearestX = Math.max(part.getPos().getX(), nearestX); + furthestZ = Math.min(part.getPos().getZ(), furthestZ); + nearestZ = Math.max(part.getPos().getZ(), nearestZ); + topY = Math.max(part.getPos().getY(), topY); + bottomY = Math.min(part.getPos().getY(), bottomY); + } + int scaleFactor = Math.abs(furthestX) + Math.abs(nearestX) + Math.abs(furthestZ) + Math.abs(nearestZ); + scaleFactor = scaleFactor / 4; + nearestX++; + nearestZ++; + float centreX = ((float) nearestX - furthestX) / 2f; + float centreZ = ((float) nearestZ - furthestZ) / 2f; + + List parts = recipe.getModels().get(0); + if (slicingActive) { + parts = parts.stream().filter(x -> x.getPos().getY() == sliceY).collect(Collectors.toList()); + } + + for (MachineStructureRecipeKeyModel part : parts) { + if (part.getBlock().isEmpty() && part.getTag().isEmpty()) { + continue; + } + + BlockPos bp = new BlockPos(part.getPos().getX(), part.getPos().getY(), part.getPos().getZ()); + + if (!part.getBlock().equals("")) { + ResourceLocation resourceLocation = new ResourceLocation(part.getBlock()); + Block block = ForgeRegistries.BLOCKS.getValue(resourceLocation); + BlockState defaultState = block.defaultBlockState(); + new GuiBlockRenderBuilder(defaultState).at(bp) + .withPrePosition(new Vector3f(6.5f, -5, 10)) + .withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true)) + .withRotation(new Quaternion(new Vector3f(0, -1, 0), 225 - xRotation, true)) + .withScale(new Vector3f(12f, -12, 12)) + .finalize(matrixStack); + } + } + if (sliceY == 0) { + ControllerBlock block = null; + for (RegistryObject reg : MMLoader.BLOCKS) { + if (reg.get().getControllerId().equals(recipe.getControllerId())) { + block = reg.get(); + } + } + BlockState defaultState = block.defaultBlockState().setValue(DirectionalBlock.FACING, Direction.NORTH); + new GuiBlockRenderBuilder(defaultState).at(new BlockPos(0, 0, 0)) + .withPrePosition(new Vector3f(6.5f, -5, 10)) + .withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true)) + .withRotation(new Quaternion(new Vector3f(0, -1, 0), 225 - xRotation, true)) + .withScale(new Vector3f(12f, -12f, 12f)) + .finalize(matrixStack); + } + + this.recipe = recipe; + xLastMousePosition = mouseX; + yLastMousePosition = mouseY; + + getButton().draw(matrixStack, 144, 125); + } + + @Override + public boolean handleClick(MachineStructureRecipe recipe, double mouseX, double mouseY, int mouseButton) { + if (mouseX > 144 && mouseY > 125 && mouseX < 162 && mouseY < 143) { + startIncrementSlice(); + } + return false; + } + + private void startIncrementSlice() { + + int topY = Integer.MIN_VALUE; + int bottomY = Integer.MAX_VALUE; + + for (MachineStructureRecipeKeyModel part : recipe.getModels().get(0)) { + topY = Math.max(part.getPos().getY(), topY); + bottomY = Math.min(part.getPos().getY(), bottomY); + } + + if (!slicingActive){ + slicingActive = true; + sliceY = bottomY; + } else if (sliceY == topY){ + slicingActive = false; + sliceY = 0; + } else { + sliceY++; + } + + + } +} diff --git a/src/main/java/com/ticticboooom/mods/mm/client/util/GuiBlockRenderBuilder.java b/src/main/java/com/ticticboooom/mods/mm/client/util/GuiBlockRenderBuilder.java new file mode 100644 index 0000000..615859d --- /dev/null +++ b/src/main/java/com/ticticboooom/mods/mm/client/util/GuiBlockRenderBuilder.java @@ -0,0 +1,89 @@ +package com.ticticboooom.mods.mm.client.util; + +import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.systems.RenderSystem; +import mekanism.client.model.BaseModelCache; +import net.minecraft.block.BlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Quaternion; +import net.minecraft.util.math.vector.Vector3f; +import net.minecraftforge.client.model.data.EmptyModelData; + +import java.util.ArrayList; +import java.util.List; + +public class GuiBlockRenderBuilder { + private final BlockState blockState; + private BlockPos position; + private List orderedRotation = new ArrayList<>(); + private Minecraft mc = Minecraft.getInstance(); + private Vector3f scale; + private Vector3f prePosition = new Vector3f(); + + public GuiBlockRenderBuilder(BlockState blockState) { + this.blockState = blockState; + position = new BlockPos(0, 0, 0); + } + + public GuiBlockRenderBuilder at(BlockPos position) { + this.position = position; + return this; + } + + public GuiBlockRenderBuilder withRotation(Quaternion rotation) { + orderedRotation.add(rotation); + return this; + } + + public GuiBlockRenderBuilder withScale(Vector3f scale) { + this.scale = scale; + return this; + } + + public GuiBlockRenderBuilder withPrePosition(Vector3f position) { + this.prePosition = position; + return this; + } + + private void prepareRender() { + RenderSystem.enableBlend(); + RenderSystem.enableRescaleNormal(); + RenderSystem.enableAlphaTest(); + RenderHelper.setupFor3DItems(); + RenderSystem.alphaFunc(516, 0.1F); + RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); + RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + private void cleanupRender() { + RenderSystem.disableAlphaTest(); + RenderSystem.disableRescaleNormal(); + } + + public void finalize(MatrixStack ms) { + prepareRender(); + IRenderTypeBuffer.Impl buf = mc.renderBuffers().bufferSource(); + BlockRendererDispatcher brd = Minecraft.getInstance().getBlockRenderer(); + ms.pushPose(); + transformMatrix(ms); + brd.renderBlock(blockState, ms, buf, 0xF000F0, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE); + buf.endBatch(); + ms.popPose(); + cleanupRender(); + } + + private void transformMatrix(MatrixStack ms) { + ms.scale(scale.x(), scale.y(), scale.z()); + ms.translate(prePosition.x(), prePosition.y(), prePosition.z()); + for (Quaternion quaternion : orderedRotation) { + ms.mulPose(quaternion); + } + ms.translate(position.getX(), position.getY(), position.getZ()); + } +} diff --git a/src/main/java/com/ticticboooom/mods/mm/data/MachineStructureRecipe.java b/src/main/java/com/ticticboooom/mods/mm/data/MachineStructureRecipe.java index aac1c25..1bd4f13 100644 --- a/src/main/java/com/ticticboooom/mods/mm/data/MachineStructureRecipe.java +++ b/src/main/java/com/ticticboooom/mods/mm/data/MachineStructureRecipe.java @@ -38,7 +38,9 @@ import java.util.List; public class MachineStructureRecipe implements IRecipe { private final ResourceLocation rl = new ResourceLocation(MM.ID, "machine_structure"); + @Getter private List> models; + @Getter private final String controllerId; private String id; diff --git a/src/main/java/com/ticticboooom/mods/mm/datagen/gen/MMItemModelProvider.java b/src/main/java/com/ticticboooom/mods/mm/datagen/gen/MMItemModelProvider.java index 414a128..4dcaa4e 100644 --- a/src/main/java/com/ticticboooom/mods/mm/datagen/gen/MMItemModelProvider.java +++ b/src/main/java/com/ticticboooom/mods/mm/datagen/gen/MMItemModelProvider.java @@ -4,6 +4,7 @@ import com.ticticboooom.mods.mm.MM; import com.ticticboooom.mods.mm.block.ControllerBlock; import com.ticticboooom.mods.mm.block.MachinePortBlock; import com.ticticboooom.mods.mm.registration.MMLoader; +import com.ticticboooom.mods.mm.registration.MMSetup; import net.minecraft.data.DataGenerator; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.generators.ItemModelProvider; @@ -29,5 +30,7 @@ public class MMItemModelProvider extends ItemModelProvider { for (RegistryObject port : MMLoader.IPORT_BLOCKS) { this.getBuilder(port.getId().toString()).parent(new ModelFile.UncheckedModelFile(new ResourceLocation(port.getId().getNamespace(), "block/" + port.getId().getPath()))); } + + this.getBuilder(MMSetup.BLUEPRINT.getId().getPath()).parent(new ModelFile.UncheckedModelFile("item/generated")).texture("layer0", "items/blueprint"); } } \ No newline at end of file diff --git a/src/main/java/com/ticticboooom/mods/mm/datagen/gen/MMLangProvider.java b/src/main/java/com/ticticboooom/mods/mm/datagen/gen/MMLangProvider.java index c3a6698..7b73a87 100644 --- a/src/main/java/com/ticticboooom/mods/mm/datagen/gen/MMLangProvider.java +++ b/src/main/java/com/ticticboooom/mods/mm/datagen/gen/MMLangProvider.java @@ -4,6 +4,7 @@ import com.ticticboooom.mods.mm.MM; import com.ticticboooom.mods.mm.block.ControllerBlock; import com.ticticboooom.mods.mm.block.MachinePortBlock; import com.ticticboooom.mods.mm.registration.MMLoader; +import com.ticticboooom.mods.mm.registration.MMSetup; import net.minecraft.data.DataGenerator; import net.minecraftforge.common.data.LanguageProvider; import net.minecraftforge.fml.RegistryObject; @@ -29,6 +30,8 @@ public class MMLangProvider extends LanguageProvider { this.add(port.get(), block.get().getControllerName() + " - " + port.get().getLangName() + " Output Port"); } } + + this.add(MMSetup.BLUEPRINT.get(), "Blueprint"); } } } diff --git a/src/main/java/com/ticticboooom/mods/mm/ports/storage/FluidPortStorage.java b/src/main/java/com/ticticboooom/mods/mm/ports/storage/FluidPortStorage.java index df8ac8c..590cab4 100644 --- a/src/main/java/com/ticticboooom/mods/mm/ports/storage/FluidPortStorage.java +++ b/src/main/java/com/ticticboooom/mods/mm/ports/storage/FluidPortStorage.java @@ -59,7 +59,15 @@ public class FluidPortStorage implements IPortStorage { @Override public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) { -} + Minecraft.getInstance().textureManager.bind(new ResourceLocation(MM.ID, "textures/gui/port_gui.png")); + screen.blit(stack, left, top, 0, 0, 175, 256); + int x = 78; + int y = 40; + screen.blit(stack, left + x, top + y, 175, 0, 18, 18); + FluidRenderer.INSTANCE.render(stack, left + x + 1, top + y + 1, inv.getFluidInTank(0), 16); + + AbstractGui.drawCenteredString(stack, Minecraft.getInstance().font, inv.getFluidInTank(0).getAmount() + " " + inv.getFluidInTank(0).getDisplayName().getString(), left + x + 9 + 1, top + y + 30, 0xfefefe); + } @Override public void setupContainer(PortBlockContainer container, PlayerInventory inv, MachinePortBlockEntity tile) { diff --git a/src/main/java/com/ticticboooom/mods/mm/registration/MMLoader.java b/src/main/java/com/ticticboooom/mods/mm/registration/MMLoader.java index df7b7d7..ceaa368 100644 --- a/src/main/java/com/ticticboooom/mods/mm/registration/MMLoader.java +++ b/src/main/java/com/ticticboooom/mods/mm/registration/MMLoader.java @@ -51,10 +51,6 @@ public class MMLoader { public static final ArrayList>> CONTAINERS = new ArrayList<>(); public static final ArrayList>> PORT_CONTAINERS = new ArrayList>>(); - public static final DeferredRegister BLOCKS_REG = DeferredRegister.create(ForgeRegistries.BLOCKS, MM.ID); - public static final DeferredRegister ITEMS_REG = DeferredRegister.create(ForgeRegistries.ITEMS, MM.ID); - public static final DeferredRegister> TILES_REG = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, MM.ID); - public static final DeferredRegister> CONTAINER_REG = DeferredRegister.create(ForgeRegistries.CONTAINERS, MM.ID); public static void load() { Path rootPath = FMLPaths.CONFIGDIR.get().resolve("masterful_machinery"); @@ -72,10 +68,10 @@ public class MMLoader { Registerable>> controllerTile = new Registerable<>(); Registerable> controllerBlock = new Registerable<>(); Registerable>> cont = new Registerable<>(); - cont.set(CONTAINER_REG.register(controllerId + "_controller", () -> IForgeContainerType.create((i, o, u) -> new ControllerBlockContainer(cont.get().get(), i, o, u)))); - controllerBlock.set(BLOCKS_REG.register(controllerId + "_controller", () -> new ControllerBlock(controllerTile.get(), controllerName, controllerId))); - controllerTile.set(TILES_REG.register(controllerId + "_controller", () -> TileEntityType.Builder.of(() -> new ControllerBlockEntity(controllerTile.get(), cont.get(), controllerId), controllerBlock.get().get()).build(null))); - ITEMS_REG.register(controllerId + "_controller", () -> new BlockItem(controllerBlock.get().get(), new Item.Properties().tab(MASTERFUL_ITEM_GROUP))); + cont.set(MMSetup.CONTAINER_REG.register(controllerId + "_controller", () -> IForgeContainerType.create((i, o, u) -> new ControllerBlockContainer(cont.get().get(), i, o, u)))); + controllerBlock.set(MMSetup.BLOCKS_REG.register(controllerId + "_controller", () -> new ControllerBlock(controllerTile.get(), controllerName, controllerId))); + controllerTile.set(MMSetup.TILES_REG.register(controllerId + "_controller", () -> TileEntityType.Builder.of(() -> new ControllerBlockEntity(controllerTile.get(), cont.get(), controllerId), controllerBlock.get().get()).build(null))); + MMSetup.ITEMS_REG.register(controllerId + "_controller", () -> new BlockItem(controllerBlock.get().get(), new Item.Properties().tab(MASTERFUL_ITEM_GROUP))); BLOCKS.add(controllerBlock.get()); CONTAINERS.add(cont.get()); } @@ -95,10 +91,10 @@ public class MMLoader { Registerable>> tile = new Registerable<>(); Registerable> block = new Registerable<>(); Registerable>> cont = new Registerable<>(); - cont.set(CONTAINER_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> IForgeContainerType.create((i, o, u) -> new PortBlockContainer(cont.get().get(), i, o, u)))); - block.set(BLOCKS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> new MachinePortBlock(tile.get(), name, controllerId))); - tile.set(TILES_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> TileEntityType.Builder.of(() -> new MachinePortBlockEntity(tile.get().get(),cont.get().get(), data.get(), true), block.get().get()).build(null))); - ITEMS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> new BlockItem(block.get().get(), new Item.Properties().tab(MASTERFUL_ITEM_GROUP))); + cont.set(MMSetup.CONTAINER_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> IForgeContainerType.create((i, o, u) -> new PortBlockContainer(cont.get().get(), i, o, u)))); + block.set(MMSetup.BLOCKS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> new MachinePortBlock(tile.get(), name, controllerId))); + tile.set(MMSetup.TILES_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> TileEntityType.Builder.of(() -> new MachinePortBlockEntity(tile.get().get(),cont.get().get(), data.get(), true), block.get().get()).build(null))); + MMSetup.ITEMS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> new BlockItem(block.get().get(), new Item.Properties().tab(MASTERFUL_ITEM_GROUP))); PORT_CONTAINERS.add(cont.get()); IPORT_BLOCKS.add(block.get()); } @@ -107,10 +103,10 @@ public class MMLoader { Registerable>> tile = new Registerable<>(); Registerable> block = new Registerable<>(); Registerable>> cont = new Registerable<>(); - cont.set(CONTAINER_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> IForgeContainerType.create((i, o, u) -> new PortBlockContainer(cont.get().get(), i, o, u)))); - block.set(BLOCKS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> new MachinePortBlock(tile.get(), name, controllerId))); - tile.set(TILES_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> TileEntityType.Builder.of(() -> new MachinePortBlockEntity(tile.get().get(), cont.get().get(), data.get(), false), block.get().get()).build(null))); - ITEMS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> new BlockItem(block.get().get(), new Item.Properties().tab(MASTERFUL_ITEM_GROUP))); + cont.set(MMSetup.CONTAINER_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> IForgeContainerType.create((i, o, u) -> new PortBlockContainer(cont.get().get(), i, o, u)))); + block.set(MMSetup.BLOCKS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> new MachinePortBlock(tile.get(), name, controllerId))); + tile.set(MMSetup.TILES_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> TileEntityType.Builder.of(() -> new MachinePortBlockEntity(tile.get().get(), cont.get().get(), data.get(), false), block.get().get()).build(null))); + MMSetup.ITEMS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> new BlockItem(block.get().get(), new Item.Properties().tab(MASTERFUL_ITEM_GROUP))); PORT_CONTAINERS.add(cont.get()); OPORT_BLOCKS.add(block.get()); } diff --git a/src/main/java/com/ticticboooom/mods/mm/registration/MMSetup.java b/src/main/java/com/ticticboooom/mods/mm/registration/MMSetup.java new file mode 100644 index 0000000..9119af6 --- /dev/null +++ b/src/main/java/com/ticticboooom/mods/mm/registration/MMSetup.java @@ -0,0 +1,21 @@ +package com.ticticboooom.mods.mm.registration; + +import com.ticticboooom.mods.mm.MM; +import net.minecraft.block.Block; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntityType; +import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; + +public class MMSetup { + + public static final DeferredRegister BLOCKS_REG = DeferredRegister.create(ForgeRegistries.BLOCKS, MM.ID); + public static final DeferredRegister ITEMS_REG = DeferredRegister.create(ForgeRegistries.ITEMS, MM.ID); + public static final DeferredRegister> TILES_REG = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, MM.ID); + public static final DeferredRegister> CONTAINER_REG = DeferredRegister.create(ForgeRegistries.CONTAINERS, MM.ID); + + public static final RegistryObject BLUEPRINT = ITEMS_REG.register("blueprint", () -> new Item(new Item.Properties().tab(MMLoader.MASTERFUL_ITEM_GROUP))); + +} diff --git a/src/main/resources/assets/masterfulmachinery/textures/gui/gui_large_jei.png b/src/main/resources/assets/masterfulmachinery/textures/gui/gui_large_jei.png new file mode 100644 index 0000000..4e725e0 Binary files /dev/null and b/src/main/resources/assets/masterfulmachinery/textures/gui/gui_large_jei.png differ diff --git a/src/main/resources/assets/masterfulmachinery/textures/gui/slot_parts.png b/src/main/resources/assets/masterfulmachinery/textures/gui/slot_parts.png new file mode 100644 index 0000000..354f485 Binary files /dev/null and b/src/main/resources/assets/masterfulmachinery/textures/gui/slot_parts.png differ diff --git a/src/main/resources/data/masterfulmachinery/recipes/struct.json b/src/main/resources/data/masterfulmachinery/recipes/struct.json new file mode 100644 index 0000000..76c9719 --- /dev/null +++ b/src/main/resources/data/masterfulmachinery/recipes/struct.json @@ -0,0 +1,31 @@ +{ + "type": "masterfulmachinery:machine_structure", + "controllerId": "basic", + "id": "first_structure", + "blocks": [ + { + "pos": { + "x": -1, + "y": 0, + "z": 0 + }, + "block": "masterfulmachinery:basic_basic_port_items_input" + }, + { + "pos": { + "x": 1, + "y": 0, + "z": 0 + }, + "block": "masterfulmachinery:basic_basic_port_items_output" + }, + { + "pos": { + "x": 0, + "y": 1, + "z": 0 + }, + "block": "masterfulmachinery:basic_basic_port_items_output" + } + ] +} \ No newline at end of file