mirror of
https://github.com/TicTicBoooom-Mods/MasterfulMachinery.git
synced 2026-01-18 16:37:23 +01:00
Minor refactor
This commit is contained in:
@@ -17,7 +17,6 @@ import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
@@ -43,20 +42,21 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (world.isRemote()){
|
||||
if (world.isRemote()) {
|
||||
return;
|
||||
}
|
||||
|
||||
update.setMsg("Failed to construct \nthe machine");
|
||||
List<MachineStructureRecipe> recipes = world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_STRUCTURE);
|
||||
for (MachineStructureRecipe recipe : recipes) {
|
||||
int index = recipe.matches(this.pos, world, controllerId);
|
||||
List<MachineStructureRecipe> structures = world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_STRUCTURE);
|
||||
for (MachineStructureRecipe structure : structures) {
|
||||
int index = structure.matches(this.pos, world, controllerId);
|
||||
if (index != -1) {
|
||||
if (!update.getSid().equals(recipe.getId().toString())){
|
||||
if (!update.getSid().equals(structure.getId().toString())) {
|
||||
update.setTicksTaken(0);
|
||||
}
|
||||
update.setSid(recipe.getId().toString());
|
||||
update.setSid(structure.getId().toString());
|
||||
update.setMsg("Found structure");
|
||||
onStructureFound(recipe, index);
|
||||
onStructureFound(structure, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
|
||||
boolean processed = false;
|
||||
for (MachineProcessRecipe recipe : processRecipes) {
|
||||
if (recipe.matches(inputPorts, structure.getStructureId(), update)) {
|
||||
if (!update.getId().equals(recipe.getId().toString())){
|
||||
if (!update.getId().equals(recipe.getId().toString())) {
|
||||
update.setTicksTaken(0);
|
||||
}
|
||||
this.update.setId(recipe.getId().toString());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ticticboooom.mods.mm.client.jei.category;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.block.ControllerBlock;
|
||||
import com.ticticboooom.mods.mm.block.MachinePortBlock;
|
||||
@@ -22,6 +23,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.DirectionalBlock;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.state.Property;
|
||||
@@ -29,6 +31,7 @@ import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ITag;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
@@ -108,8 +111,8 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout iRecipeLayout, MachineStructureRecipe recipe, IIngredients iIngredients) {
|
||||
this.xRotation = 0;
|
||||
this.yRotation = 0;
|
||||
this.xRotation = -225;
|
||||
this.yRotation = 15;
|
||||
this.yLastMousePosition = 0;
|
||||
this.xLastMousePosition = 0;
|
||||
this.scaleFactor = 1.2f;
|
||||
@@ -183,7 +186,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
double relMoveY = mouseY - yLastMousePosition;
|
||||
prePos.add((float)relMoveX * 0.08f, (float)-relMoveY * 0.08f, 0);
|
||||
}
|
||||
Vector3f offset = new Vector3f(-minX - 0.5f - centreX, -minY - 0.5f - centerY, -minZ - 0.5f + centreZ);
|
||||
Vector3f offset = new Vector3f(-minX - 0.5f - centreX, -minY - 0.5f - centerY, minZ - 0.5f + centreZ);
|
||||
|
||||
Vector4f zero = new Vector4f(0, 0, 0, 1);
|
||||
zero.transform(matrixStack.getLast().getMatrix().copy());
|
||||
@@ -244,6 +247,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Render the controller block
|
||||
if (sliceY == 0) {
|
||||
ControllerBlock block = null;
|
||||
@@ -266,6 +270,10 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
}
|
||||
GLScissor.disable();
|
||||
|
||||
// Render hover block outline
|
||||
AxisAlignedBB structureAABB = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
renderHoverOutline(matrixStack);
|
||||
|
||||
// End tick
|
||||
xLastMousePosition = mouseX;
|
||||
yLastMousePosition = mouseY;
|
||||
@@ -283,8 +291,15 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
return false;
|
||||
}
|
||||
|
||||
private void startIncrementSlice() {
|
||||
private void renderHoverOutline(MatrixStack ms) {
|
||||
//float tx = 6.75f, ty = -5, tz = 10;
|
||||
float tx = 0, ty = 0, tz = 0;
|
||||
IVertexBuilder buf = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource().getBuffer(RenderType.getLines());
|
||||
//buf.pos(tx, ty, tz).color(255, 255, 255, 255).endVertex();
|
||||
//buf.pos(ms.getLast().getMatrix(), tx, ty, tz).color(255, 255, 255, 255).endVertex();
|
||||
}
|
||||
|
||||
private void startIncrementSlice() {
|
||||
int topY = Integer.MIN_VALUE;
|
||||
int bottomY = Integer.MAX_VALUE;
|
||||
|
||||
@@ -329,8 +344,8 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
private void renderBlock(BlockState defaultState, BlockPos bp, Vector3f prePos, Vector3f offset, MatrixStack ms) {
|
||||
new GuiBlockRenderBuilder(defaultState).at(bp)
|
||||
.withPrePosition(prePos)
|
||||
.withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true))
|
||||
.withRotation(new Quaternion(new Vector3f(0, -1, 0), 225 - xRotation, true))
|
||||
.withRotation(new Quaternion(new Vector3f(1, 0, 0), yRotation, true))
|
||||
.withRotation(new Quaternion(new Vector3f(0, -1, 0), -xRotation, true))
|
||||
.withScale(new Vector3f(scaleFactor, -scaleFactor, scaleFactor))
|
||||
.withOffset(offset)
|
||||
.finalize(ms);
|
||||
|
||||
@@ -152,8 +152,6 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
|
||||
boolean canTick = true;
|
||||
|
||||
|
||||
|
||||
|
||||
index = 0;
|
||||
for (PortState input : inputs) {
|
||||
if (input.isConsumePerTick()) {
|
||||
|
||||
23
src/test/resources/data/mm/recipes/output_dupe.json
Normal file
23
src/test/resources/data/mm/recipes/output_dupe.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"type": "masterfulmachinery:machine_process",
|
||||
"structureId": "test_all",
|
||||
"controllerId": "basic",
|
||||
"ticks": 1,
|
||||
"inputs": [
|
||||
{
|
||||
"type": "masterfulmachinery:fluids",
|
||||
"data": {
|
||||
"fluid": "mekanism:steam",
|
||||
"amount": 5
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"type": "masterfulmachinery:energy",
|
||||
"data": {
|
||||
"amount": 10
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"type": "masterfulmachinery:machine_structure",
|
||||
"id": "botanist_furnace_structure",
|
||||
"controllerId": "botanist_furnace",
|
||||
"name": "Botanist's Furnace",
|
||||
"layout": [
|
||||
[
|
||||
")))))",
|
||||
")***)",
|
||||
"+++++",
|
||||
",))))"
|
||||
],
|
||||
[
|
||||
"-----",
|
||||
".///0",
|
||||
"1 1",
|
||||
"2333C"
|
||||
],
|
||||
[
|
||||
"4---4",
|
||||
"5 5",
|
||||
"1 1",
|
||||
"13331"
|
||||
],
|
||||
[
|
||||
" 4-4 ",
|
||||
" 676 ",
|
||||
" 181 ",
|
||||
" 111 "
|
||||
]
|
||||
],
|
||||
"legend": {
|
||||
")": {
|
||||
"block": "botania:livingrock"
|
||||
},
|
||||
"*": {
|
||||
"block": "minecraft:redstone_block"
|
||||
},
|
||||
"+": {
|
||||
"block": "create:belt"
|
||||
},
|
||||
",": {
|
||||
"block": "create:gearbox"
|
||||
},
|
||||
"-": {
|
||||
"block": "minecraft:cobblestone"
|
||||
},
|
||||
".": {
|
||||
"block": "masterfulmachinery:botanist_furnace_botanist_furnace_item_port_items_input"
|
||||
},
|
||||
"/": {
|
||||
"block": "minecraft:campfire"
|
||||
},
|
||||
"0": {
|
||||
"block": "masterfulmachinery:botanist_furnace_botanist_furnace_item_port_items_output"
|
||||
},
|
||||
"1": {
|
||||
"block": "botania:livingrock_stairs"
|
||||
},
|
||||
"2": {
|
||||
"block": "masterfulmachinery:botanist_furnace_botanist_furnace_rotation_port_create_rotation_input"
|
||||
},
|
||||
"3": {
|
||||
"block": "create:framed_glass"
|
||||
},
|
||||
"4": {
|
||||
"block": "minecraft:cobblestone"
|
||||
},
|
||||
"5": {
|
||||
"block": "minecraft:jack_o_lantern"
|
||||
},
|
||||
"6": {
|
||||
"block": "minecraft:cobblestone"
|
||||
},
|
||||
"7": {
|
||||
"block": "botania:mana_spreader"
|
||||
},
|
||||
"8": {
|
||||
"block": "masterfulmachinery:botanist_furnace_botanist_furnace_mana_port_botania_mana_input"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"type": "masterfulmachinery:machine_structure",
|
||||
"id": "botanist_rotational_generator_structure",
|
||||
"controllerId": "botanist_rotational_generator",
|
||||
"name": "botanist's Rotational Generator",
|
||||
"layout": [
|
||||
[
|
||||
" ",
|
||||
")))",
|
||||
" "
|
||||
],
|
||||
[
|
||||
")))",
|
||||
"*+,",
|
||||
")C)"
|
||||
],
|
||||
[
|
||||
" ",
|
||||
")1)",
|
||||
" "
|
||||
]
|
||||
],
|
||||
"legend": {
|
||||
")": {
|
||||
"block": "create:andesite_casing"
|
||||
},
|
||||
"*": {
|
||||
"block": "masterfulmachinery:botanist_rotational_generator_botanist_rotational_generator_mana_port_botania_mana_input"
|
||||
},
|
||||
"+": {
|
||||
"block": "create:shaft"
|
||||
},
|
||||
",": {
|
||||
"block": "masterfulmachinery:botanist_rotational_generator_botanist_rotational_generator_rotation_port_create_rotation_output"
|
||||
},
|
||||
"1": {
|
||||
"block": "create:framed_glass"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,9 @@
|
||||
"layout": [
|
||||
[
|
||||
"1C2"
|
||||
],
|
||||
[
|
||||
" T "
|
||||
]
|
||||
],
|
||||
"legend": {
|
||||
@@ -14,6 +17,9 @@
|
||||
},
|
||||
"2": {
|
||||
"block": "masterfulmachinery:basic_simple_port_create_rotation_output"
|
||||
},
|
||||
"T": {
|
||||
"block": "create:deployer"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@
|
||||
"name": "Variable IO",
|
||||
"layout": [
|
||||
[
|
||||
")C)",
|
||||
")*)",
|
||||
"*+*",
|
||||
")*)"
|
||||
")C)"
|
||||
],
|
||||
[
|
||||
"),)",
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"type": "masterfulmachinery:machine_structure",
|
||||
"id": "weak_coke_oven_structure",
|
||||
"controllerId": "weak_coke_oven",
|
||||
"name": "Weak Coke Oven",
|
||||
"layout": [
|
||||
[
|
||||
")*)",
|
||||
"+,-",
|
||||
".,/"
|
||||
],
|
||||
[
|
||||
")))",
|
||||
"0 0",
|
||||
"1C1"
|
||||
],
|
||||
[
|
||||
")))",
|
||||
"212",
|
||||
" "
|
||||
]
|
||||
],
|
||||
"legend": {
|
||||
"0": {
|
||||
"block": "botania:drum_wild"
|
||||
},
|
||||
"1": {
|
||||
"block": "botania:livingwood_planks_stairs"
|
||||
},
|
||||
"2": {
|
||||
"block": "botania:livingrock_stairs"
|
||||
},
|
||||
")": {
|
||||
"block": "botania:livingrock_bricks"
|
||||
},
|
||||
"*": {
|
||||
"block": "masterfulmachinery:weak_coke_oven_weak_coke_oven_mana_port_botania_mana_input"
|
||||
},
|
||||
"+": {
|
||||
"block": "masterfulmachinery:weak_coke_oven_weak_coke_oven_fluid_port_fluids_input"
|
||||
},
|
||||
",": {
|
||||
"block": "botania:livingwood_planks"
|
||||
},
|
||||
"-": {
|
||||
"block": "masterfulmachinery:weak_coke_oven_weak_coke_oven_fluid_port_fluids_output"
|
||||
},
|
||||
".": {
|
||||
"block": "masterfulmachinery:weak_coke_oven_weak_coke_oven_item_port_items_input"
|
||||
},
|
||||
"/": {
|
||||
"block": "masterfulmachinery:weak_coke_oven_weak_coke_oven_item_port_items_output"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
#Thu Oct 21 09:55:37 BST 2021
|
||||
VERSION_CODE=851
|
||||
#Fri Oct 29 13:28:32 BST 2021
|
||||
VERSION_CODE=858
|
||||
|
||||
Reference in New Issue
Block a user