This commit is contained in:
2026-03-10 00:14:49 +08:00
parent 10707f047b
commit 740527fc41
10 changed files with 137 additions and 71 deletions

View File

@@ -1,28 +0,0 @@
FROM eclipse-temurin:21-jdk-alpine AS builder
WORKDIR /app
# Install dependencies
RUN apk add --no-cache curl unzip
# Copy project files
COPY gradle.properties settings.gradle build.gradle ./
COPY src ./src
# Download and setup Gradle
RUN curl -L -o gradle.zip https://services.gradle.org/distributions/gradle-8.10-bin.zip && \
unzip -q gradle.zip && \
rm gradle.zip && \
mv gradle-8.10 gradle
# Create empty gradle home to avoid permission issues
RUN mkdir -p /root/.gradle
# Build the mod
RUN ./gradle/bin/gradle build --no-daemon -x test || (cat /app/build/reports/problems/problems-report.html 2>/dev/null && exit 1)
# Output stage - copy artifacts
FROM alpine:latest
WORKDIR /output
COPY --from=builder /app/build/libs/*.jar ./
CMD ["ls", "-la", "/output/"]

View File

@@ -32,7 +32,7 @@ runs {
server { server {
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
programArgument '--nogui' arguments '--nogui'
} }
gameTestServer { gameTestServer {
@@ -40,7 +40,7 @@ runs {
} }
data { data {
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() arguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
} }
} }

View File

@@ -1,23 +0,0 @@
version: '3.8'
services:
build:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./build:/app/build
command: sh -c "cp /output/*.jar /app/build/ 2>/dev/null || echo 'Build complete'"
dev:
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/app
- gradle-cache:/root/.gradle
working_dir: /app
command: ./gradle/bin/gradle runClient --no-daemon
volumes:
gradle-cache:

View File

@@ -1,21 +1,16 @@
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false org.gradle.daemon=false
# Mod Info
mod_version=1.0.0
mod_group_id=com.betterenderchests
mod_id=betterenderchests
mod_name=Better Ender Chests
mod_author=Vanilla
mod_description=Adds tiered Ender Chests with massive storage capacity!
# Minecraft & NeoForge
minecraft_version=1.21.1 minecraft_version=1.21.1
minecraft_version_range=[1.21.1,1.22) minecraft_version_range=[1.21.1,1.22)
neo_version=21.1.80 neo_version=21.1.124
neo_version_range=[21.1.0,21.2) neo_version_range=[21.1,)
loader_version_range=[4,) loader_version_range=[2,)
mod_id=betterenderchests
mod_name=Better Ender Chests
mod_group_id=com.betterenderchests
mod_author=Your Name
mod_version=1.0.0
mod_description=A Minecraft mod that adds tiered Ender Chests with massive storage capacity!
# Parchment Mappings
parchment_minecraft_version=1.21.1
parchment_mappings_version=2024.11.17

View File

@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

95
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,95 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >nul 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@endlocal & set ERROR_CODE=%ERRORLEVEL%
if not "%ERRORLEVEL%"=="0" goto fail
goto end
:fail
set ERROR_CODE=1
:end
@rem Set variable GRADLE_EXIT_CONSOLE to force the Console window to remain open
@rem when Gradle finishes with (ctrl-D) in the Shell.
@rem Set "GRADLE_EXIT_CONSOLE=0" for Exit Code 0
if not "" == "%GRADLE_EXIT_CONSOLE%" exit %GRADLE_EXIT_CONSOLE%
exit /b %ERROR_CODE%

View File

@@ -1,6 +1,7 @@
package com.betterenderchests.block; package com.betterenderchests.block;
import com.betterenderchests.menu.TieredEnderChestMenu; import com.betterenderchests.menu.TieredEnderChestMenu;
import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@@ -30,10 +31,15 @@ import org.jetbrains.annotations.Nullable;
public class TieredEnderChestBlock extends BaseEntityBlock { public class TieredEnderChestBlock extends BaseEntityBlock {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
protected static final VoxelShape SHAPE = Block.box(1.0, 0.0, 1.0, 15.0, 14.0, 15.0); protected static final VoxelShape SHAPE = Block.box(1.0, 0.0, 1.0, 15.0, 14.0, 15.0);
public static final MapCodec<TieredEnderChestBlock> CODEC = simpleCodec(TieredEnderChestBlock::new);
private final int inventorySize; private final int inventorySize;
private final Component containerTitle; private final Component containerTitle;
public TieredEnderChestBlock(Properties properties) {
this(properties, 27);
}
public TieredEnderChestBlock(Properties properties, int inventorySize) { public TieredEnderChestBlock(Properties properties, int inventorySize) {
super(properties); super(properties);
this.inventorySize = inventorySize; this.inventorySize = inventorySize;
@@ -46,13 +52,18 @@ public class TieredEnderChestBlock extends BaseEntityBlock {
return SHAPE; return SHAPE;
} }
@Override
protected MapCodec<? extends BaseEntityBlock> codec() {
return CODEC;
}
@Override @Override
protected RenderShape getRenderShape(BlockState state) { protected RenderShape getRenderShape(BlockState state) {
return RenderShape.ENTITYBLOCK_ANIMATED; return RenderShape.ENTITYBLOCK_ANIMATED;
} }
@Override @Override
protected BlockState getStateForPlacement(BlockPlaceContext context) { public BlockState getStateForPlacement(BlockPlaceContext context) {
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()); return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite());
} }

View File

@@ -44,4 +44,8 @@ public class PortableEnderChestItem extends Item {
public int getInventorySize() { public int getInventorySize() {
return inventorySize; return inventorySize;
} }
public PortableEnderChestItem fireResistant() {
return this;
}
} }

View File

@@ -15,7 +15,8 @@ public class ModMenus {
public static final Supplier<MenuType<TieredEnderChestMenu>> TIERED_ENDER_CHEST = MENUS.register( public static final Supplier<MenuType<TieredEnderChestMenu>> TIERED_ENDER_CHEST = MENUS.register(
"tiered_ender_chest", "tiered_ender_chest",
() -> IMenuTypeExtension.create(TieredEnderChestMenu::new)); () -> IMenuTypeExtension.create((containerId, playerInventory, buf) ->
new TieredEnderChestMenu(containerId, playerInventory)));
public static void register(IEventBus eventBus) { public static void register(IEventBus eventBus) {
MENUS.register(eventBus); MENUS.register(eventBus);

View File

@@ -1,5 +1,6 @@
package com.betterenderchests.menu; package com.betterenderchests.menu;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.world.Container; import net.minecraft.world.Container;
import net.minecraft.world.SimpleContainer; import net.minecraft.world.SimpleContainer;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
@@ -17,6 +18,10 @@ public class TieredEnderChestMenu extends AbstractContainerMenu {
this(containerId, playerInventory, 27); // Default 3 rows this(containerId, playerInventory, 27); // Default 3 rows
} }
public TieredEnderChestMenu(int containerId, RegistryFriendlyByteBuf buffer) {
this(containerId, null, 27); // Network sync constructor - will be filled from client
}
public TieredEnderChestMenu(int containerId, Inventory playerInventory, int size) { public TieredEnderChestMenu(int containerId, Inventory playerInventory, int size) {
this(containerId, playerInventory, new SimpleContainer(size), size); this(containerId, playerInventory, new SimpleContainer(size), size);
} }