diff --git a/build.gradle b/build.gradle index d32b327..988fcc2 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.1.21-T' + System.currentTimeMillis() +version = '1.16.5-0.1.22-T' + System.currentTimeMillis() group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'MasterfulMachinery' diff --git a/src/main/java/com/ticticboooom/mods/mm/block/ControllerBlock.java b/src/main/java/com/ticticboooom/mods/mm/block/ControllerBlock.java index c9396d9..aff00f4 100644 --- a/src/main/java/com/ticticboooom/mods/mm/block/ControllerBlock.java +++ b/src/main/java/com/ticticboooom/mods/mm/block/ControllerBlock.java @@ -33,14 +33,17 @@ public class ControllerBlock extends DirectionalBlock { private String controllerName; @Getter private String controllerId; + @Getter + private String texOverride; - public ControllerBlock(RegistryObject> type, String name, String id) { + public ControllerBlock(RegistryObject> type, String name, String id, String texOverride) { super(AbstractBlock.Properties.of(Material.METAL) .harvestLevel(1) .harvestTool(ToolType.PICKAXE)); this.type = type; this.controllerName = name; this.controllerId = id; + this.texOverride = texOverride; this.registerDefaultState(this.defaultBlockState().setValue(FACING, Direction.NORTH)); } diff --git a/src/main/java/com/ticticboooom/mods/mm/block/MachinePortBlock.java b/src/main/java/com/ticticboooom/mods/mm/block/MachinePortBlock.java index 290fcef..51dd1d0 100644 --- a/src/main/java/com/ticticboooom/mods/mm/block/MachinePortBlock.java +++ b/src/main/java/com/ticticboooom/mods/mm/block/MachinePortBlock.java @@ -30,12 +30,15 @@ public class MachinePortBlock extends Block { private String langName; @Getter private String controllerId; + @Getter + private String textureOverride; - public MachinePortBlock(RegistryObject> type, String name, String controllerId) { + public MachinePortBlock(RegistryObject> type, String name, String controllerId, String textureOverride) { super(AbstractBlock.Properties.of(Material.METAL)); this.type = type; this.langName = name; this.controllerId = controllerId; + this.textureOverride = textureOverride; } @Override diff --git a/src/main/java/com/ticticboooom/mods/mm/datagen/gen/MMBlockStateProvider.java b/src/main/java/com/ticticboooom/mods/mm/datagen/gen/MMBlockStateProvider.java index 17f1950..60829b2 100644 --- a/src/main/java/com/ticticboooom/mods/mm/datagen/gen/MMBlockStateProvider.java +++ b/src/main/java/com/ticticboooom/mods/mm/datagen/gen/MMBlockStateProvider.java @@ -3,6 +3,7 @@ package com.ticticboooom.mods.mm.datagen.gen; 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.helper.RLUtils; import com.ticticboooom.mods.mm.registration.MMLoader; import net.minecraft.block.DirectionalBlock; import net.minecraft.client.renderer.RenderType; @@ -29,7 +30,7 @@ public class MMBlockStateProvider extends BlockStateProvider { @Override protected void registerStatesAndModels() { for (RegistryObject controller : MMLoader.BLOCKS) { - dynamicBlockNorthOverlay(controller.getId(), BASE_TEXTURE, CONTROLLER_TEXTURE); + dynamicBlockNorthOverlay(controller.getId(), controller.get().getTexOverride() != null ? RLUtils.toRL(controller.get().getTexOverride()) : BASE_TEXTURE, CONTROLLER_TEXTURE); VariantBlockStateBuilder variantBuilder = getVariantBuilder(controller.get()); variantBuilder.partialState().with(DirectionalBlock.FACING, Direction.NORTH).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + controller.getId().getPath()))).rotationY(0).addModel(); variantBuilder.partialState().with(DirectionalBlock.FACING, Direction.SOUTH).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + controller.getId().getPath()))).rotationY(180).addModel(); @@ -38,13 +39,12 @@ public class MMBlockStateProvider extends BlockStateProvider { variantBuilder.partialState().with(DirectionalBlock.FACING, Direction.UP).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + controller.getId().getPath()))).rotationY(0).addModel(); variantBuilder.partialState().with(DirectionalBlock.FACING, Direction.DOWN).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + controller.getId().getPath()))).rotationY(0).addModel(); } - for (RegistryObject port : MMLoader.IPORT_BLOCKS) { - dynamicBlock(port.getId(), BASE_TEXTURE, IPORT_TEXTURE); + dynamicBlock(port.getId(), port.get().getTextureOverride() != null ? RLUtils.toRL(port.get().getTextureOverride()) : BASE_TEXTURE, IPORT_TEXTURE); simpleBlock(port.get(), new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + port.getId().getPath()))); } for (RegistryObject port : MMLoader.OPORT_BLOCKS) { - dynamicBlock(port.getId(), BASE_TEXTURE, OPORT_TEXTURE); + dynamicBlock(port.getId(), port.get().getTextureOverride() != null ? RLUtils.toRL(port.get().getTextureOverride()) : BASE_TEXTURE, OPORT_TEXTURE); simpleBlock(port.get(), new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + port.getId().getPath()))); } } 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 464f3dc..dcb4905 100644 --- a/src/main/java/com/ticticboooom/mods/mm/registration/MMLoader.java +++ b/src/main/java/com/ticticboooom/mods/mm/registration/MMLoader.java @@ -44,8 +44,7 @@ public class MMLoader { public static final ArrayList> IPORT_BLOCKS = new ArrayList<>(); public static final ArrayList> OPORT_BLOCKS = new ArrayList<>(); public static final ArrayList>> CONTAINERS = new ArrayList<>(); - public static final ArrayList>> PORT_CONTAINERS = new ArrayList>>(); - + public static final ArrayList>> PORT_CONTAINERS = new ArrayList<>(); public static void load() { Path rootPath = FMLPaths.CONFIGDIR.get().resolve("masterful_machinery"); @@ -59,12 +58,17 @@ public class MMLoader { for (JsonObject obj : load) { String controllerId = obj.get("controllerId").getAsString(); String controllerName = obj.get("name").getAsString(); + String texOverride = null; + if (obj.has("textureOverride")) { + texOverride = obj.get("textureOverride").getAsString(); + } + final String textureOverrideFinal = texOverride; { Registerable>> controllerTile = new Registerable<>(); Registerable> controllerBlock = new Registerable<>(); Registerable>> cont = new Registerable<>(); 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))); + controllerBlock.set(MMSetup.BLOCKS_REG.register(controllerId + "_controller", () -> new ControllerBlock(controllerTile.get(), controllerName, controllerId, textureOverrideFinal))); 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()); @@ -77,7 +81,13 @@ public class MMLoader { String type = portObj.get("type").getAsString(); String id = portObj.get("id").getAsString(); String name = portObj.get("name").getAsString(); - + String portTexOverride = null; + if (portObj.has("textureOverride")){ + portTexOverride = portObj.get("name").getAsString(); + } else { + portTexOverride = textureOverrideFinal; + } + final String portTextureOverrideFinal = portTexOverride; ResourceLocation resourceLocation = RLUtils.toRL(type); MasterfulPortType value = MMPorts.PORTS.get(resourceLocation); Supplier data = value.getParser().createStorage(portObj.get("data").getAsJsonObject()); @@ -87,7 +97,7 @@ public class MMLoader { Registerable> block = new Registerable<>(); Registerable>> cont = new Registerable<>(); 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))); + block.set(MMSetup.BLOCKS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> new MachinePortBlock(tile.get(), name, controllerId, portTextureOverrideFinal))); 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()); @@ -99,7 +109,7 @@ public class MMLoader { Registerable> block = new Registerable<>(); Registerable>> cont = new Registerable<>(); 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))); + block.set(MMSetup.BLOCKS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> new MachinePortBlock(tile.get(), name, controllerId, portTextureOverrideFinal))); 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()); diff --git a/wiki_src/content/contact/index.md b/wiki_src/content/contact/index.md deleted file mode 100644 index 77419df..0000000 --- a/wiki_src/content/contact/index.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: "Contact" -description: "Drop us an email." -date: 2020-08-27T19:25:12+02:00 -lastmod: 2020-08-27T19:25:12+02:00 -draft: true -images: [] ---- - diff --git a/wiki_src/content/docs/config/controller.md b/wiki_src/content/docs/config/controller.md deleted file mode 100644 index 5eedaa9..0000000 --- a/wiki_src/content/docs/config/controller.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: "Step By Step" -description: "Config for defining Controllers and Ports." -lead: "All config driven blocks must bge created in the modpack config folder under the masterful_machinery directory/folder." -date: 2020-10-06T08:49:31+00:00 -lastmod: 2020-10-06T08:49:31+00:00 -draft: false -images: [ '/assets/images/screenshot.png'] -menu: - docs: - parent: "config" -weight: 630 -toc: true ---- - -## Why not DataPack For The Blocks? - -In minecraft blocks and items are registered a long time before the datapack's are even loaded. This means that to register blocks and items from JSON files, the mod must have a non-datapack-driven way of creating and configuring those blocks and such. - -# Creating A Controller Block - -Firstly, we must create the block which controls and handles the machines and recipes. This block is called a Controller. - -To create a controller block you must navigate to the following directory/folder relative to the `.minecraft` or the equivalent root directory/folder for your modpack. - -Path: `/config/masterful_machinery/controllers`. - -Once you are inside the above directory. create a new JSON file, you can call it anything you want as long as it ends in `.json`. - -Open the JSON file in your favorite JSON supporting text editor - diff --git a/wiki_src/content/docs/config/examples.md b/wiki_src/content/docs/config/examples.md new file mode 100644 index 0000000..22626cb --- /dev/null +++ b/wiki_src/content/docs/config/examples.md @@ -0,0 +1,16 @@ +--- +title: "Controller & Ports Examples" +description: "Examples of the controllers config files." +lead: "Examples of the controllers config files." +date: 2020-10-06T08:49:31+00:00 +lastmod: 2020-10-06T08:49:31+00:00 +draft: false +images: [] +menu: + docs: + parent: "config" +weight: 650 +toc: true +--- + + diff --git a/wiki_src/content/docs/config/reference.md b/wiki_src/content/docs/config/reference.md new file mode 100644 index 0000000..69a34b6 --- /dev/null +++ b/wiki_src/content/docs/config/reference.md @@ -0,0 +1,14 @@ +--- +title: "Controller & Ports Reference" +description: "A Config file reference to help with understanding each field." +lead: "A Config file reference to help with understanding each field." +date: 2020-10-06T08:49:31+00:00 +lastmod: 2020-10-06T08:49:31+00:00 +draft: false +images: [] +menu: + docs: + parent: "config" +weight: 650 +toc: true +--- diff --git a/wiki_src/content/docs/config/stepbystep.md b/wiki_src/content/docs/config/stepbystep.md new file mode 100644 index 0000000..3e7236b --- /dev/null +++ b/wiki_src/content/docs/config/stepbystep.md @@ -0,0 +1,186 @@ +--- +title: "Controller & Ports Tutorial" +description: "Config for defining Controllers and Ports." +lead: "All config driven blocks must bge created in the modpack config folder under the masterful_machinery directory/folder." +date: 2020-10-06T08:49:31+00:00 +lastmod: 2020-10-06T08:49:31+00:00 +draft: false +images: [] +menu: + docs: + parent: "config" +weight: 630 +toc: true +--- + +## Why not DataPack For The Blocks? + +In minecraft blocks and items are registered a long time before the datapack's are even loaded. This means that to register blocks and items from JSON files, the mod must have a non-datapack-driven way of creating and configuring those blocks and such. + +## Creating A Controller + +Firstly, we must create the block which controls and handles the machines and recipes. This block is called a Controller. + +To create a controller block you must navigate to the following directory/folder relative to the `.minecraft` or the equivalent root directory/folder for your modpack. + +Path: `/config/masterful_machinery/controllers`. + +Once you are inside the above directory. create a new JSON file, you can call it anything you want as long as it ends in `.json`. + +## Writing the JSON File + +Firstly, inside of our newly created json file we must set a unique identifier for the controller: + +```json +{ + "controllerId": "basic" +} +``` + +Controller blocks and items are created with the registry id of the following format: `masterfulmachinery:[controllerId]_controller`. + +Using this format we know that our controller will be created with the block and item ids of `masterfulmachinery:basic_controller` + +Next we must create a more human-readable name for our controller. +To do this amend the previous JSON to match the following. +```json +{ + "controllerId": "basic", + "name": "Basic" +} +``` + +Similarly to the id, the name is created in a defined format. The format for the name is as follows: `[name] Controller`. + +From this we know that the name of our controller with be `Basic Controller` + +However, the file is not ready to be used yet, to make it "bare-minimum" usable (a single controller block) we must add an empty array for our ports. +To do this amend the previous JSON to match the following. + +```json +{ + "controllerId": "basic", + "name": "Basic", + "ports": [] +} +``` + +> The above file is now able to be loaded by the mod and will function as a very useless controller block. + +## Defining Ports + +Ports are a block which allow a player to input and output all sorts of different resources of many different types to and from machines. + +To create ports which are usable to a player, we must add an entry to our `ports` array. +To do this amend the previous JSON to match the following. + +```json +{ + "controllerId": "basic", + "name": "Basic", + "ports": [ + { + + } + ] +} +``` + +In it's current state the empty JSON object will crash the game, but it is a good demonstration of JSON and it's format. + +Next we must define a type field, this will tell the mod what type of port we want to create (item/fluid/energy/etc.) within the JSON object. +To do this amend the previous JSON to match the following. + +```json +{ + "controllerId": "basic", + "name": "Basic", + "ports": [ + { + "type": "masterfulmachinery:items" + } + ] +} +``` + +The type defined above is that of an item port, this is similar to a chest and will contain slots which can store stacks of items. + +> To see a list of available port types [Click Here](/docs/config/types) + +Next we must set a unqiue id for our port, this is is relative to the port type and controller. +To do this amend the previous JSON to match the following. + +```json +{ + "controllerId": "basic", + "name": "Basic", + "ports": [ + { + "type": "masterfulmachinery:items", + "id": "small" + } + ] +} +``` + +Port block/item ids are formatted as follows: `masterfulmachinery:[controllerId]_[id]_port_[type]_[input/output]` + +With this in mind we know the above ports will have the ids of: +- `mastefulmachinery:basic_small_port_items_input` +- `mastefulmachinery:basic_small_port_items_output` + +Keep in mind the fact that 1 port definition will make 2 blocks and items, 1 for input, 1 for output. + +Also keep in mind that the id of a port only has to be unique within the same port type and controller, so if you have 3 port with different types they could have the same id. Also if you have 2 different controllers with a port of the same type each, you can give those the same id ad they will not clash due to the rather lengthy concatination of the name. + +Next we must define a human-readable name for our Port. +To do this amend the previous JSON to match the following. + +```json +{ + "controllerId": "basic", + "name": "Basic", + "ports": [ + { + "type": "masterfulmachinery:items", + "id": "small", + "name": "Small" + } + ] +} +``` + +The ingame name of the block will be formatted as follows: `[controller name] - [port name] [port type name] Input/Output`. with this in mind we know that the port blocks will be created with the following names for the above config: +- `Basic - Small Item Input` +- `Basic - Small Item Output` + +The next section gets a little confusing due to the dynamic nature of the mod. We must define the limits/config/data for the ports we want to create. + +Different port types have different fields within the `data` JSON object. For item ports we can do the following: + + +```json +{ + "controllerId": "basic", + "name": "Basic", + "ports": [ + { + "type": "masterfulmachinery:items", + "id": "small", + "name": "Small", + "data": { + "rows": 3, + "columns": 4 + } + } + ] +} +``` + +This will create both input and outputs ports of this type and tier have a chest layout of 3 rows and 4 columns. + +> For each port type's data section's fields, [Click Here](/docs/config/types/#controllers-file-config-data-section) + +Now run the game with this config and you should get a result of 1 `Basic Controller` and 2 Port blocks with chest like inventories (when clicked) of 3 rows and 4 columns. + +For m,ore/larger examples [Click Here](/docs/config/types/#controllers-file-config-data-section) \ No newline at end of file diff --git a/wiki_src/content/docs/config/types.md b/wiki_src/content/docs/config/types.md new file mode 100644 index 0000000..8d20e9a --- /dev/null +++ b/wiki_src/content/docs/config/types.md @@ -0,0 +1,81 @@ +--- +title: "Port Types" +description: "A list of the available port types in Masterful Machinery." +lead: "A list of the available port types in Masterful Machinery." +date: 2020-10-06T08:49:31+00:00 +lastmod: 2020-10-06T08:49:31+00:00 +draft: false +images: [] +menu: + docs: + parent: "config" +weight: 660 +toc: true +--- + +- `masterfulmachinery:items` (Item Ports) +- `masterfulmachinery:fluids` (Fluid Ports) +- `masterfulmachinery:energy` (Forge Energy Ports) +- `masterfulmachinery:mekanism_gas` (Mekanism Gas Ports) +- `masterfulmachinery:mekanism_slurry` (Mekanism Slurry Ports) + + +## Controllers File Config Data Section + +- `masterfulmachinery:items` (Item Ports) + +```json +{ + "rows": INTEGER, + "columns": INTEGER +} +``` + +Replace `INTEGER` with a whole number (integer) for example: `6` or `9` + +--- + +- `masterfulmachinery:fluids` (Fluid Ports) +```json +{ + "capacity": INTEGER +} +``` + +Replace `INTEGER` with a whole number (integer) for example: `10000` or `1000000` + +--- +- `masterfulmachinery:energy` (Forge Energy Ports) + +```json +{ + "capacity": INTEGER +} +``` + +Replace `INTEGER` with a whole number (integer) for example: `10000` or `1000000` + +--- + +- `masterfulmachinery:mekanism_gas` (Mekanism Gas Ports) + +```json +{ + "capacity": INTEGER +} +``` + +Replace `INTEGER` with a whole number (integer) for example: `10000` or `1000000` + +--- + +- `masterfulmachinery:mekanism_slurry` (Mekanism Slurry Ports) +```json +{ + "capacity": INTEGER +} +``` + +Replace `INTEGER` with a whole number (integer) for example: `10000` or `1000000` + +--- \ No newline at end of file