Skip to content

Commit

Permalink
expanded feature: 25 columns now; also moved to neoforge
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothrazar committed Nov 29, 2024
1 parent bc42c03 commit 22c213a
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 70 deletions.
40 changes: 21 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'net.neoforged.gradle' version '[6.0.18,6.2)'
}

version = "${mc_version}-${mod_version}"
Expand Down Expand Up @@ -119,7 +119,7 @@ sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {

flatDir { dir 'libs' }
// flatDir { dir 'libs' }
maven {
// location of the maven that hosts JEI files
name = "Progwml6 maven"
Expand Down Expand Up @@ -147,7 +147,8 @@ dependencies {
// The "userdev" classifier will be requested and setup by ForgeGradle.
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
// minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
minecraft "net.neoforged:forge:${mc_version}-${forge_version}"

// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
Expand All @@ -159,15 +160,21 @@ dependencies {
runtimeOnly fg.deobf("dev.emi:emi-forge:${emi_version}+${mc_version}")


// implementation fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}")
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}:api")
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}+${mc_version}")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}+${mc_version}:api")



compileOnly fg.deobf("vazkii.patchouli:Patchouli:${mc_version}-${patchouli_version}-FORGE:api")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${mc_version}-${patchouli_version}-FORGE")


//optional deps

compileOnly fg.deobf("vazkii.botania:Botania:${mc_version}-443-FORGE:api")
runtimeOnly fg.deobf("vazkii.botania:Botania:${mc_version}-443-FORGE")

implementation fg.deobf("curse.maven:cyclic-239286:5940363")

// Example mod dependency using a mod jar from ./libs with a flat dir repository
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
// The group id is ignored when searching -- in this case, it is "blank"
Expand All @@ -184,11 +191,9 @@ dependencies {
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
forge_version: forge_version, forge_version_range: forge_version_range,
loader_version_range: loader_version_range,
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors: mod_authors, mod_description: mod_description,
mc_version: mc_version,
mod_id: mod_id,
mod_version: mod_version
]
inputs.properties replaceProperties

Expand All @@ -202,11 +207,11 @@ tasks.named('jar', Jar).configure {
manifest {
attributes([
'Specification-Title' : mod_id,
'Specification-Vendor' : mod_authors,
'Specification-Vendor' : 'Lothrazar',
'Specification-Version' : '1', // We are version 1 of ourselves
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_authors,
'Implementation-Vendor' : 'Lothrazar',
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
Expand All @@ -215,10 +220,6 @@ tasks.named('jar', Jar).configure {
finalizedBy 'reobfJar'
}

// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing:
// tasks.named('publish').configure {
// dependsOn 'reobfJar'
// }

// Example configuration to allow publishing using the maven-publish plugin
publishing {
Expand All @@ -233,6 +234,7 @@ publishing {
}
}
}

task signJar(type: SignJar, dependsOn: jar) {

// findProperty allows us to reference the property without it existing.
Expand All @@ -245,11 +247,11 @@ task signJar(type: SignJar, dependsOn: jar) {
inputFile = jar.archivePath
outputFile = jar.archivePath
}

task cleanJar {
delete 'build/libs'
}


tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
24 changes: 8 additions & 16 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,23 @@ mod_id=storagenetwork
curse_id=268495
mod_version=1.11.3



mc_version=1.20.1
forge_version=47.1.1

# NEO
forge_version=47.1.104

mod_name=storagenetwork
mod_group_id=com.lothrazar.storagenetwork

mod_license=SeeGithub
mod_authors=Lothrazar
mod_description=mod
minecraft_version_range=[1.20.1,)
forge_version_range=[47,)
loader_version_range=[47,)
mapping_channel=official
minecraft_version=1.20.1
mapping_version=1.20.1
mc_version=1.20.1


flib_file=4647711
flib_version=0.0.7
patchouli_version=81
jei_version=15.0.0.12
flib_version=0.0.14
flib_file=5495793
patchouli_version=84
jei_version=15.3.0.4
emi_version=1.0.21
curios_version=5.2.0-beta.3+1.20.1
curios_version=5.7.2


4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ pluginManagement {
repositories {
gradlePluginPortal()
maven {
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
name = 'NeoForged'
url = 'https://maven.neoforged.net/releases'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,18 @@ public boolean mouseScrolled(double x, double y, double mouseButton) {
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
getNetwork().mouseClicked(mouseX, mouseY, mouseButton);
if (getNetwork().getSize() == NetworkScreenSize.NORMAL) {
var size = getNetwork().getSize();
if (size.isCrafting()) {
//TODO: this is part of crafting grid, to clear it out. should be its own button class
int rectX = 63;
int rectY = 110;
if (size == NetworkScreenSize.EXPANDED) {
rectX = 63;
rectY = 110 + 200;
}
System.out.println(mouseX + "," + mouseY);
if (isHovering(rectX, rectY, 7, 7, mouseX, mouseY)) {
System.out.println("clear!");
PacketRegistry.INSTANCE.sendToServer(new ClearRecipeMessage());
PacketRegistry.INSTANCE.sendToServer(new RequestMessage(0, ItemStack.EMPTY, false, false));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@

public class ScreenNetworkInventoryExpanded extends AbstractNetworkScreen<ContainerNetworkInventoryExpanded> {

public static final int ROWS = 4 * 5 + 1;
protected int W = 256;
//i know they could all be in the same png file and i pull out sprites from it, but split images is easier to work with
private TileableTexture head = new TileableTexture(new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/expandable_head.png"), W, 10);
private TileableTexture head_right = new TileableTexture(new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/expandable_head_right.png"), W, 10);
private TileableTexture row = new TileableTexture(new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/expandable_row.png"), W, SsnConsts.SQ);
private TileableTexture row_right = new TileableTexture(new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/expandable_row_right.png"), W, SsnConsts.SQ);
private TileableTexture crafting = new TileableTexture(new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/expandable_crafting.png"), W, 66);
private TileableTexture crafting_right = new TileableTexture(new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/expandable_crafting_right.png"), W, 66);
private TileableTexture player = new TileableTexture(new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/expandable_player.png"), 176, 84);
protected final NetworkWidget network;
private TileInventoryExpanded tile;
Expand All @@ -31,8 +33,10 @@ public ScreenNetworkInventoryExpanded(ContainerNetworkInventoryExpanded containe
super(container, inv, name);
tile = container.tile;
network = new NetworkWidget(this, NetworkScreenSize.EXPANDED);
imageHeight = player.height() + crafting.height() + row.height() * ROWS + head.height();
imageWidth = W;
imageHeight = player.height() + crafting.height()
+ row.height() * NetworkScreenSize.EXPANDED.lines()
+ head.height();
imageWidth = W + 12 * 18;//scrollWidth
}

@Override
Expand All @@ -59,16 +63,18 @@ public void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mouseY)
int xpos = xCenter;
int ypos = yCenter;
blitSegment(ms, head, xpos, ypos);
blitSegment(ms, head_right, xpos + W, ypos);
ypos += head.height();
//render the rows
for (int line = 0; line < network.getLines(); line++) {
blitSegment(ms, row, xpos, ypos);
blitSegment(ms, row_right, xpos + W, ypos);
ypos += row.height();
}
blitSegment(ms, crafting, xpos, ypos);
blitSegment(ms, crafting_right, xpos + W, ypos);
ypos += crafting.height() - 4;
blitSegment(ms, player, xpos, ypos);
// ms.blit(player.texture(), xpos, ypos, 0, imageHeight, imageWidth, imageHeight);
//update network
network.applySearchTextToSlots();
network.renderItemSlots(ms, mouseX, mouseY, font);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,31 @@ public enum NetworkScreenSize {
//normal has the crafting table
//large is the original inventory and remote with no crafting table
NORMAL, LARGE, EXPANDED;

public int lines() {
switch (this) {
case NORMAL:
return 4;
case LARGE:
return 4 * 2;
case EXPANDED:
return 4 * 5 + 1;
}
return 0;
}

public int columns() {
switch (this) {
case NORMAL:
case LARGE:
return 9;
case EXPANDED:
return 25;
}
return 0;
}

public boolean isCrafting() {
return this != LARGE;
}
}
33 changes: 14 additions & 19 deletions src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.lothrazar.storagenetwork.StorageNetworkMod;
import com.lothrazar.storagenetwork.api.EnumSearchPrefix;
import com.lothrazar.storagenetwork.api.IGuiNetwork;
import com.lothrazar.storagenetwork.block.expand.ScreenNetworkInventoryExpanded;
import com.lothrazar.storagenetwork.gui.components.ButtonRequest;
import com.lothrazar.storagenetwork.gui.components.ButtonRequest.TextureEnum;
import com.lothrazar.storagenetwork.gui.slot.ItemSlotNetwork;
Expand Down Expand Up @@ -60,37 +59,35 @@ public class NetworkWidget {
//
public int xNetwork = 8;
public int yNetwork = 10;
private NetworkScreenSize size;
private final NetworkScreenSize size;

public NetworkWidget(IGuiNetwork gui, NetworkScreenSize size) {
this.gui = gui;
stacks = Lists.newArrayList();
slots = Lists.newArrayList();
setScreenSize(size);
this.size = size;
setScreenSize();
PacketRegistry.INSTANCE.sendToServer(new RequestMessage());
lastClick = System.currentTimeMillis();
}

private void setScreenSize(NetworkScreenSize size) {
private void setScreenSize() {
int buffer = 0;
setLines(size.lines());
setColumns(size.columns());
switch (size) {
case NORMAL:
buffer = 59;
setLines(4);
break;
case LARGE:
setLines(4 * 2);
break;
case EXPANDED:
buffer = -10;
this.xNetwork = 10; // head.height();
this.scrollWidth = 256;
setLines(ScreenNetworkInventoryExpanded.ROWS); // the number of rows that can fit
setColumns(9 + 4);
this.scrollWidth = 256 + 12 * 18; //imageWidth
break;
}
scrollHeight = (SsnConsts.SQ + 1) * this.getLines() + buffer;
this.size = size;
}

public void init(Font font) {
Expand Down Expand Up @@ -393,25 +390,23 @@ public void mouseClicked(double mouseX, double mouseY, int mouseButton) {
}
}
LocalPlayer player = Minecraft.getInstance().player;
if (player == null) {
if (player == null || !this.canClick()) {
return;
}
ItemStack stackCarriedByMouse = player.containerMenu.getCarried();
if (!stackUnderMouse.isEmpty()
&& (mouseButton == UtilTileEntity.MOUSE_BTN_LEFT || mouseButton == UtilTileEntity.MOUSE_BTN_RIGHT)
&& stackCarriedByMouse.isEmpty() &&
this.canClick()) {
&& stackCarriedByMouse.isEmpty()) {
// Request an item (from the network) if we are in the upper section of the GUI
PacketRegistry.INSTANCE.sendToServer(new RequestMessage(mouseButton, this.stackUnderMouse.copy(), Screen.hasShiftDown(),
Screen.hasAltDown() || Screen.hasControlDown()));
this.lastClick = System.currentTimeMillis();
}
else if (!stackCarriedByMouse.isEmpty() && inField((int) mouseX, (int) mouseY) &&
this.canClick()) {
// Insert the item held by the mouse into the network
PacketRegistry.INSTANCE.sendToServer(new InsertMessage(0, mouseButton));
this.lastClick = System.currentTimeMillis();
}
else if (!stackCarriedByMouse.isEmpty() && inField((int) mouseX, (int) mouseY)) {
// Insert the item held by the mouse into the network
PacketRegistry.INSTANCE.sendToServer(new InsertMessage(0, mouseButton));
this.lastClick = System.currentTimeMillis();
}
}

private boolean inField(int mouseX, int mouseY) {
Expand Down
12 changes: 3 additions & 9 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ issueTrackerURL="https://github.com/Lothrazar/Storage-Network/issues" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="storagenetwork" #mandatory
modId="${mod_id}" #mandatory

# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version="${mod_version}" #mandatory
Expand Down Expand Up @@ -52,18 +52,12 @@ Storage Network to connect inventories to search and craft
[[dependencies.storagenetwork]]
modId="minecraft"
mandatory=true
versionRange="[1.20.1,)"
ordering="NONE"
side="BOTH"
[[dependencies.storagenetwork]]
modId="jei"
mandatory=false
versionRange="[13.1,)"
versionRange="[${mc_version},)"
ordering="NONE"
side="BOTH"
[[dependencies.storagenetwork]]
modId="flib"
mandatory=true
versionRange="[0.0.7,)"
versionRange="[0.0.14,)"
ordering="NONE"
side="BOTH"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 22c213a

Please sign in to comment.