mirror of
https://github.com/TicTicBoooom-Mods/MasterfulMachinery.git
synced 2026-03-18 21:40:34 +01:00
fixed some bugs and started nbt support
This commit is contained in:
38
build.gradle
38
build.gradle
@@ -20,7 +20,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
version = '1.16.5-0.1.35-T' + System.currentTimeMillis()
|
||||
version = '1.16.5-0.1.39-B' + getVersionNumber()
|
||||
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'MasterfulMachinery'
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8.
|
||||
@@ -152,6 +152,19 @@ repositories {
|
||||
url "https://maven.theillusivec4.top/"
|
||||
}
|
||||
maven { url 'https://maven.blamejared.com' }
|
||||
maven {
|
||||
url = "https://maven.saps.dev/minecraft"
|
||||
content {
|
||||
includeGroup "dev.latvian.mods"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
// Shedaniel's maven (Architectury API)
|
||||
url = "https://maven.architectury.dev"
|
||||
content {
|
||||
includeGroup "me.shedaniel"
|
||||
}
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
||||
@@ -175,7 +188,7 @@ dependencies {
|
||||
|
||||
implementation fg.deobf("curse.maven:create-328085:3278516")
|
||||
|
||||
implementation fg.deobf("curse.maven:astral-sorcery-241721:3156477")
|
||||
compileOnly fg.deobf("curse.maven:astral-sorcery-241721:3156477")
|
||||
implementation fg.deobf("curse.maven:observerlib-316833:3162044")
|
||||
// runtime deps
|
||||
runtimeOnly fg.deobf("curse.maven:curios-309927:3231111")
|
||||
@@ -184,6 +197,10 @@ dependencies {
|
||||
|
||||
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.16.4-51")
|
||||
|
||||
|
||||
implementation "dev.latvian.mods:rhino:1605.1.0-build.4"
|
||||
implementation fg.deobf("me.shedaniel:architectury-forge:v1.15.13")
|
||||
implementation fg.deobf("dev.latvian.mods:kubejs-forge:1605.3.10-build.8")
|
||||
// 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"
|
||||
@@ -243,4 +260,21 @@ reobf {
|
||||
dependsOn createMcpToSrg
|
||||
mappings = createMcpToSrg.outputs.files.singleFile
|
||||
}
|
||||
}
|
||||
|
||||
def getVersionNumber() {
|
||||
def vFile = file('version.properties')
|
||||
def Integer buildNumber = 0
|
||||
if (vFile.canRead()){
|
||||
def Properties versionProps = new Properties();
|
||||
|
||||
versionProps.load(new FileInputStream(vFile))
|
||||
|
||||
def code = versionProps.getProperty("VERSION_CODE").toInteger() + 1
|
||||
buildNumber = code
|
||||
versionProps.setProperty("VERSION_CODE", code.toString())
|
||||
|
||||
versionProps.store(vFile.newWriter(), null)
|
||||
}
|
||||
return buildNumber.toString()
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.ticticboooom.mods.mm;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.Gson;
|
||||
import com.ticticboooom.mods.mm.block.ControllerBlock;
|
||||
import com.ticticboooom.mods.mm.block.MachinePortBlock;
|
||||
import com.ticticboooom.mods.mm.block.container.ControllerBlockContainer;
|
||||
@@ -50,7 +51,7 @@ import java.io.IOException;
|
||||
public class MM {
|
||||
public static final String ID = "masterfulmachinery";
|
||||
public static final Logger LOG = LogManager.getLogger("Masterful Machinery");
|
||||
|
||||
public static final Gson GSON = new Gson();
|
||||
|
||||
private DataGenerator generator;
|
||||
private static boolean hasGenerated = false;
|
||||
@@ -113,11 +114,11 @@ public class MM {
|
||||
}
|
||||
|
||||
for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) {
|
||||
RenderTypeLookup.setRenderLayer(block.get(), layer ->layer == RenderType.getCutout() || layer == RenderType.getSolid() || layer == RenderType.getTranslucent());
|
||||
RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.getSolid() || layer == RenderType.getTranslucent());
|
||||
}
|
||||
|
||||
for (RegistryObject<MachinePortBlock> block : MMLoader.IPORT_BLOCKS) {
|
||||
RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.getCutout() || layer == RenderType.getSolid() || layer == RenderType.getTranslucent());
|
||||
RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.getSolid() || layer == RenderType.getTranslucent());
|
||||
}
|
||||
|
||||
for (RegistryObject<MachinePortBlock> block : MMLoader.OPORT_BLOCKS) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.ticticboooom.mods.mm.block;
|
||||
|
||||
import com.ticticboooom.mods.mm.block.tile.MachinePortBlockEntity;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.StarlightPortStorage;
|
||||
import hellfirepvp.astralsorcery.common.block.base.BlockStarlightRecipient;
|
||||
import hellfirepvp.astralsorcery.common.constellation.IWeakConstellation;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class AstralMachinePortBlock extends MachinePortBlock implements BlockStarlightRecipient {
|
||||
public AstralMachinePortBlock(RegistryObject<TileEntityType<?>> type, String name, String controllerId, String textureOverride, ResourceLocation overlay) {
|
||||
super(type, name, controllerId, textureOverride, overlay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveStarlight(World world, Random random, BlockPos blockPos, IWeakConstellation iWeakConstellation, double v) {
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if (tile instanceof MachinePortBlockEntity){
|
||||
PortStorage storage = ((MachinePortBlockEntity) tile).getStorage();
|
||||
if (!((MachinePortBlockEntity) tile).isInput()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (storage instanceof StarlightPortStorage) {
|
||||
StarlightPortStorage starlightStorage = (StarlightPortStorage) storage;
|
||||
int rec = new Double(v).intValue();
|
||||
starlightStorage.getInv().receiveStarlight(rec, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,10 +39,8 @@ public class ControllerBlock extends DirectionalBlock {
|
||||
private String controllerId;
|
||||
@Getter
|
||||
private String texOverride;
|
||||
@Getter
|
||||
private ModelOverrideModel modelOverride;
|
||||
|
||||
public ControllerBlock(RegistryObject<TileEntityType<?>> type, String name, String id, String texOverride, ModelOverrideModel modelOverride) {
|
||||
public ControllerBlock(RegistryObject<TileEntityType<?>> type, String name, String id, String texOverride) {
|
||||
super(AbstractBlock.Properties.create(Material.IRON)
|
||||
.harvestLevel(1)
|
||||
.harvestTool(ToolType.PICKAXE));
|
||||
@@ -50,7 +48,6 @@ public class ControllerBlock extends DirectionalBlock {
|
||||
this.controllerName = name;
|
||||
this.controllerId = id;
|
||||
this.texOverride = texOverride;
|
||||
this.modelOverride = modelOverride;
|
||||
this.setDefaultState(this.getDefaultState().with(FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,6 @@ package com.ticticboooom.mods.mm.block;
|
||||
|
||||
import com.ticticboooom.mods.mm.block.tile.MachinePortBlockEntity;
|
||||
import com.ticticboooom.mods.mm.inventory.ItemStackInventory;
|
||||
import com.ticticboooom.mods.mm.model.ModelOverrideModel;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.StarlightPortStorage;
|
||||
import hellfirepvp.astralsorcery.common.block.base.BlockStarlightRecipient;
|
||||
import hellfirepvp.astralsorcery.common.constellation.IWeakConstellation;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -23,7 +18,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
@@ -31,9 +25,8 @@ import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
public class MachinePortBlock extends Block implements BlockStarlightRecipient {
|
||||
public class MachinePortBlock extends Block {
|
||||
private RegistryObject<TileEntityType<?>> type;
|
||||
@Getter
|
||||
private String langName;
|
||||
@@ -44,17 +37,13 @@ public class MachinePortBlock extends Block implements BlockStarlightRecipient {
|
||||
@Getter
|
||||
private ResourceLocation overlay;
|
||||
|
||||
@Getter
|
||||
private final ModelOverrideModel modelOverride;
|
||||
|
||||
public MachinePortBlock(RegistryObject<TileEntityType<?>> type, String name, String controllerId, String textureOverride, ResourceLocation overlay, ModelOverrideModel modelOverride) {
|
||||
public MachinePortBlock(RegistryObject<TileEntityType<?>> type, String name, String controllerId, String textureOverride, ResourceLocation overlay) {
|
||||
super(AbstractBlock.Properties.create(Material.IRON));
|
||||
this.type = type;
|
||||
this.langName = name;
|
||||
this.controllerId = controllerId;
|
||||
this.textureOverride = textureOverride;
|
||||
this.overlay = overlay;
|
||||
this.modelOverride = modelOverride;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,21 +97,4 @@ public class MachinePortBlock extends Block implements BlockStarlightRecipient {
|
||||
((MachinePortBlockEntity) tile).getStorage().neighborChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveStarlight(World world, Random random, BlockPos blockPos, IWeakConstellation iWeakConstellation, double v) {
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if (tile instanceof MachinePortBlockEntity){
|
||||
PortStorage storage = ((MachinePortBlockEntity) tile).getStorage();
|
||||
if (!((MachinePortBlockEntity) tile).isInput()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (storage instanceof StarlightPortStorage) {
|
||||
StarlightPortStorage starlightStorage = (StarlightPortStorage) storage;
|
||||
int rec = new Double(v).intValue();
|
||||
starlightStorage.getInv().receiveStarlight(rec, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ import vazkii.botania.api.mana.IManaReceiver;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class MachinePortBlockEntity extends UpdatableTile implements ITickableTileEntity, INamedContainerProvider, IManaReceiver {
|
||||
public class MachinePortBlockEntity extends UpdatableTile implements ITickableTileEntity, INamedContainerProvider {
|
||||
|
||||
private ContainerType<?> container;
|
||||
protected ContainerType<?> container;
|
||||
@Getter
|
||||
private PortStorage storage;
|
||||
protected PortStorage storage;
|
||||
@Getter
|
||||
private boolean input;
|
||||
protected boolean input;
|
||||
|
||||
|
||||
public MachinePortBlockEntity(TileEntityType<?> p_i48289_1_, ContainerType<?> container, PortStorage storage, boolean input) {
|
||||
@@ -81,35 +81,4 @@ public class MachinePortBlockEntity extends UpdatableTile implements ITickableTi
|
||||
this.getStorage().tick(this);
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull() {
|
||||
if (storage instanceof ManaPortStorage) {
|
||||
ManaPortStorage s = (ManaPortStorage) storage;
|
||||
return s.getInv().getManaStored() == s.getInv().getMaxManaStored();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveMana(int mana) {
|
||||
if (storage instanceof ManaPortStorage && this.isInput()) {
|
||||
ManaPortStorage s = (ManaPortStorage) storage;
|
||||
s.getInv().receiveMana(mana, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveManaFromBursts() {
|
||||
return this.isInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentMana() {
|
||||
if (storage instanceof ManaPortStorage) {
|
||||
ManaPortStorage s = (ManaPortStorage) storage;
|
||||
return s.getInv().getManaStored();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.ticticboooom.mods.mm.block.tile;
|
||||
|
||||
import com.ticticboooom.mods.mm.ports.storage.ManaPortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.DyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.api.mana.spark.ISparkAttachable;
|
||||
import vazkii.botania.api.mana.spark.ISparkEntity;
|
||||
|
||||
public class ManaMachinePortBlockEntity extends MachinePortBlockEntity implements IManaPool, ISparkAttachable {
|
||||
|
||||
private ISparkEntity spark;
|
||||
|
||||
public ManaMachinePortBlockEntity(TileEntityType<?> p_i48289_1_, ContainerType<?> container, PortStorage storage, boolean input) {
|
||||
super(p_i48289_1_, container, storage, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull() {
|
||||
if (storage instanceof ManaPortStorage) {
|
||||
ManaPortStorage s = (ManaPortStorage) storage;
|
||||
return s.getInv().getManaStored() == s.getInv().getMaxManaStored();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveMana(int mana) {
|
||||
if (storage instanceof ManaPortStorage && this.isInput()) {
|
||||
ManaPortStorage s = (ManaPortStorage) storage;
|
||||
s.getInv().receiveMana(mana, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveManaFromBursts() {
|
||||
return this.isInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentMana() {
|
||||
if (storage instanceof ManaPortStorage) {
|
||||
ManaPortStorage s = (ManaPortStorage) storage;
|
||||
return s.getInv().getManaStored();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutputtingPower() {
|
||||
return !this.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DyeColor getColor() {
|
||||
return DyeColor.GRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(DyeColor color) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAttachSpark(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachSpark(ISparkEntity entity) {
|
||||
spark = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailableSpaceForMana() {
|
||||
if (storage instanceof ManaPortStorage) {
|
||||
ManaPortStorage s = (ManaPortStorage) storage;
|
||||
return s.getInv().getMaxManaStored() - s.getInv().getManaStored();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISparkEntity getAttachedSpark() {
|
||||
return spark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areIncomingTranfersDone() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -29,21 +29,11 @@ public class MMBlockStateProvider extends BlockStateProvider {
|
||||
|
||||
private static final ResourceLocation BASE_TEXTURE = new ResourceLocation(MM.ID, "block/base_block");
|
||||
private static final ResourceLocation CONTROLLER_TEXTURE = new ResourceLocation(MM.ID, "block/controller_cutout");
|
||||
private static final ResourceLocation IPORT_TEXTURE = new ResourceLocation(MM.ID, "block/base_ports/item_input_cutout");
|
||||
private static final ResourceLocation OPORT_TEXTURE = new ResourceLocation(MM.ID, "block/base_ports/item_output_cutout");
|
||||
|
||||
@Override
|
||||
protected void registerStatesAndModels() {
|
||||
for (RegistryObject<ControllerBlock> controller : MMLoader.BLOCKS) {
|
||||
if (controller.get().getModelOverride() != null) {
|
||||
ModelOverrideModel modelOverride = controller.get().getModelOverride();
|
||||
if (modelOverride.getCommonModel().isPresent()) {
|
||||
ResourceLocation location = RLUtils.toRL(modelOverride.getCommonModel().get());
|
||||
dynamicBlockNorthOverlayModel(controller.getId(), location, CONTROLLER_TEXTURE);
|
||||
}
|
||||
} else {
|
||||
dynamicBlockNorthOverlay(controller.getId(), controller.get().getTexOverride() != null ? RLUtils.toRL(controller.get().getTexOverride()) : 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();
|
||||
@@ -54,29 +44,11 @@ public class MMBlockStateProvider extends BlockStateProvider {
|
||||
}
|
||||
|
||||
for (RegistryObject<MachinePortBlock> port : MMLoader.IPORT_BLOCKS) {
|
||||
if (port.get().getModelOverride() != null) {
|
||||
ModelOverrideModel modelOverride = port.get().getModelOverride();
|
||||
if (modelOverride.getInputModel().isPresent()) {
|
||||
dynamicBlockModel(port.getId(), RLUtils.toRL(modelOverride.getInputModel().get()), port.get().getOverlay());
|
||||
} else if (modelOverride.getCommonModel().isPresent()) {
|
||||
dynamicBlockModel(port.getId(), RLUtils.toRL(modelOverride.getCommonModel().get()), port.get().getOverlay());
|
||||
}
|
||||
} else {
|
||||
dynamicBlock(port.getId(), port.get().getTextureOverride() != null ? RLUtils.toRL(port.get().getTextureOverride()) : BASE_TEXTURE, port.get().getOverlay());
|
||||
}
|
||||
dynamicBlock(port.getId(), port.get().getTextureOverride() != null ? RLUtils.toRL(port.get().getTextureOverride()) : BASE_TEXTURE, port.get().getOverlay());
|
||||
simpleBlock(port.get(), new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + port.getId().getPath())));
|
||||
}
|
||||
for (RegistryObject<MachinePortBlock> port : MMLoader.OPORT_BLOCKS) {
|
||||
if (port.get().getModelOverride() != null) {
|
||||
ModelOverrideModel modelOverride = port.get().getModelOverride();
|
||||
if (modelOverride.getOutputModel().isPresent()) {
|
||||
dynamicBlockModel(port.getId(), RLUtils.toRL(modelOverride.getOutputModel().get()), port.get().getOverlay());
|
||||
} else if (modelOverride.getCommonModel().isPresent()) {
|
||||
dynamicBlockModel(port.getId(), RLUtils.toRL(modelOverride.getCommonModel().get()), port.get().getOverlay());
|
||||
}
|
||||
} else {
|
||||
dynamicBlock(port.getId(), port.get().getTextureOverride() != null ? RLUtils.toRL(port.get().getTextureOverride()) : BASE_TEXTURE, port.get().getOverlay());
|
||||
}
|
||||
dynamicBlock(port.getId(), port.get().getTextureOverride() != null ? RLUtils.toRL(port.get().getTextureOverride()) : BASE_TEXTURE, port.get().getOverlay());
|
||||
simpleBlock(port.get(), new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + port.getId().getPath())));
|
||||
}
|
||||
|
||||
@@ -160,66 +132,6 @@ public class MMBlockStateProvider extends BlockStateProvider {
|
||||
.end();
|
||||
}
|
||||
|
||||
public void dynamicBlockModel(ResourceLocation loc, ResourceLocation baseModel, ResourceLocation overlayTexture) {
|
||||
models().getBuilder(loc.toString()).parent(new ModelFile.UncheckedModelFile(baseModel))
|
||||
.texture("particle", overlayTexture)
|
||||
.transforms()
|
||||
.transform(ModelBuilder.Perspective.THIRDPERSON_LEFT)
|
||||
.rotation(75F, 45F, 0F)
|
||||
.translation(0F, 2.5F, 0)
|
||||
.scale(0.375F, 0.375F, 0.375F)
|
||||
.end()
|
||||
.transform(ModelBuilder.Perspective.THIRDPERSON_RIGHT)
|
||||
.rotation(75F, 45F, 0F)
|
||||
.translation(0F, 2.5F, 0)
|
||||
.scale(0.375F, 0.375F, 0.375F)
|
||||
.end()
|
||||
.end()
|
||||
.customLoader(MultiLayerModelBuilder::begin)
|
||||
.submodel(RenderType.getTranslucent(), this.models().nested().parent(new ModelFile.UncheckedModelFile(baseModel)).parent(new ModelFile.UncheckedModelFile(mcLoc("block/block"))))
|
||||
.submodel(RenderType.getTranslucent(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
|
||||
.texture("overlay", overlayTexture)
|
||||
.element()
|
||||
.from(0, 0, 0)
|
||||
.to(16, 16, 16)
|
||||
.face(Direction.NORTH)
|
||||
.texture("#overlay")
|
||||
//.allFaces((dir, uv) -> uv.uvs(0F,0F, 16F,16F))
|
||||
.end()
|
||||
.end()
|
||||
)
|
||||
.end();
|
||||
}
|
||||
public void dynamicBlockNorthOverlayModel(ResourceLocation loc, ResourceLocation baseModel, ResourceLocation overlayTexture) {
|
||||
models().getBuilder(loc.toString()).parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
|
||||
.texture("particle", overlayTexture)
|
||||
.transforms()
|
||||
.transform(ModelBuilder.Perspective.THIRDPERSON_LEFT)
|
||||
.rotation(75F, 45F, 0F)
|
||||
.translation(0F, 2.5F, 0)
|
||||
.scale(0.375F, 0.375F, 0.375F)
|
||||
.end()
|
||||
.transform(ModelBuilder.Perspective.THIRDPERSON_RIGHT)
|
||||
.rotation(75F, 45F, 0F)
|
||||
.translation(0F, 2.5F, 0)
|
||||
.scale(0.375F, 0.375F, 0.375F)
|
||||
.end()
|
||||
.end()
|
||||
.customLoader(MultiLayerModelBuilder::begin)
|
||||
.submodel(RenderType.getTranslucent(), this.models().nested().parent(new ModelFile.UncheckedModelFile(baseModel)))
|
||||
.submodel(RenderType.getTranslucent(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
|
||||
.texture("overlay", overlayTexture)
|
||||
.element()
|
||||
.from(0, 0, 0)
|
||||
.to(16, 16, 16)
|
||||
.face(Direction.NORTH)
|
||||
.texture("#overlay")
|
||||
//.allFaces((dir, uv) -> uv.uvs(0F,0F, 16F,16F))
|
||||
.end()
|
||||
.end()
|
||||
)
|
||||
.end();
|
||||
}
|
||||
|
||||
private void directionalState(Block block) {
|
||||
VariantBlockStateBuilder variantBuilder = getVariantBuilder(block);
|
||||
|
||||
@@ -3,8 +3,14 @@ package com.ticticboooom.mods.mm.nbt;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.nbt.model.NBTActionModel;
|
||||
import com.ticticboooom.mods.mm.nbt.model.NBTModel;
|
||||
import net.minecraft.data.NBTToSNBTConverter;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -21,6 +27,30 @@ public class NBTActionParser {
|
||||
);
|
||||
resultList.add(model);
|
||||
}
|
||||
if (resultList.isEmpty()){
|
||||
return null;
|
||||
}
|
||||
return new NBTModel(resultList);
|
||||
}
|
||||
|
||||
public static NBTModel parse(PacketBuffer buf) {
|
||||
int i = buf.readInt();
|
||||
List<NBTActionModel> resultList = new ArrayList<>();
|
||||
for (int i1 = 0; i1 < i; i1++) {
|
||||
resultList.add(new NBTActionModel(buf.readString(), buf.readString(), new JsonParser().parse(buf.readString())));
|
||||
}
|
||||
if (i <= 0){
|
||||
return null;
|
||||
}
|
||||
return new NBTModel(resultList);
|
||||
}
|
||||
|
||||
public static void write(PacketBuffer buf, NBTModel model) {
|
||||
buf.writeInt(model.getActions().size());
|
||||
for (NBTActionModel action : model.getActions()) {
|
||||
buf.writeString(action.getAction());
|
||||
buf.writeString(action.getKey());
|
||||
buf.writeString(action.getValue().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ticticboooom.mods.mm.ports;
|
||||
|
||||
import com.ticticboooom.mods.mm.ports.parser.IPortFactory;
|
||||
import com.ticticboooom.mods.mm.ports.parser.PortFactory;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
@@ -11,9 +11,9 @@ public class MasterfulPortType implements IForgeRegistryEntry<MasterfulPortType>
|
||||
|
||||
private ResourceLocation name;
|
||||
@Getter
|
||||
private IPortFactory parser;
|
||||
private PortFactory parser;
|
||||
|
||||
public MasterfulPortType(ResourceLocation name, IPortFactory parser) {
|
||||
public MasterfulPortType(ResourceLocation name, PortFactory parser) {
|
||||
this.name = name;
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
@@ -12,13 +12,17 @@ import com.ticticboooom.mods.mm.ports.storage.EnergyPortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import lombok.SneakyThrows;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class EnergyPortParser implements IPortFactory {
|
||||
public class EnergyPortParser extends PortFactory {
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +54,7 @@ public class EnergyPortParser implements IPortFactory {
|
||||
return new ResourceLocation(MM.ID, "block/base_ports/energy_output_cutout");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PortState createState(JsonObject obj) {
|
||||
DataResult<Pair<EnergyPortState, JsonElement>> apply = JsonOps.INSTANCE.withDecoder(EnergyPortState.CODEC).apply(obj);
|
||||
|
||||
@@ -20,7 +20,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FluidPortParser implements IPortFactory {
|
||||
public class FluidPortParser extends PortFactory {
|
||||
|
||||
@Override
|
||||
public Supplier<PortStorage> createStorage(JsonObject obj) {
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.ticticboooom.mods.mm.ports.parser;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ticticboooom.mods.mm.ports.state.PortState;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import mezz.jei.api.ingredients.IIngredientType;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface IPortFactory {
|
||||
PortState createState(JsonObject obj);
|
||||
PortState createState(PacketBuffer buf);
|
||||
Supplier<PortStorage> createStorage(JsonObject obj);
|
||||
void write(PacketBuffer buf, PortState state);
|
||||
void setIngredients(IIngredients ingredients, List<?> stacks, boolean input);
|
||||
ResourceLocation getInputOverlay();
|
||||
ResourceLocation getOutputOverlay();
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.nbt.NBTActionParser;
|
||||
import com.ticticboooom.mods.mm.nbt.model.NBTModel;
|
||||
import com.ticticboooom.mods.mm.ports.state.PortState;
|
||||
import com.ticticboooom.mods.mm.ports.state.ItemPortState;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
@@ -16,12 +18,11 @@ import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ItemPortParser implements IPortFactory {
|
||||
public class ItemPortParser extends PortFactory {
|
||||
|
||||
|
||||
@Override
|
||||
@@ -45,18 +46,30 @@ public class ItemPortParser implements IPortFactory {
|
||||
@Override
|
||||
public void write(PacketBuffer buf, PortState state) {
|
||||
buf.func_240629_a_(ItemPortState.CODEC, ((ItemPortState) state));
|
||||
NBTActionParser.write(buf, ((ItemPortState) state).getNbt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortState createState(JsonObject obj) {
|
||||
DataResult<Pair<ItemPortState, JsonElement>> apply = JsonOps.INSTANCE.withDecoder(ItemPortState.CODEC).apply(obj);
|
||||
return apply.result().get().getFirst();
|
||||
ItemPortState result = apply.result().get().getFirst();
|
||||
if (obj.has("nbt")){
|
||||
JsonElement nbt = obj.get("nbt");
|
||||
NBTModel parse = NBTActionParser.parse(nbt.getAsJsonArray());
|
||||
result.setNbt(parse);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public PortState createState(PacketBuffer buf) {
|
||||
return buf.func_240628_a_(ItemPortState.CODEC);
|
||||
ItemPortState state = buf.func_240628_a_(ItemPortState.CODEC);
|
||||
NBTModel parsed = NBTActionParser.parse(buf);
|
||||
state.setNbt(parsed);
|
||||
return state;
|
||||
|
||||
}
|
||||
@Override
|
||||
public ResourceLocation getInputOverlay() {
|
||||
|
||||
@@ -6,21 +6,27 @@ import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.ports.state.ManaPortState;
|
||||
import com.ticticboooom.mods.mm.block.MachinePortBlock;
|
||||
import com.ticticboooom.mods.mm.block.tile.ManaMachinePortBlockEntity;
|
||||
import com.ticticboooom.mods.mm.ports.state.ManaPortState;
|
||||
import com.ticticboooom.mods.mm.ports.state.PortState;
|
||||
import com.ticticboooom.mods.mm.ports.storage.ManaPortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.ManaPortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import com.ticticboooom.mods.mm.registration.MMSetup;
|
||||
import com.ticticboooom.mods.mm.registration.Registerable;
|
||||
import lombok.SneakyThrows;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ManaPortParser implements IPortFactory {
|
||||
public class ManaPortParser extends PortFactory {
|
||||
|
||||
@Override
|
||||
public Supplier<PortStorage> createStorage(JsonObject obj) {
|
||||
@@ -42,12 +48,12 @@ public class ManaPortParser implements IPortFactory {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getInputOverlay() {
|
||||
return new ResourceLocation(MM.ID, "block/base_ports/mana_input_cutout");
|
||||
return new ResourceLocation(MM.ID, "block/compat_ports/botania_mana_cutout");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getOutputOverlay() {
|
||||
return new ResourceLocation(MM.ID, "block/base_ports/mana_output_cutout");
|
||||
return new ResourceLocation(MM.ID, "block/compat_ports/botania_mana_cutout");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,4 +67,9 @@ public class ManaPortParser implements IPortFactory {
|
||||
public PortState createState(PacketBuffer buf) {
|
||||
return buf.func_240628_a_(ManaPortState.CODEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryObject<TileEntityType<?>> registerTileEntity(String id, DeferredRegister<TileEntityType<?>> reg, Registerable<RegistryObject<TileEntityType<?>>>tile, Registerable<RegistryObject<MachinePortBlock>> block, Registerable<RegistryObject<ContainerType<?>>> containerType, Supplier<PortStorage> portStorage, boolean isInput){
|
||||
return reg.register(id, () -> TileEntityType.Builder.create(() -> new ManaMachinePortBlockEntity(tile.get().get(), containerType.get().get(), portStorage.get(), true), block.get().get()).build(null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,14 @@ import com.ticticboooom.mods.mm.ports.storage.MekGasPortStorage;
|
||||
import lombok.SneakyThrows;
|
||||
import mekanism.api.chemical.gas.GasStack;
|
||||
import mekanism.client.jei.MekanismJEI;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class MekGasPortParser implements IPortFactory {
|
||||
public class MekGasPortParser extends PortFactory {
|
||||
|
||||
@Override
|
||||
public void setIngredients(IIngredients ingredients, List<?> stacks, boolean input) {
|
||||
|
||||
@@ -13,16 +13,14 @@ import com.ticticboooom.mods.mm.ports.storage.MekSlurryPortStorage;
|
||||
import lombok.SneakyThrows;
|
||||
import mekanism.api.chemical.slurry.SlurryStack;
|
||||
import mekanism.client.jei.MekanismJEI;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class MekSlurryPortParser implements IPortFactory {
|
||||
public class MekSlurryPortParser extends PortFactory {
|
||||
|
||||
@Override
|
||||
public void setIngredients(IIngredients ingredients, List<?> stacks, boolean input) {
|
||||
|
||||
@@ -8,23 +8,19 @@ import com.mojang.serialization.JsonOps;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.client.jei.category.MMJeiPlugin;
|
||||
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
|
||||
import com.ticticboooom.mods.mm.ports.state.FluidPortState;
|
||||
import com.ticticboooom.mods.mm.ports.state.PneumaticPortState;
|
||||
import com.ticticboooom.mods.mm.ports.state.PortState;
|
||||
import com.ticticboooom.mods.mm.ports.storage.FluidPortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PneumaticPortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import lombok.SneakyThrows;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PneumaticPortParser implements IPortFactory{
|
||||
public class PneumaticPortParser extends PortFactory {
|
||||
|
||||
@Override
|
||||
public Supplier<PortStorage> createStorage(JsonObject obj) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.ticticboooom.mods.mm.ports.parser;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ticticboooom.mods.mm.block.MachinePortBlock;
|
||||
import com.ticticboooom.mods.mm.block.tile.MachinePortBlockEntity;
|
||||
import com.ticticboooom.mods.mm.model.ModelOverrideModel;
|
||||
import com.ticticboooom.mods.mm.ports.state.PortState;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import com.ticticboooom.mods.mm.registration.MMSetup;
|
||||
import com.ticticboooom.mods.mm.registration.Registerable;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class PortFactory {
|
||||
public abstract PortState createState(JsonObject obj);
|
||||
public abstract PortState createState(PacketBuffer buf);
|
||||
public abstract Supplier<PortStorage> createStorage(JsonObject obj);
|
||||
public abstract void write(PacketBuffer buf, PortState state);
|
||||
public abstract void setIngredients(IIngredients ingredients, List<?> stacks, boolean input);
|
||||
public abstract ResourceLocation getInputOverlay();
|
||||
public abstract ResourceLocation getOutputOverlay();
|
||||
public RegistryObject<TileEntityType<?>> registerTileEntity(String id, DeferredRegister<TileEntityType<?>> reg, Registerable<RegistryObject<TileEntityType<?>>>tile, Registerable<RegistryObject<MachinePortBlock>> block, Registerable<RegistryObject<ContainerType<?>>> containerType, Supplier<PortStorage> portStorage, boolean isInput){
|
||||
return reg.register(id, () -> TileEntityType.Builder.create(() -> new MachinePortBlockEntity(tile.get().get(), containerType.get().get(), portStorage.get(), isInput), block.get().get()).build(null));
|
||||
}
|
||||
public RegistryObject<MachinePortBlock> registerBlock(String id, DeferredRegister<Block> reg, Registerable<RegistryObject<TileEntityType<?>>> type, String name, String controllerId, String textureOverride, ResourceLocation overlay){
|
||||
return reg.register(id, () -> new MachinePortBlock(type.get(), name, controllerId, textureOverride, overlay));
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class RotationPortParser implements IPortFactory{
|
||||
public class RotationPortParser extends PortFactory {
|
||||
|
||||
@Override
|
||||
public Supplier<PortStorage> createStorage(JsonObject obj) {
|
||||
|
||||
@@ -6,22 +6,26 @@ import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.block.AstralMachinePortBlock;
|
||||
import com.ticticboooom.mods.mm.block.MachinePortBlock;
|
||||
import com.ticticboooom.mods.mm.ports.state.PortState;
|
||||
import com.ticticboooom.mods.mm.ports.state.StarlightPortState;
|
||||
import com.ticticboooom.mods.mm.ports.state.StarlightPortState;
|
||||
import com.ticticboooom.mods.mm.ports.storage.EnergyPortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.StarlightPortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.StarlightPortStorage;
|
||||
import com.ticticboooom.mods.mm.registration.Registerable;
|
||||
import lombok.SneakyThrows;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class StarlightPortParser implements IPortFactory {
|
||||
public class StarlightPortParser extends PortFactory {
|
||||
|
||||
@Override
|
||||
public Supplier<PortStorage> createStorage(JsonObject obj) {
|
||||
@@ -61,4 +65,9 @@ public class StarlightPortParser implements IPortFactory {
|
||||
public PortState createState(PacketBuffer buf) {
|
||||
return buf.func_240628_a_(StarlightPortState.CODEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryObject<MachinePortBlock> registerBlock(String id, DeferredRegister<Block> reg, Registerable<RegistryObject<TileEntityType<?>>> type, String name, String controllerId, String textureOverride, ResourceLocation overlay) {
|
||||
return reg.register(id, () -> new AstralMachinePortBlock(type.get(), name, controllerId, textureOverride, overlay));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,13 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.exception.InvalidProcessDefinitionException;
|
||||
import com.ticticboooom.mods.mm.helper.RLUtils;
|
||||
import com.ticticboooom.mods.mm.nbt.NBTPopulate;
|
||||
import com.ticticboooom.mods.mm.nbt.NBTValidator;
|
||||
import com.ticticboooom.mods.mm.nbt.model.NBTModel;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import com.ticticboooom.mods.mm.ports.storage.ItemPortStorage;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.SneakyThrows;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
@@ -44,11 +48,15 @@ public class ItemPortState extends PortState {
|
||||
private final int count;
|
||||
private final String item;
|
||||
private final String tag;
|
||||
@Getter
|
||||
@Setter
|
||||
private NBTModel nbt;
|
||||
|
||||
public ItemPortState(int count, String item, String tag) {
|
||||
this.count = count;
|
||||
this.item = item;
|
||||
this.tag = tag;
|
||||
nbt = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,7 +99,7 @@ public class ItemPortState extends PortState {
|
||||
for (PortStorage inv : storage) {
|
||||
if (inv instanceof ItemPortStorage) {
|
||||
ItemPortStorage iinv = (ItemPortStorage) inv;
|
||||
for (int i = 0; i < iinv.getInv().getSlots(); i++) {
|
||||
for (int i = 0; i < iinv.getInv().getSlots(); i++) {
|
||||
ItemStack stackInSlot = iinv.getInv().getStackInSlot(i);
|
||||
if (stackInSlot.isEmpty()) {
|
||||
continue;
|
||||
@@ -100,11 +108,21 @@ public class ItemPortState extends PortState {
|
||||
if (!item.equals("")) {
|
||||
if (stackInSlot.getItem().getRegistryName().toString().equals(item)) {
|
||||
current -= stackInSlot.getCount();
|
||||
if (nbt != null) {
|
||||
if (!NBTValidator.isValid(stackInSlot.getTag(), nbt)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!tag.equals("")) {
|
||||
ITag<Item> tag = ItemTags.getCollection().get(RLUtils.toRL(this.tag));
|
||||
if (tag != null && tag.contains(stackInSlot.getItem())) {
|
||||
current -= stackInSlot.getCount();
|
||||
if (nbt != null) {
|
||||
if (!NBTValidator.isValid(stackInSlot.getTag(), nbt)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (current <= 0) {
|
||||
@@ -131,10 +149,16 @@ public class ItemPortState extends PortState {
|
||||
int increment = Math.min((stackInSlot.getItem().getMaxStackSize() - amount), (count - current));
|
||||
stackInSlot.setCount(stackInSlot.getCount() + increment);
|
||||
current += increment;
|
||||
if (nbt != null){
|
||||
stackInSlot.setTag(NBTPopulate.populate(stackInSlot.getTag(), nbt));
|
||||
}
|
||||
} else if (stackInSlot.isEmpty()) {
|
||||
Item forgeItem = ForgeRegistries.ITEMS.getValue(RLUtils.toRL(item));
|
||||
iinv.getInv().setStackInSlot(i, new ItemStack(forgeItem, Math.min(forgeItem.getMaxStackSize(), count - current)));
|
||||
current += Math.min(forgeItem.getMaxStackSize(), count - current);
|
||||
if (nbt != null){
|
||||
stackInSlot.setTag(NBTPopulate.populate(stackInSlot.getTag(), nbt));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (current >= count) {
|
||||
@@ -185,19 +209,19 @@ public class ItemPortState extends PortState {
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void validateDefinition() {
|
||||
if (!item.equals("")){
|
||||
if (!RLUtils.isRL(item)){
|
||||
if (!item.equals("")) {
|
||||
if (!RLUtils.isRL(item)) {
|
||||
throw new InvalidProcessDefinitionException("Item: " + item + " is not a valid item id (ResourceLocation)");
|
||||
}
|
||||
|
||||
if (!ForgeRegistries.ITEMS.containsKey(RLUtils.toRL(item))){
|
||||
if (!ForgeRegistries.ITEMS.containsKey(RLUtils.toRL(item))) {
|
||||
throw new InvalidProcessDefinitionException("Item: " + item + " does not exist in the game's item registry");
|
||||
}
|
||||
} else if (!tag.equals("")){
|
||||
if (!RLUtils.isRL(tag)){
|
||||
} else if (!tag.equals("")) {
|
||||
if (!RLUtils.isRL(tag)) {
|
||||
throw new InvalidProcessDefinitionException("Item Tag: " + tag + " is not a valid item tag id (ResourceLocation)");
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
throw new InvalidProcessDefinitionException("You must define a item id or item tag id in the items 'data' object");
|
||||
}
|
||||
}
|
||||
@@ -221,7 +245,7 @@ public class ItemPortState extends PortState {
|
||||
|
||||
List<ItemStack> stacks = new ArrayList<>();
|
||||
tag.getAllElements().forEach(z -> stacks.add(new ItemStack(z, this.count)));
|
||||
return (List<T>)stacks;
|
||||
return (List<T>) stacks;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@@ -237,7 +261,7 @@ public class ItemPortState extends PortState {
|
||||
Stream<ItemStack> itemStackStream = tag.getAllElements().stream().map(z -> new ItemStack(z.getItem(), this.count));
|
||||
layout.getItemStacks().set(typeIndex, itemStackStream.collect(Collectors.toList()));
|
||||
}
|
||||
if (this.getChance() < 1){
|
||||
if (this.getChance() < 1) {
|
||||
layout.getItemStacks().addTooltipCallback((s, a, b, c) -> {
|
||||
if (s == typeIndex) {
|
||||
c.add(new StringTextComponent("Chance: " + this.getChance() * 100 + "%"));
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ManaPortStorage extends PortStorage {
|
||||
amount = (float)inv.getManaStored() / inv.getMaxManaStored();
|
||||
}
|
||||
screen.blit(stack, left + barOffsetX, top + barOffsetY, 193, 18, 18, (int) (108 * amount));
|
||||
AbstractGui.drawString(stack, Minecraft.getInstance().fontRenderer, inv.getManaStored() + "Mana", left + 30, top + 60, 0xfefefe);
|
||||
AbstractGui.drawString(stack, Minecraft.getInstance().fontRenderer, inv.getManaStored() + " Mana", left + 30, top + 60, 0xfefefe);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,7 +98,6 @@ public class ManaPortStorage extends PortStorage {
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(this.validPools);
|
||||
int tiles = validPools.size();
|
||||
if (tiles != 0) {
|
||||
int extractableMana = inv.extractMana(Integer.MAX_VALUE, true);
|
||||
|
||||
@@ -83,7 +83,7 @@ public class PneumaticPortStorage extends PortStorage {
|
||||
screen.blit(stack, left + barOffsetX, top + barOffsetY, 193, 18, 18, (int) (108 * amount));
|
||||
|
||||
AbstractGui.drawCenteredString(stack, Minecraft.getInstance().fontRenderer, NumberFormat.getInstance().format(inv.getPressure()) + "P", left + 50, top + 80, 0xfefefe);
|
||||
AbstractGui.drawCenteredString(stack, Minecraft.getInstance().fontRenderer, inv.getAir() + " Air", left + 50, top + 80, 0xfefefe);
|
||||
AbstractGui.drawCenteredString(stack, Minecraft.getInstance().fontRenderer, inv.getAir() + " Air", left + 50, top + 60, 0xfefefe);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,23 +4,21 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
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.block.container.ControllerBlockContainer;
|
||||
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
|
||||
import com.ticticboooom.mods.mm.block.tile.ControllerBlockEntity;
|
||||
import com.ticticboooom.mods.mm.block.tile.MachinePortBlockEntity;
|
||||
import com.ticticboooom.mods.mm.helper.IOHelper;
|
||||
import com.ticticboooom.mods.mm.helper.RLUtils;
|
||||
import com.ticticboooom.mods.mm.model.ModelOverrideModel;
|
||||
import com.ticticboooom.mods.mm.ports.MasterfulPortType;
|
||||
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.extensions.IForgeContainerType;
|
||||
@@ -66,19 +64,13 @@ public class MMLoader {
|
||||
if (obj.has("textureOverride")) {
|
||||
texOverride = obj.get("textureOverride").getAsString();
|
||||
}
|
||||
ModelOverrideModel controllerModelOverride = null;
|
||||
if (obj.has("modelOverride")){
|
||||
DataResult<Pair<ModelOverrideModel, JsonElement>> modelOverride = JsonOps.INSTANCE.withDecoder(ModelOverrideModel.CODEC).apply(obj.get("modelOverride"));
|
||||
controllerModelOverride = modelOverride.result().get().getFirst();
|
||||
}
|
||||
final ModelOverrideModel controllerModelOverrideFinal = controllerModelOverride;
|
||||
final String textureOverrideFinal = texOverride;
|
||||
{
|
||||
Registerable<RegistryObject<TileEntityType<?>>> controllerTile = new Registerable<>();
|
||||
Registerable<RegistryObject<ControllerBlock>> controllerBlock = new Registerable<>();
|
||||
Registerable<RegistryObject<ContainerType<ControllerBlockContainer>>> 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, textureOverrideFinal, controllerModelOverrideFinal)));
|
||||
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.create(() -> 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().group(MASTERFUL_ITEM_GROUP)));
|
||||
BLOCKS.add(controllerBlock.get());
|
||||
@@ -97,17 +89,13 @@ public class MMLoader {
|
||||
} else {
|
||||
portTexOverride = textureOverrideFinal;
|
||||
}
|
||||
ModelOverrideModel portModelOverride;
|
||||
if (portObj.has("modelOverride")){
|
||||
DataResult<Pair<ModelOverrideModel, JsonElement>> modelOverride = JsonOps.INSTANCE.withDecoder(ModelOverrideModel.CODEC).apply(obj.get("modelOverride"));
|
||||
portModelOverride = modelOverride.result().get().getFirst();
|
||||
} else {
|
||||
portModelOverride = controllerModelOverrideFinal;
|
||||
}
|
||||
final ModelOverrideModel portModelOverrideFinal = portModelOverride;
|
||||
final String portTextureOverrideFinal = portTexOverride;
|
||||
ResourceLocation resourceLocation = RLUtils.toRL(type);
|
||||
MasterfulPortType value = MMPorts.PORTS.get(resourceLocation);
|
||||
if (value == null){
|
||||
MM.LOG.warn("port type not present: " + resourceLocation.toString());
|
||||
continue;
|
||||
}
|
||||
Supplier<PortStorage> data = value.getParser().createStorage(portObj.get("data").getAsJsonObject());
|
||||
|
||||
{
|
||||
@@ -115,8 +103,8 @@ public class MMLoader {
|
||||
Registerable<RegistryObject<MachinePortBlock>> block = new Registerable<>();
|
||||
Registerable<RegistryObject<ContainerType<?>>> 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, portTextureOverrideFinal, value.getParser().getInputOverlay(), portModelOverrideFinal)));
|
||||
tile.set(MMSetup.TILES_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> TileEntityType.Builder.create(() -> new MachinePortBlockEntity(tile.get().get(),cont.get().get(), data.get(), true), block.get().get()).build(null)));
|
||||
block.set(value.getParser().registerBlock(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", MMSetup.BLOCKS_REG, tile, name, controllerId, portTextureOverrideFinal, value.getParser().getInputOverlay()));
|
||||
tile.set(value.getParser().registerTileEntity(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", MMSetup.TILES_REG, tile, block, cont, data, true));
|
||||
MMSetup.ITEMS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> new BlockItem(block.get().get(), new Item.Properties().group(MASTERFUL_ITEM_GROUP)));
|
||||
PORT_CONTAINERS.add(cont.get());
|
||||
IPORT_BLOCKS.add(block.get());
|
||||
@@ -127,8 +115,8 @@ public class MMLoader {
|
||||
Registerable<RegistryObject<MachinePortBlock>> block = new Registerable<>();
|
||||
Registerable<RegistryObject<ContainerType<?>>> 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, portTextureOverrideFinal, value.getParser().getOutputOverlay(), portModelOverrideFinal)));
|
||||
tile.set(MMSetup.TILES_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> TileEntityType.Builder.create(() -> new MachinePortBlockEntity(tile.get().get(), cont.get().get(), data.get(), false), block.get().get()).build(null)));
|
||||
block.set(value.getParser().registerBlock(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", MMSetup.BLOCKS_REG, tile, name, controllerId, portTextureOverrideFinal, value.getParser().getOutputOverlay()));
|
||||
tile.set(value.getParser().registerTileEntity(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", MMSetup.TILES_REG, tile, block, cont, data, false));
|
||||
MMSetup.ITEMS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> new BlockItem(block.get().get(), new Item.Properties().group(MASTERFUL_ITEM_GROUP)));
|
||||
PORT_CONTAINERS.add(cont.get());
|
||||
OPORT_BLOCKS.add(block.get());
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.ports.MasterfulPortType;
|
||||
import com.ticticboooom.mods.mm.ports.parser.*;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -15,12 +16,21 @@ public class MMPorts {
|
||||
PORTS.put(new ResourceLocation(MM.ID, "items"), new MasterfulPortType(new ResourceLocation(MM.ID, "items"), new ItemPortParser()));
|
||||
PORTS.put(new ResourceLocation(MM.ID, "fluids"), new MasterfulPortType(new ResourceLocation(MM.ID, "fluids"), new FluidPortParser()));
|
||||
PORTS.put(new ResourceLocation(MM.ID, "energy"),new MasterfulPortType(new ResourceLocation(MM.ID, "energy"), new EnergyPortParser()));
|
||||
PORTS.put(new ResourceLocation(MM.ID, "mekanism_gas"),new MasterfulPortType(new ResourceLocation(MM.ID, "mekanism_gas"), new MekGasPortParser()));
|
||||
PORTS.put(new ResourceLocation(MM.ID, "mekanism_slurry"),new MasterfulPortType(new ResourceLocation(MM.ID, "mekanism_slurry"), new MekSlurryPortParser()));
|
||||
PORTS.put(new ResourceLocation(MM.ID, "pncr_pressure"),new MasterfulPortType(new ResourceLocation(MM.ID, "pncr_pressure"), new PneumaticPortParser()));
|
||||
PORTS.put(new ResourceLocation(MM.ID, "create_rotation"),new MasterfulPortType(new ResourceLocation(MM.ID, "create_rotation"), new RotationPortParser()));
|
||||
PORTS.put(new ResourceLocation(MM.ID, "starlight"),new MasterfulPortType(new ResourceLocation(MM.ID, "starlight"), new StarlightPortParser()));
|
||||
PORTS.put(new ResourceLocation(MM.ID, "botania_mana"),new MasterfulPortType(new ResourceLocation(MM.ID, "botania_mana"), new ManaPortParser()));
|
||||
PORTS.put(new ResourceLocation(MM.ID, "astral_starlight"),new MasterfulPortType(new ResourceLocation(MM.ID, "astral_starlight"), new StarlightPortParser()));
|
||||
if (ModList.get().isLoaded("mekanism")) {
|
||||
PORTS.put(new ResourceLocation(MM.ID, "mekanism_gas"),new MasterfulPortType(new ResourceLocation(MM.ID, "mekanism_gas"), new MekGasPortParser()));
|
||||
PORTS.put(new ResourceLocation(MM.ID, "mekanism_slurry"),new MasterfulPortType(new ResourceLocation(MM.ID, "mekanism_slurry"), new MekSlurryPortParser()));
|
||||
}
|
||||
if (ModList.get().isLoaded("pneumaticcraft")){
|
||||
PORTS.put(new ResourceLocation(MM.ID, "pncr_pressure"),new MasterfulPortType(new ResourceLocation(MM.ID, "pncr_pressure"), new PneumaticPortParser()));
|
||||
}
|
||||
if (ModList.get().isLoaded("create")){
|
||||
PORTS.put(new ResourceLocation(MM.ID, "create_rotation"),new MasterfulPortType(new ResourceLocation(MM.ID, "create_rotation"), new RotationPortParser()));
|
||||
}
|
||||
if (ModList.get().isLoaded("botania")){
|
||||
PORTS.put(new ResourceLocation(MM.ID, "botania_mana"),new MasterfulPortType(new ResourceLocation(MM.ID, "botania_mana"), new ManaPortParser()));
|
||||
}
|
||||
if (ModList.get().isLoaded("astralsorcery")){
|
||||
PORTS.put(new ResourceLocation(MM.ID, "astral_starlight"),new MasterfulPortType(new ResourceLocation(MM.ID, "astral_starlight"), new StarlightPortParser()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
version.properties
Normal file
2
version.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
#Mon May 24 17:45:34 BST 2021
|
||||
VERSION_CODE=66
|
||||
Reference in New Issue
Block a user