Skip to content

Commit

Permalink
Port to 1.19.2 - v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Sep 30, 2022
1 parent 0d3ea27 commit 820c561
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ body:
If your Minecraft version isn't listed here, it means that it's no longer supported. In that case, don't create an issue.
options:
- Minecraft 1.18.2
- Minecraft 1.16.5
- Minecraft 1.19.2
validations:
required: true
- type: input
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Ported to Minecraft 1.19.2.

## [0.9.2] - 2022-03-26

### Changed
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply plugin: 'maven-publish'

group = 'com.refinedmods'
archivesBaseName = 'rangedpumps'
version = '0.9.3'
version = '1.0.0'

if (System.getenv('GITHUB_SHA') != null) {
version += '+' + System.getenv('GITHUB_SHA').substring(0, 7)
Expand All @@ -31,7 +31,7 @@ if (System.getenv('RELEASE') != null) {
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

minecraft {
mappings channel: 'official', version: '1.18.2'
mappings channel: 'official', version: '1.19.2'

runs {
client {
Expand Down Expand Up @@ -79,7 +79,7 @@ processResources {
}

dependencies {
minecraft 'net.minecraftforge:forge:1.18.2-40.0.32'
minecraft 'net.minecraftforge:forge:1.19.2-43.1.32'
}

jar {
Expand All @@ -104,7 +104,7 @@ if (System.getenv("CURSEFORGE_TOKEN") != null) {
changelog = System.getenv("CHANGELOG")
changelogType = 'markdown'
releaseType = project.version.toString().contains('beta') ? 'beta' : (project.version.toString().contains('alpha') ? 'alpha' : 'release')
addGameVersion "1.18.2"
addGameVersion "1.19.2"
mainArtifact(jar) {
displayName = "v$project.version"
}
Expand Down
25 changes: 20 additions & 5 deletions src/main/java/com/refinedmods/rangedpumps/RangedPumps.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.refinedmods.rangedpumps;

import com.refinedmods.rangedpumps.block.PumpBlock;
import com.refinedmods.rangedpumps.blockentity.PumpBlockEntity;
import com.refinedmods.rangedpumps.config.ServerConfig;
import com.refinedmods.rangedpumps.item.group.MainCreativeModeTab;
import com.refinedmods.rangedpumps.setup.CommonSetup;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
Expand All @@ -11,18 +13,31 @@
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

@Mod(RangedPumps.ID)
public final class RangedPumps {
public static final String ID = "rangedpumps";

private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ID);
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ID);
private static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, ID);

public static RegistryObject<PumpBlock> PUMP_BLOCK;
public static RegistryObject<BlockEntityType<PumpBlockEntity>> PUMP_BLOCK_ENTITY_TYPE;

public static final CreativeModeTab CREATIVE_MODE_TAB = new MainCreativeModeTab();
public static final ServerConfig SERVER_CONFIG = new ServerConfig();

public RangedPumps() {
PUMP_BLOCK = BLOCKS.register("pump", PumpBlock::new);
ITEMS.register("pump", () -> new BlockItem(PUMP_BLOCK.get(), new Item.Properties().tab(RangedPumps.CREATIVE_MODE_TAB)));
PUMP_BLOCK_ENTITY_TYPE = BLOCK_ENTITY_TYPES.register("pump", () -> BlockEntityType.Builder.of(PumpBlockEntity::new, PUMP_BLOCK.get()).build(null));
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_CONFIG.getSpec());

FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(Block.class, CommonSetup::onRegisterBlocks);
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(BlockEntityType.class, CommonSetup::onRegisterBlockEntities);
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(Item.class, CommonSetup::onRegisterItems);
BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
BLOCK_ENTITY_TYPES.register(FMLJavaModLoadingContext.get().getModEventBus());
}
}
15 changes: 4 additions & 11 deletions src/main/java/com/refinedmods/rangedpumps/block/PumpBlock.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.refinedmods.rangedpumps.block;

import com.refinedmods.rangedpumps.RangedPumps;
import com.refinedmods.rangedpumps.blockentity.PumpState;
import com.refinedmods.rangedpumps.blockentity.PumpBlockEntity;
import com.refinedmods.rangedpumps.blockentity.PumpState;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
Expand All @@ -24,16 +23,10 @@
import net.minecraftforge.registries.ObjectHolder;

public class PumpBlock extends Block implements EntityBlock {
@ObjectHolder(RangedPumps.ID + ":pump")
public static final PumpBlock BLOCK = null;

public PumpBlock() {
super(Block.Properties.of(Material.STONE).strength(1.9F).sound(SoundType.STONE));

setRegistryName(RangedPumps.ID, "pump");
}


@SuppressWarnings("deprecation")
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (!level.isClientSide) {
Expand All @@ -48,13 +41,13 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player
Component message = PumpState.getMessage(pump);

if (message != null) {
player.sendMessage(message, player.getUUID());
player.sendSystemMessage(message);
}

if (pump.getTank().getFluidAmount() == 0) {
player.sendMessage(new TranslatableComponent("block." + RangedPumps.ID + ".pump.state_empty", energy.getEnergyStored(), energy.getMaxEnergyStored()), player.getUUID());
player.sendSystemMessage(Component.translatable("block." + RangedPumps.ID + ".pump.state_empty", energy.getEnergyStored(), energy.getMaxEnergyStored()));
} else {
player.sendMessage(new TranslatableComponent("block." + RangedPumps.ID + ".pump.state", pump.getTank().getFluidAmount(), pump.getTank().getFluid().getDisplayName(), energy.getEnergyStored(), energy.getMaxEnergyStored()), player.getUUID());
player.sendSystemMessage(Component.translatable("block." + RangedPumps.ID + ".pump.state", pump.getTank().getFluidAmount(), pump.getTank().getFluid().getDisplayName(), energy.getEnergyStored(), energy.getMaxEnergyStored()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.EnergyStorage;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidType;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.templates.FluidTank;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ObjectHolder;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -36,9 +33,6 @@
import java.util.Queue;

public class PumpBlockEntity extends BlockEntity {
@ObjectHolder(RangedPumps.ID + ":pump")
public static final BlockEntityType<PumpBlockEntity> TYPE = null;

private PumpTank tank = new PumpTank();
private IEnergyStorage energy = new EnergyStorage(RangedPumps.SERVER_CONFIG.getEnergyCapacity());

Expand All @@ -54,7 +48,7 @@ public class PumpBlockEntity extends BlockEntity {
private Block blockToReplaceLiquidsWith;

public PumpBlockEntity(BlockPos pos, BlockState state) {
super(TYPE, pos, state);
super(RangedPumps.PUMP_BLOCK_ENTITY_TYPE.get(), pos, state);
}

private void rebuildSurfaces() {
Expand Down Expand Up @@ -111,7 +105,7 @@ public void tick() {
BlockEntity blockEntity = level.getBlockEntity(worldPosition.relative(facing));

if (blockEntity != null) {
IFluidHandler handler = blockEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite()).orElse(null);
IFluidHandler handler = blockEntity.getCapability(ForgeCapabilities.FLUID_HANDLER, facing.getOpposite()).orElse(null);

if (handler != null) {
fluidHandlers.add(handler);
Expand Down Expand Up @@ -192,7 +186,7 @@ private FluidStack drainAt(BlockPos pos, IFluidHandler.FluidAction action) {
level.setBlock(pos, Blocks.AIR.defaultBlockState(), 11);
}

return new FluidStack(fluid, FluidAttributes.BUCKET_VOLUME);
return new FluidStack(fluid, FluidType.BUCKET_VOLUME);
}
} else if (frontBlock instanceof IFluidBlock) {
IFluidBlock fluidBlock = (IFluidBlock) frontBlock;
Expand Down Expand Up @@ -220,7 +214,7 @@ PumpState getState() {
return PumpState.REDSTONE;
} else if (energy.getEnergyStored() == 0) {
return PumpState.ENERGY;
} else if (tank.getFluidAmount() > tank.getCapacity() - FluidAttributes.BUCKET_VOLUME) {
} else if (tank.getFluidAmount() > tank.getCapacity() - FluidType.BUCKET_VOLUME) {
return PumpState.FULL;
} else {
return PumpState.WORKING;
Expand Down Expand Up @@ -282,11 +276,11 @@ public void load(CompoundTag tag) {
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
if (cap == CapabilityEnergy.ENERGY) {
if (cap == ForgeCapabilities.ENERGY) {
return energyProxyCap.cast();
}

if (cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
if (cap == ForgeCapabilities.FLUID_HANDLER) {
return fluidHandlerCap.cast();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.refinedmods.rangedpumps.RangedPumps;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;

public enum PumpState {
ENERGY,
Expand All @@ -12,19 +11,13 @@ public enum PumpState {
DONE;

public static Component getMessage(PumpBlockEntity pump) {
switch (pump.getState()) {
case ENERGY:
return new TranslatableComponent("block.rangedpumps.pump.state.energy");
case REDSTONE:
return new TranslatableComponent("block.rangedpumps.pump.state.redstone");
case WORKING:
return new TranslatableComponent("block.rangedpumps.pump.state.working", pump.getCurrentPosition().getX(), pump.getCurrentPosition().getY(), pump.getCurrentPosition().getZ(), pump.getRange(), RangedPumps.SERVER_CONFIG.getRange());
case FULL:
return new TranslatableComponent("block.rangedpumps.pump.state.full");
case DONE:
return new TranslatableComponent("block.rangedpumps.pump.state.done");
default:
return null;
}
return switch (pump.getState()) {
case ENERGY -> Component.translatable("block.rangedpumps.pump.state.energy");
case REDSTONE -> Component.translatable("block.rangedpumps.pump.state.redstone");
case WORKING ->
Component.translatable("block.rangedpumps.pump.state.working", pump.getCurrentPosition().getX(), pump.getCurrentPosition().getY(), pump.getCurrentPosition().getZ(), pump.getRange(), RangedPumps.SERVER_CONFIG.getRange());
case FULL -> Component.translatable("block.rangedpumps.pump.state.full");
case DONE -> Component.translatable("block.rangedpumps.pump.state.done");
};
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.refinedmods.rangedpumps.config;

import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidType;

public class ServerConfig {
private ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
Expand All @@ -22,7 +22,7 @@ public ServerConfig() {

range = builder.comment("The range of the pump").defineInRange("range", 64, 0, 1024);
speed = builder.comment("The interval in ticks for when to move on to the next block (higher is slower)").defineInRange("speed", 8, 0, 1024);
tankCapacity = builder.comment("The capacity of the internal pump tank").defineInRange("tankCapacity", FluidAttributes.BUCKET_VOLUME * 32, FluidAttributes.BUCKET_VOLUME, Integer.MAX_VALUE);
tankCapacity = builder.comment("The capacity of the internal pump tank").defineInRange("tankCapacity", FluidType.BUCKET_VOLUME * 32, FluidType.BUCKET_VOLUME, Integer.MAX_VALUE);
energyCapacity = builder.comment("The capacity of the energy storage").defineInRange("energyCapacity", 32000, 0, Integer.MAX_VALUE);
energyUsagePerMove = builder.comment("Energy drained when moving to the next block").defineInRange("energyUsagePerMove", 0, 0, Integer.MAX_VALUE);
energyUsagePerDrain = builder.comment("Energy drained when draining liquid").defineInRange("energyUsagePerDrain", 100, 0, Integer.MAX_VALUE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.refinedmods.rangedpumps.item.group;

import com.refinedmods.rangedpumps.RangedPumps;
import com.refinedmods.rangedpumps.block.PumpBlock;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;

Expand All @@ -12,6 +11,6 @@ public MainCreativeModeTab() {

@Override
public ItemStack makeIcon() {
return new ItemStack(PumpBlock.BLOCK);
return new ItemStack(RangedPumps.PUMP_BLOCK.get());
}
}
31 changes: 0 additions & 31 deletions src/main/java/com/refinedmods/rangedpumps/setup/CommonSetup.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader = "javafml"
loaderVersion = "[40,)"
loaderVersion = "[43,)"
issueTrackerURL = "https://github.com/refinedmods/rangedpumps"
license = "MIT"
[[mods]]
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"pack": {
"description": "Ranged Pumps resources",
"pack_format": 9
"pack_format": 9,
"forge:resource_pack_format": 9,
"forge:data_pack_format": 10
}
}

0 comments on commit 820c561

Please sign in to comment.