structure detection closer to mvp

This commit is contained in:
ticticboooom
2022-04-15 16:24:26 +01:00
parent baa5c73fcc
commit 6c06a08206
5 changed files with 20 additions and 34 deletions

View File

@@ -27,7 +27,6 @@ import java.util.Random;
public class PortBlockModel implements IDynamicBakedModel {
public static final ModelProperty<PortModel> PORT = new ModelProperty<>();
public static final ModelProperty<Boolean> PORT_IO_TYPE = new ModelProperty<>();
public static final PortItemOverrideList OVERRIDE_LIST = new PortItemOverrideList();
@Nonnull

View File

@@ -91,7 +91,7 @@ public class ControllerTile extends TileEntity implements ITickableTileEntity, I
}
} else {
if (blockState.getBlock().getRegistryName().toString().equals(s)) {
matches = true;
matches = true;
}
}
}
@@ -101,12 +101,12 @@ public class ControllerTile extends TileEntity implements ITickableTileEntity, I
private boolean isValidPort(StructureKeyTypeValue dataIn, StructureModel model, BlockState blockState, BlockPos pos) {
PortStructureKeyType.Value data = (PortStructureKeyType.Value) dataIn;
if (blockState.getBlock().getRegistryName().equals(MMBlocks.PORT.getId())) {
TileEntity te = world.getTileEntity(pos);
TileEntity te = world.getTileEntity(this.pos.add(pos));
if (te instanceof PortTile) {
PortTile pte = (PortTile) te;
boolean io = true;
if (data.input.isPresent()) {
io = data.input.get() == pte.isInput;
io = data.input.get() == pte.portModel.input;
}
return io && pte.portModel.type.equals(data.port);
}
@@ -117,12 +117,12 @@ public class ControllerTile extends TileEntity implements ITickableTileEntity, I
private boolean isValidPortTier(StructureKeyTypeValue dataIn, StructureModel model, BlockState blockState, BlockPos pos) {
PortTierStructureKeyType.Value data = (PortTierStructureKeyType.Value) dataIn;
if (blockState.getBlock().getRegistryName().equals(MMBlocks.PORT.getId())) {
TileEntity te = world.getTileEntity(pos);
TileEntity te = world.getTileEntity(this.pos.add(pos));
if (te instanceof PortTile) {
PortTile pte = (PortTile) te;
boolean io = true;
if (data.input.isPresent()) {
io = data.input.get() == pte.isInput;
io = data.input.get() == pte.portModel.input;
}
return io && pte.portModel.id.equals(data.portTier);
}
@@ -132,18 +132,22 @@ public class ControllerTile extends TileEntity implements ITickableTileEntity, I
private boolean isValidPortGroup(StructureKeyTypeValue dataIn, StructureModel model, BlockState blockState, BlockPos pos) {
PortGroupStructureKeyType.Value data = (PortGroupStructureKeyType.Value) dataIn;
TileEntity te = world.getTileEntity(pos);
TileEntity te = world.getTileEntity(this.pos.add(pos));
if (te instanceof PortTile) {
PortTile pte = (PortTile) te;
List<String> reqKeys = model.portGroupings.get(data.group);
for (String reqKey : reqKeys) {
StructureModel.RequiredPort requiredPort = model.requiredPorts.get(reqKey);
if (!requiredPort.port.equals(pte.portModel.type)) {
if (requiredPort != null && !requiredPort.port.equals(pte.portModel.type)) {
return false;
}
return requiredPort.tiers.contains(pte.portModel.id);
boolean matches = false;
for (ResourceLocation tier : requiredPort.tiers) {
if (tier.toString().equals(pte.portModel.id.toString())) {
matches = true;
}
}
return matches;
}
}
return false;
@@ -212,7 +216,7 @@ public class ControllerTile extends TileEntity implements ITickableTileEntity, I
private boolean isValidBlockPlacement(StructureModel model) {
Rotation rotation = Rotation.NONE;
for (int i = 0; i < 4; i++) {
boolean found = true;
boolean found = true;
for (StructureModel.PositionedKey positionedKey : rotateKeys(model, rotation)) {
if (!isValidBlockSingleWithKey(positionedKey, model)) {
found = false;

View File

@@ -16,7 +16,6 @@ public class PortTile extends TileEntity implements ITickableTileEntity {
}
public PortModel portModel;
public boolean isInput;
@Override
public void tick() {
@@ -27,7 +26,6 @@ public class PortTile extends TileEntity implements ITickableTileEntity {
public IModelData getModelData() {
return new ModelDataMap.Builder()
.withInitial(PortBlockModel.PORT, portModel)
.withInitial(PortBlockModel.PORT_IO_TYPE, isInput)
.build();
}

View File

@@ -26,7 +26,7 @@
]
},
"B": "minecraft:glass",
"D": "#minecraft:wools",
"D": "#minecraft:wool",
"E": {
"include": "#minecraft:logs",
"exclude": [
@@ -39,7 +39,7 @@
},
"G": {
"type": "mm:port_tier",
"portTier": "test:item_main",
"portTier": "test:item_main_output",
"input": false
},
"H": {
@@ -74,22 +74,17 @@
"port": "mm:items",
"input": true,
"tiers": [
"mm:item_main"
"test:item_main_input"
]
},
"second": {
"port": "mm:fluids",
"port": "mm:items",
"input": false
},
"third": {
"port": "mm:fluids",
"input": true
}
},
"portGroupings": {
"mygroup": [
"first",
"third"
"first"
]
}
}

View File

@@ -1,10 +0,0 @@
{
"controllerId": "test:main",
"name": "Main Fluids",
"type": "mm:fluids",
"defaultModel": {
"block": "minecraft:sponge",
"properties": {}
},
"isInput": true
}