mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-12-05 00:38:35 +01:00
Compare commits
4 commits
955299f3f1
...
894fae6b87
Author | SHA1 | Date | |
---|---|---|---|
894fae6b87 | |||
09a471c042 | |||
e0e0b550e2 | |||
db97e2dd25 |
7 changed files with 99 additions and 9 deletions
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
|
@ -3,12 +3,12 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Clone repository
|
- name: Clone Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Setup Java
|
- name: Setup Java
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
java-version: '17'
|
java-version: '21'
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
- name: Cache
|
- name: Cache
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
|
@ -16,7 +16,7 @@ jobs:
|
||||||
path: |
|
path: |
|
||||||
~/.gradle/caches
|
~/.gradle/caches
|
||||||
~/.gradle/wrapper
|
~/.gradle/wrapper
|
||||||
key: ${{ hashFiles('**/build.gradle', '**/gradle-wrapper.properties') }}
|
key: ${{ hashFiles('**/build.gradle', '**/gradle-wrapper.properties', '**/gradle.properties') }}
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
chmod +x ./gradlew
|
chmod +x ./gradlew
|
||||||
|
@ -25,4 +25,4 @@ jobs:
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: Mod Jar
|
name: Mod Jar
|
||||||
path: build/libs/**.jar
|
path: build/libs/**.jar
|
||||||
|
|
39
.github/workflows/release.yml
vendored
Normal file
39
.github/workflows/release.yml
vendored
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ["*"]
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Clone Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '21'
|
||||||
|
distribution: 'temurin'
|
||||||
|
- name: Cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
key: ${{ hashFiles('**/build.gradle', '**/gradle-wrapper.properties', '**/gradle.properties') }}
|
||||||
|
- name: Grab Changelog from Commit Message Body
|
||||||
|
run: |
|
||||||
|
changelog=$(echo -e "$MESSAGE" | sed -n '/^$/,$p' | sed '1d')
|
||||||
|
echo -e "$changelog"
|
||||||
|
{
|
||||||
|
echo 'CHANGELOG<<EOF'
|
||||||
|
echo -e "$changelog"
|
||||||
|
echo EOF
|
||||||
|
} >> "$GITHUB_ENV"
|
||||||
|
env:
|
||||||
|
MESSAGE: ${{ github.event.head_commit.message }}
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
chmod +x ./gradlew
|
||||||
|
./gradlew publishMods --no-daemon
|
||||||
|
env:
|
||||||
|
MR_TOKEN: ${{ secrets.MR_TOKEN }}
|
||||||
|
CF_TOKEN: ${{ secrets.CF_TOKEN }}
|
26
build.gradle
26
build.gradle
|
@ -4,6 +4,7 @@ plugins {
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'net.neoforged.gradle.userdev' version '7.0.163'
|
id 'net.neoforged.gradle.userdev' version '7.0.163'
|
||||||
|
id 'me.modmuss50.mod-publish-plugin' version "0.7.4"
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('wrapper', Wrapper).configure {
|
tasks.named('wrapper', Wrapper).configure {
|
||||||
|
@ -171,3 +172,28 @@ idea {
|
||||||
downloadJavadoc = true
|
downloadJavadoc = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publishMods {
|
||||||
|
def cfToken = providers.environmentVariable("CF_TOKEN")
|
||||||
|
def mrToken = providers.environmentVariable("MR_TOKEN")
|
||||||
|
dryRun = !cfToken.isPresent() || !mrToken.isPresent()
|
||||||
|
changelog = providers.environmentVariable("CHANGELOG").orElse("")
|
||||||
|
version = mod_version
|
||||||
|
type = me.modmuss50.mpp.ReleaseType.valueOf(mod_release_state)
|
||||||
|
file = tasks.jarJar.archiveFile
|
||||||
|
modLoaders.add("neoforge")
|
||||||
|
|
||||||
|
modrinth {
|
||||||
|
accessToken = mrToken
|
||||||
|
projectId = "XExdLWCQ"
|
||||||
|
minecraftVersions.add(minecraft_version)
|
||||||
|
optional("jei")
|
||||||
|
}
|
||||||
|
|
||||||
|
curseforge {
|
||||||
|
accessToken = cfToken
|
||||||
|
projectId = "376737"
|
||||||
|
minecraftVersions.add(minecraft_version)
|
||||||
|
optional("jei")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ mod_name=PrettyPipes
|
||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=MIT
|
mod_license=MIT
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=1.18.0
|
mod_version=1.18.1
|
||||||
|
mod_release_state=STABLE
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|
|
@ -121,6 +121,10 @@ public record PacketButton(BlockPos pos, int result, List<Integer> data) impleme
|
||||||
var tile = Utility.getBlockEntity(CraftingTerminalBlockEntity.class, player.level(), pos);
|
var tile = Utility.getBlockEntity(CraftingTerminalBlockEntity.class, player.level(), pos);
|
||||||
tile.requestCraftingItems(player, data.getFirst(), data.get(1) > 0);
|
tile.requestCraftingItems(player, data.getFirst(), data.get(1) > 0);
|
||||||
}),
|
}),
|
||||||
|
CRAFT_TERMINAL_SEND_BACK((pos, data, player) -> {
|
||||||
|
var tile = Utility.getBlockEntity(CraftingTerminalBlockEntity.class, player.level(), pos);
|
||||||
|
tile.sendItemsBack();
|
||||||
|
}),
|
||||||
CANCEL_CRAFTING((pos, data, player) -> {
|
CANCEL_CRAFTING((pos, data, player) -> {
|
||||||
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level(), pos);
|
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level(), pos);
|
||||||
tile.cancelCrafting();
|
tile.cancelCrafting();
|
||||||
|
|
|
@ -26,6 +26,7 @@ import net.minecraft.world.level.ChunkPos;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.items.ItemHandlerHelper;
|
import net.neoforged.neoforge.items.ItemHandlerHelper;
|
||||||
import net.neoforged.neoforge.items.ItemStackHandler;
|
import net.neoforged.neoforge.items.ItemStackHandler;
|
||||||
|
import net.neoforged.neoforge.items.wrapper.RangedWrapper;
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import org.apache.commons.lang3.mutable.MutableInt;
|
import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
|
|
||||||
|
@ -139,6 +140,17 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
|
||||||
network.endProfile();
|
network.endProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendItemsBack() {
|
||||||
|
var outputInventory = new RangedWrapper(this.items, 6, 12);
|
||||||
|
for (var i = 0; i < this.craftItems.getSlots(); i++) {
|
||||||
|
var stack = this.craftItems.getStackInSlot(i);
|
||||||
|
if (!stack.isEmpty()) {
|
||||||
|
var remain = ItemHandlerHelper.insertItemStacked(outputInventory, stack, false);
|
||||||
|
this.craftItems.setStackInSlot(i, remain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveAdditional(CompoundTag compound, HolderLookup.Provider provider) {
|
public void saveAdditional(CompoundTag compound, HolderLookup.Provider provider) {
|
||||||
super.saveAdditional(compound, provider);
|
super.saveAdditional(compound, provider);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
|
import net.minecraft.client.gui.components.Tooltip;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -12,11 +13,13 @@ import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class CraftingTerminalGui extends ItemTerminalGui {
|
public class CraftingTerminalGui extends ItemTerminalGui {
|
||||||
|
|
||||||
private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "textures/gui/crafting_terminal.png");
|
private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "textures/gui/crafting_terminal.png");
|
||||||
private Button requestButton;
|
private Button requestButton;
|
||||||
|
private Button sendBackButton;
|
||||||
|
|
||||||
public CraftingTerminalGui(ItemTerminalContainer screenContainer, Inventory inv, Component titleIn) {
|
public CraftingTerminalGui(ItemTerminalContainer screenContainer, Inventory inv, Component titleIn) {
|
||||||
super(screenContainer, inv, titleIn);
|
super(screenContainer, inv, titleIn);
|
||||||
|
@ -32,6 +35,9 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
||||||
var force = Screen.hasAltDown() || InputConstants.isKeyDown(this.minecraft.getWindow().getWindow(), 259) ? 1 : 0;
|
var force = Screen.hasAltDown() || InputConstants.isKeyDown(this.minecraft.getWindow().getWindow(), 259) ? 1 : 0;
|
||||||
PacketDistributor.sendToServer(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, Arrays.asList(amount, force)));
|
PacketDistributor.sendToServer(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, Arrays.asList(amount, force)));
|
||||||
}).bounds(this.leftPos + 8, this.topPos + 100, 50, 20).build());
|
}).bounds(this.leftPos + 8, this.topPos + 100, 50, 20).build());
|
||||||
|
this.sendBackButton = this.addRenderableWidget(Button.builder(Component.literal(">"), button -> {
|
||||||
|
PacketDistributor.sendToServer(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_SEND_BACK, List.of()));
|
||||||
|
}).bounds(this.leftPos + 47, this.topPos + 72, 12, 12).build());
|
||||||
this.tick();
|
this.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,12 +46,14 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
||||||
super.containerTick();
|
super.containerTick();
|
||||||
var tile = this.getCraftingContainer().getTile();
|
var tile = this.getCraftingContainer().getTile();
|
||||||
this.requestButton.active = false;
|
this.requestButton.active = false;
|
||||||
|
this.sendBackButton.active = false;
|
||||||
for (var i = 0; i < tile.craftItems.getSlots(); i++) {
|
for (var i = 0; i < tile.craftItems.getSlots(); i++) {
|
||||||
var stack = tile.getRequestedCraftItem(i);
|
var requestStack = tile.getRequestedCraftItem(i);
|
||||||
if (!stack.isEmpty() && stack.getCount() < stack.getMaxStackSize()) {
|
if (!requestStack.isEmpty() && requestStack.getCount() < requestStack.getMaxStackSize())
|
||||||
this.requestButton.active = true;
|
this.requestButton.active = true;
|
||||||
break;
|
var realStack = tile.craftItems.getStackInSlot(i);
|
||||||
}
|
if (!realStack.isEmpty())
|
||||||
|
this.sendBackButton.active = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue