Skip to content

Commit

Permalink
Merge pull request #58 from refinedmods/feat/GH-57/port
Browse files Browse the repository at this point in the history
chore: port to minecraft 1.21
  • Loading branch information
raoulvdberge authored Jul 6, 2024
2 parents ac74ec1 + adeeadb commit 21e2256
Show file tree
Hide file tree
Showing 21 changed files with 106 additions and 46 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ body:
- Minecraft 1.19.2
- Minecraft 1.20.1
- Minecraft 1.20.4
- Minecraft 1.21
validations:
required: true
- type: input
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
types: [ opened, synchronize, reopened ]
jobs:
build:
uses: refinedmods/refinedarchitect/.github/workflows/build.yml@v0.11.4
uses: refinedmods/refinedarchitect/.github/workflows/build.yml@v0.15.3
with:
mutation-testing: false
sonarqube: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
type: string
jobs:
draft:
uses: refinedmods/refinedarchitect/.github/workflows/draft-release.yml@v0.11.4
uses: refinedmods/refinedarchitect/.github/workflows/draft-release.yml@v0.15.3
with:
release-type: ${{ inputs.release-type }}
version-number-override: ${{ inputs.version-number-override }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-for-unsupported-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
types: [ labeled, unlabeled, reopened ]
jobs:
unsupported-labeler:
uses: refinedmods/refinedarchitect/.github/workflows/issue-for-unsupported-version.yml@v0.11.4
uses: refinedmods/refinedarchitect/.github/workflows/issue-for-unsupported-version.yml@v0.15.3
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- closed
jobs:
publish-release:
uses: refinedmods/refinedarchitect/.github/workflows/publish-release.yml@v0.11.4
uses: refinedmods/refinedarchitect/.github/workflows/publish-release.yml@v0.15.3
secrets: inherit
with:
project-name: 'Ranged Pumps'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/resolved-issue-locking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
- cron: '0 0 * * *'
jobs:
lock:
uses: refinedmods/refinedarchitect/.github/workflows/resolved-issue-locking.yml@v0.11.4
uses: refinedmods/refinedarchitect/.github/workflows/resolved-issue-locking.yml@v0.15.3
2 changes: 1 addition & 1 deletion .github/workflows/validate-branch-name.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: Validate branch name
on: [ pull_request ]
jobs:
validate-branch-name:
uses: refinedmods/refinedarchitect/.github/workflows/validate-branch-name.yml@v0.11.4
uses: refinedmods/refinedarchitect/.github/workflows/validate-branch-name.yml@v0.15.3
2 changes: 1 addition & 1 deletion .github/workflows/validate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ on:
types: [ opened, synchronize, reopened, ready_for_review, labeled, unlabeled ]
jobs:
validate-changelog:
uses: refinedmods/refinedarchitect/.github/workflows/validate-changelog.yml@v0.11.4
uses: refinedmods/refinedarchitect/.github/workflows/validate-changelog.yml@v0.15.3
with:
validation-level: 'warn'
2 changes: 1 addition & 1 deletion .github/workflows/validate-commit-messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: Validate commit messages
on: [ pull_request ]
jobs:
validate-commit-messages:
uses: refinedmods/refinedarchitect/.github/workflows/validate-commit-messages.yml@v0.11.4
uses: refinedmods/refinedarchitect/.github/workflows/validate-commit-messages.yml@v0.15.3
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ eclipse/
.nb-gradle-properties
.project
*.launch
runs/
run/
*.iml
*.ipr
*.iws
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Changed

- Ported to Minecraft 1.21.
- Korean translation updated by [@gisellevonbingen](https://github.com/gisellevonbingen).

## [1.2.0] - 2024-01-29
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apply from: "https://raw.githubusercontent.com/refinedmods/refinedarchitect/v0.11.4/helper.gradle"
apply from: "https://raw.githubusercontent.com/refinedmods/refinedarchitect/v0.15.3/helper.gradle"

group = 'com.refinedmods'

forgeProject("rangedpumps")
neoForgeProject("rangedpumps")

archivesBaseName = 'rangedpumps'

Expand Down
66 changes: 66 additions & 0 deletions config/intellij-code-style.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<code_scheme name="Refined Mods" version="173">
<JavaCodeStyleSettings>
<option name="GENERATE_FINAL_LOCALS" value="true" />
<option name="GENERATE_FINAL_PARAMETERS" value="true" />
<option name="SPACE_INSIDE_ONE_LINE_ENUM_BRACES" value="true" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="com.refinedmods" withSubpackages="true" static="false" />
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="true" />
</value>
</option>
</JavaCodeStyleSettings>
<ScalaCodeStyleSettings>
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
</ScalaCodeStyleSettings>
<codeStyleSettings language="Cookie">
<indentOptions>
<option name="USE_TAB_CHARACTER" value="false" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="RIGHT_MARGIN" value="120" />
<option name="BLANK_LINES_BEFORE_PACKAGE" value="1" />
<option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="RESOURCE_LIST_WRAP" value="1" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="THROWS_LIST_WRAP" value="1" />
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
<option name="THROWS_KEYWORD_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="TERNARY_OPERATION_WRAP" value="1" />
<option name="FOR_STATEMENT_WRAP" value="1" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="ASSIGNMENT_WRAP" value="1" />
<option name="ASSERT_STATEMENT_WRAP" value="1" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
<option name="PARAMETER_ANNOTATION_WRAP" value="1" />
<option name="VARIABLE_ANNOTATION_WRAP" value="1" />
<option name="ENUM_CONSTANTS_WRAP" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="NBTT">
<indentOptions>
<option name="USE_TAB_CHARACTER" value="false" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
6 changes: 2 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
# Gradle
org.gradle.jvmargs=-Xmx1G
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/refinedmods/rangedpumps/RangedPumps.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.refinedmods.rangedpumps.block.PumpBlock;
import com.refinedmods.rangedpumps.blockentity.PumpBlockEntity;
import com.refinedmods.rangedpumps.config.ServerConfig;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
Expand All @@ -15,7 +14,7 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.neoforge.capabilities.Capabilities;
Expand All @@ -40,9 +39,9 @@ public final class RangedPumps {

public static final ServerConfig SERVER_CONFIG = new ServerConfig();

public RangedPumps(final IEventBus eventBus) {
public RangedPumps(final IEventBus eventBus, final ModContainer container) {
ITEMS.register("pump", () -> new BlockItem(PUMP_BLOCK.get(), new Item.Properties()));
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_CONFIG.getSpec());
container.registerConfig(ModConfig.Type.SERVER, SERVER_CONFIG.getSpec());
BLOCKS.register(eventBus);
ITEMS.register(eventBus);
BLOCK_ENTITY_TYPES.register(eventBus);
Expand All @@ -65,7 +64,7 @@ public static void onRegisterCapabilities(RegisterCapabilitiesEvent e) {

public static void onRegister(RegisterEvent e) {
e.register(Registries.CREATIVE_MODE_TAB, helper -> {
helper.register(new ResourceLocation(RangedPumps.ID, "general"), CreativeModeTab.builder()
helper.register(ResourceLocation.fromNamespaceAndPath(RangedPumps.ID, "general"), CreativeModeTab.builder()
.title(Component.translatable("itemGroup.rangedpumps"))
.icon(() -> new ItemStack(RangedPumps.PUMP_BLOCK.get()))
.displayItems((params, output) -> {
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/com/refinedmods/rangedpumps/block/PumpBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ public PumpBlock() {
super(Block.Properties.of().strength(1.9F).sound(SoundType.STONE));
}

@SuppressWarnings("deprecation")
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand,
BlockHitResult hit) {
@Override
protected InteractionResult useWithoutItem(final BlockState state,
final Level level,
final BlockPos pos,
final Player player,
final BlockHitResult hitResult) {
if (!level.isClientSide) {
BlockEntity blockEntity = level.getBlockEntity(pos);

Expand All @@ -54,7 +57,7 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player
energy.getEnergyStored(), energy.getMaxEnergyStored()));
} else {
player.sendSystemMessage(Component.translatable("block." + RangedPumps.ID + ".pump.state",
pump.getTank().getFluidAmount(), pump.getTank().getFluid().getDisplayName(),
pump.getTank().getFluidAmount(), pump.getTank().getFluid().getHoverName(),
energy.getEnergyStored(), energy.getMaxEnergyStored()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
Expand All @@ -27,7 +28,6 @@
import net.neoforged.neoforge.energy.IEnergyStorage;
import net.neoforged.neoforge.fluids.FluidStack;
import net.neoforged.neoforge.fluids.FluidType;
import net.neoforged.neoforge.fluids.IFluidBlock;
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
import net.neoforged.neoforge.fluids.capability.templates.FluidTank;

Expand Down Expand Up @@ -157,7 +157,7 @@ public void tick() {
if (RangedPumps.SERVER_CONFIG.getReplaceLiquidWithBlock()) {
if (blockToReplaceLiquidsWith == null) {
blockToReplaceLiquidsWith = BuiltInRegistries.BLOCK.get(
new ResourceLocation(RangedPumps.SERVER_CONFIG.getBlockIdToReplaceLiquidsWith())
ResourceLocation.parse(RangedPumps.SERVER_CONFIG.getBlockIdToReplaceLiquidsWith())
);
}

Expand All @@ -181,23 +181,15 @@ private FluidStack drainAt(BlockPos pos, IFluidHandler.FluidAction action) {
BlockState frontBlockState = level.getBlockState(pos);
Block frontBlock = frontBlockState.getBlock();

if (frontBlock instanceof LiquidBlock) {
// @Volatile: Logic from LiquidBlock#pickupFluid
if (frontBlock instanceof LiquidBlock liquidBlock) {
// @Volatile: Logic from LiquidBlock#pickupBlock
if (frontBlockState.getValue(LiquidBlock.LEVEL) == 0) {
Fluid fluid = ((LiquidBlock) frontBlock).getFluid();

Fluid fluid = liquidBlock.fluid;
if (action == IFluidHandler.FluidAction.EXECUTE) {
level.setBlock(pos, Blocks.AIR.defaultBlockState(), 11);
}

return new FluidStack(fluid, FluidType.BUCKET_VOLUME);
}
} else if (frontBlock instanceof IFluidBlock) {
IFluidBlock fluidBlock = (IFluidBlock) frontBlock;

if (fluidBlock.canDrain(level, pos)) {
return fluidBlock.drain(level, pos, action);
}
}

return FluidStack.EMPTY;
Expand All @@ -214,7 +206,7 @@ int getRange() {
PumpState getState() {
if (range > RangedPumps.SERVER_CONFIG.getRange()) {
return PumpState.DONE;
} else if (level.hasNeighborSignal(worldPosition)) {
} else if (level != null && level.hasNeighborSignal(worldPosition)) {
return PumpState.REDSTONE;
} else if (energy.getEnergyStored() == 0) {
return PumpState.ENERGY;
Expand All @@ -234,8 +226,8 @@ public IEnergyStorage getEnergy() {
}

@Override
public void saveAdditional(CompoundTag tag) {
super.saveAdditional(tag);
public void saveAdditional(CompoundTag tag, HolderLookup.Provider provider) {
super.saveAdditional(tag, provider);

tag.putInt("Energy", energy.getEnergyStored());

Expand All @@ -251,12 +243,12 @@ public void saveAdditional(CompoundTag tag) {

tag.put("Surfaces", surfaces);

tank.writeToNBT(tag);
tank.writeToNBT(provider, tag);
}

@Override
public void load(CompoundTag tag) {
super.load(tag);
public void loadAdditional(CompoundTag tag, HolderLookup.Provider provider) {
super.loadAdditional(tag, provider);

if (tag.contains("Energy")) {
energy.receiveEnergy(tag.getInt("Energy"), false);
Expand All @@ -278,7 +270,7 @@ public void load(CompoundTag tag) {
}
}

tank.readFromNBT(tag);
tank.readFromNBT(provider, tag);
}

private static class PumpTank extends FluidTank {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
}
},
"result": {
"item": "rangedpumps:pump"
"id": "rangedpumps:pump"
}
}

0 comments on commit 21e2256

Please sign in to comment.