mirror of
https://github.com/TicTicBoooom-Mods/MasterfulMachinery.git
synced 2026-01-19 00:47:25 +01:00
added input/output rendering onto ports
This commit is contained in:
@@ -4,10 +4,16 @@ import com.ticticboooom.mods.mm.setup.MMTiles;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class PortBlock extends Block {
|
||||
|
||||
@@ -25,4 +31,6 @@ public class PortBlock extends Block {
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return MMTiles.PORT.get().create();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class MMItemGroup extends ItemGroup {
|
||||
ItemStack stack = new ItemStack(MMItems.PORT.get());
|
||||
CompoundNBT tag = stack.getOrCreateTag();
|
||||
tag.putString("Port", entry.getValue().id.toString());
|
||||
stack.setDisplayName(entry.getValue().name);
|
||||
controllers.add(stack);
|
||||
}
|
||||
return controllers;
|
||||
|
||||
@@ -2,12 +2,14 @@ package com.ticticboooom.mods.mm.block.item;
|
||||
|
||||
import com.ticticboooom.mods.mm.block.tile.PortTile;
|
||||
import com.ticticboooom.mods.mm.data.DataRegistry;
|
||||
import com.ticticboooom.mods.mm.data.model.PortModel;
|
||||
import com.ticticboooom.mods.mm.setup.MMBlocks;
|
||||
import com.ticticboooom.mods.mm.util.TagHelper;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@@ -40,13 +40,11 @@ public class PortBlockModel implements IDynamicBakedModel {
|
||||
PortModel port = data.getData(PORT);
|
||||
if (data.hasProperty(PORT) && port != null) {
|
||||
PortType portType = PortTypeRegistry.PORT_TYPES.get(port.type);
|
||||
if (data.hasProperty(PORT_IO_TYPE)) {
|
||||
Boolean isInput = data.getData(PORT_IO_TYPE);
|
||||
if (isInput != null && isInput) {
|
||||
quads.add(ModelTools.createQuad(portType.getInputCutout(), side));
|
||||
} else {
|
||||
quads.add(ModelTools.createQuad(portType.getOutputCutout(), side));
|
||||
}
|
||||
boolean isInput = port.input;
|
||||
if (isInput) {
|
||||
quads.add(ModelTools.createQuad(portType.getInputCutout(), side));
|
||||
} else {
|
||||
quads.add(ModelTools.createQuad(portType.getOutputCutout(), side));
|
||||
}
|
||||
}
|
||||
return quads;
|
||||
|
||||
@@ -30,4 +30,6 @@ public class PortTile extends TileEntity implements ITickableTileEntity {
|
||||
.withInitial(PortBlockModel.PORT_IO_TYPE, isInput)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,4 +11,5 @@ public class PortModel {
|
||||
public ITextComponent name;
|
||||
public BlockstateModel defaultModel;
|
||||
public boolean showCutout;
|
||||
public boolean input;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public class PortReloadListener extends JsonReloadListener {
|
||||
model.controllerId = ResourceLocation.tryCreate(json.get("controllerId").getAsString());
|
||||
model.defaultModel = ParserUtils.parseOrDefault(json, "defaultModel", (x) -> ParserUtils.parseBlockState(x.getAsJsonObject()), BlockstateModel.DEFAULT);
|
||||
model.showCutout = ParserUtils.parseOrDefault(json, "showCutout", JsonElement::getAsBoolean, true);
|
||||
model.input = ParserUtils.parseOrDefault(json, "isInput", JsonElement::getAsBoolean, false);
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
10
src/test/resources/data/test/mm/port_tiers/fluid_input.json
Normal file
10
src/test/resources/data/test/mm/port_tiers/fluid_input.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"controllerId": "test:main",
|
||||
"name": "Main Fluids",
|
||||
"type": "mm:fluids",
|
||||
"defaultModel": {
|
||||
"block": "minecraft:sponge",
|
||||
"properties": {}
|
||||
},
|
||||
"isInput": true
|
||||
}
|
||||
@@ -5,5 +5,6 @@
|
||||
"defaultModel": {
|
||||
"block": "minecraft:sponge",
|
||||
"properties": {}
|
||||
}
|
||||
},
|
||||
"isInput": true
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"controllerId": "test:main",
|
||||
"name": "Main Items",
|
||||
"type": "mm:items",
|
||||
"defaultModel": {
|
||||
"block": "minecraft:sponge",
|
||||
"properties": {}
|
||||
},
|
||||
"isInput": false
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
#Tue Apr 12 13:18:55 BST 2022
|
||||
VERSION_CODE=1454
|
||||
#Wed Apr 13 11:31:27 BST 2022
|
||||
VERSION_CODE=1470
|
||||
|
||||
Reference in New Issue
Block a user