Skip to content

Commit

Permalink
1.20.4 NeoForge!
Browse files Browse the repository at this point in the history
Still a lot to do, but this compiles and starts up.
And some things even work.
  • Loading branch information
desht committed Mar 27, 2024
1 parent 5313a58 commit 054f76f
Show file tree
Hide file tree
Showing 1,817 changed files with 14,676 additions and 19,602 deletions.
604 changes: 234 additions & 370 deletions build.gradle

Large diffs are not rendered by default.

44 changes: 26 additions & 18 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,50 @@ org.gradle.daemon=false
#########################################################
# Minecraft versions
#########################################################
mc_version=1.20.1
forge_version=47.1.65
mappings_version=1.20.1-2023.06.26
forge_version_range=[47.1.0,)
minecraft_version_range=[1.20.1,)
minecraft_version=1.20.4
minecraft_version_range=[1.20.4,)
neo_version=20.4.212
neo_version_range=[20.4.190,)
loader_version_range=[1,)
mappings_version=1.20.4-2023.10.22
pack_format_number=18

#########################################################
# Mod version
#########################################################
mod_id=pneumaticcraft
mod_version_massive=6
mod_version_major=0
mod_version_minor=13
curse_project_id=281849
archive_base_name=pneumaticcraft
mod_version=7.0.0
mod_name="PneumaticCraft: Repressurized"
mod_group_id=me.desht
mod_license=GPL3
mod_authors=Des Herriott,Minemaarten
mod_description=Doing cool stuff with pressurized air
modrinth_project_id=ncAcdgk7
curse_project_id=281849

#########################################################
# API versions
#########################################################
jei_version=15.2.0.25
curios_version=5.2.0-beta.3+1.20.1
top_version=1.20.0-9.0.0-1
crafttweaker_version=14.0.17
patchouli_version=1.20.1-83-FORGE
jei_version=17.3.0.49
curios_version=7.3.4+1.20.4
mekanism_version=1.20.4-10.5.6.28
immersive_engineering_version=1.20.4-10.0.1-pre.198
top_version=1.20.4_neo-11.0.2-3
patchouli_version=1.20.4-85-NEOFORGE-SNAPSHOT
cc_tweaked_version=1.110.0
jade_curse_id = 5109393
crafttweaker_version=17.0.9

# TODO update deps when available
botania_version=1.20.1-441-FORGE-SNAPSHOT
cc_tweaked_version=1.100.10
immersive_engineering_version=1.20.1-9.4.0-166.39
ctm_version=1.1.2.6
mekanism_version=1.19.2-10.3.5.474
cofh_core_curse_id=4202944
thermal_cultivation_curse_id=4112131
thermal_expansion_curse_id=4112130
thermal_foundation_curse_id=4112137
thermal_innovation_curse_id=4112132
thermal_locomotion_curse_id=4112134
jade_curse_id = 4573193
create_version = 0.5.1.d-11
flywheel_version = 0.6.9-5
registrate_version = MC1.20-1.3.3
Expand Down
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.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
78 changes: 67 additions & 11 deletions src/api/java/me/desht/pneumaticcraft/api/PNCCapabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
package me.desht.pneumaticcraft.api;

import me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic;
import me.desht.pneumaticcraft.api.pneumatic_armor.hacking.IHacking;
import me.desht.pneumaticcraft.api.tileentity.IAirHandler;
import me.desht.pneumaticcraft.api.tileentity.IAirHandlerItem;
import me.desht.pneumaticcraft.api.tileentity.IAirHandlerMachine;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.CapabilityToken;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.neoforged.neoforge.capabilities.BlockCapability;
import net.neoforged.neoforge.capabilities.EntityCapability;
import net.neoforged.neoforge.capabilities.ItemCapability;

import java.util.Optional;

import static me.desht.pneumaticcraft.api.PneumaticRegistry.RL;

/**
* Public PneumaticCraft capability objects.
Expand All @@ -33,25 +40,74 @@ public class PNCCapabilities {
/**
* Basic air handler; use this capability on entities which can be pressurized (drones by default)
*/
public static final Capability<IAirHandler> AIR_HANDLER_CAPABILITY = CapabilityManager.get(new CapabilityToken<>() {});
public static final EntityCapability<IAirHandler,Void> AIR_HANDLER_ENTITY
= EntityCapability.createVoid(RL("air_handler_entity"), IAirHandler.class);

/**
* Machine air handler; use this on tile entities which can store air.
*/
public static final Capability<IAirHandlerMachine> AIR_HANDLER_MACHINE_CAPABILITY = CapabilityManager.get(new CapabilityToken<>() {});
public static final BlockCapability<IAirHandlerMachine, Direction> AIR_HANDLER_MACHINE
= BlockCapability.createSided(RL("air_handler_machine"), IAirHandlerMachine.class);

/**
* Item air handler; use this on items which can be pressurized.
*/
public static final Capability<IAirHandlerItem> AIR_HANDLER_ITEM_CAPABILITY = CapabilityManager.get(new CapabilityToken<>() {});
public static final ItemCapability<IAirHandlerItem,Void> AIR_HANDLER_ITEM
= ItemCapability.createVoid(RL("air_handler_item"), IAirHandlerItem.class);

/**
* Hacking handler; use this on entities which can be hacked by the Pneumatic Helmet.
* Heat exchanger capability
*/
public static final Capability<IHacking> HACKING_CAPABILITY = CapabilityManager.get(new CapabilityToken<>() {});
public static final BlockCapability<IHeatExchangerLogic,Direction> HEAT_EXCHANGER_BLOCK
= BlockCapability.createSided(RL("heat_exchanger_block"), IHeatExchangerLogic.class);

public static final EntityCapability<IHeatExchangerLogic,Void> HEAT_EXCHANGER_ENTITY
= EntityCapability.createVoid(RL("heat_exchanger_entity"), IHeatExchangerLogic.class);

/* ------------------------------------------------------------------------------------------------------- */

/**
* Heat exchanger capability
* Convenience method to get the air handler for an item, if it exists.
* @param stack the item stack to query
* @return the optional air handler
*/
public static Optional<IAirHandlerItem> getAirHandler(ItemStack stack) {
return Optional.ofNullable(stack.getCapability(AIR_HANDLER_ITEM));
}

/**
* Convenience method to get the air handler for a block entity, if it exists
* @param blockEntity the block entity to query
* @param direction the direction to check
* @return the optional air handler
*/
public static final Capability<IHeatExchangerLogic> HEAT_EXCHANGER_CAPABILITY = CapabilityManager.get(new CapabilityToken<>() {});
public static Optional<IAirHandlerMachine> getAirHandler(BlockEntity blockEntity, Direction direction) {
return Optional.ofNullable(blockEntity.getLevel().getCapability(AIR_HANDLER_MACHINE, blockEntity.getBlockPos(), direction));
}

/**
* Convenience method to get the air handler for a block entity on the null "face", if it exists
* @param blockEntity the block entity to query
* @return the optional air handler
*/
public static Optional<IAirHandlerMachine> getAirHandler(BlockEntity blockEntity) {
return getAirHandler(blockEntity, null);
}

/**
* Convenience method to get the air handler for an entity, if it exists
* @param entity the entity to querty
* @return the optional air handler
*/
public static Optional<IAirHandler> getAirHandler(Entity entity) {
return Optional.ofNullable(entity.getCapability(AIR_HANDLER_ENTITY));
}

public static Optional<IHeatExchangerLogic> getHeatLogic(BlockEntity blockEntity, Direction direction) {
return Optional.ofNullable(blockEntity.getLevel().getCapability(HEAT_EXCHANGER_BLOCK, blockEntity.getBlockPos(), direction));
}

public static Optional<IHeatExchangerLogic> getHeatLogic(BlockEntity blockEntity) {
return getHeatLogic(blockEntity, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import me.desht.pneumaticcraft.api.client.IClientRegistry;
import me.desht.pneumaticcraft.api.client.pneumatic_helmet.IClientArmorRegistry;
import me.desht.pneumaticcraft.api.crafting.IPneumaticRecipeRegistry;
import me.desht.pneumaticcraft.api.crafting.ingredient.CustomIngredientTypes;
import me.desht.pneumaticcraft.api.drone.IDroneRegistry;
import me.desht.pneumaticcraft.api.fuel.IFuelRegistry;
import me.desht.pneumaticcraft.api.heat.IHeatRegistry;
Expand All @@ -32,7 +32,7 @@
import me.desht.pneumaticcraft.api.upgrade.IUpgradeRegistry;
import me.desht.pneumaticcraft.api.wrench.IWrenchRegistry;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.ModLoadingContext;
import net.neoforged.fml.ModLoadingContext;

/**
* This class can be used to register and access various things to and from the mod. All access is via
Expand Down Expand Up @@ -77,8 +77,6 @@ public static ResourceLocation RL(String path) {
* Retrieve an instance of this via {@link PneumaticRegistry#getInstance()}
*/
public interface IPneumaticCraftInterface {
IPneumaticRecipeRegistry getRecipeRegistry();

IAirHandlerMachineFactory getAirHandlerMachineFactory();

IClientArmorRegistry getClientArmorRegistry();
Expand All @@ -104,5 +102,7 @@ public interface IPneumaticCraftInterface {
IMiscHelpers getMiscHelpers();

DamageSources getDamageSources();

CustomIngredientTypes getCustomIngredientTypes();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.neoforged.bus.api.Event;
import net.neoforged.bus.api.ICancellableEvent;

/**
* Fired when a helmet Block Tracker is about to track a block. Can be canceled to prevent tracking.
* Posted on MinecraftForge.EVENT_BUS
*
* @author MineMaarten
*/
@Cancelable
public class BlockTrackEvent extends Event {
public class BlockTrackEvent extends Event implements ICancellableEvent {

public final Level world;
public final BlockPos pos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@
package me.desht.pneumaticcraft.api.client.pneumatic_helmet;

import net.minecraft.world.entity.Entity;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.neoforged.bus.api.Event;
import net.neoforged.bus.api.ICancellableEvent;

/**
* Fired when a helmet Block Tracker is about to track an entity. Can be canceled to prevent tracking.
* Posted on MinecraftForge.EVENT_BUS
*
* @author MineMaarten
*/
@Cancelable
public class EntityTrackEvent extends Event {
public class EntityTrackEvent extends Event implements ICancellableEvent {
public final Entity trackingEntity;

public EntityTrackEvent(Entity trackingEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.neoforged.bus.api.Event;
import net.neoforged.bus.api.ICancellableEvent;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.fluids.capability.IFluidHandler;

/**
* Fired when a helmet Block Tracker is about to track a fluid tank. Can be canceled to prevent tracking.
Expand All @@ -33,8 +33,7 @@
*
* @author MineMaarten
*/
@Cancelable
public class FluidTrackEvent extends Event {
public class FluidTrackEvent extends Event implements ICancellableEvent {
private final BlockEntity te;

public FluidTrackEvent(BlockEntity te) {
Expand All @@ -46,6 +45,6 @@ public IFluidHandler getFluidHandler() {
}

public IFluidHandler getFluidHandler(Direction face) {
return te.getCapability(ForgeCapabilities.FLUID_HANDLER, face).map(iFluidHandler -> iFluidHandler).orElse(null);
return te.getLevel().getCapability(Capabilities.FluidHandler.BLOCK, te.getBlockPos(), te.getBlockState(), te, face);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.client.settings.KeyModifier;
import net.neoforged.neoforge.client.settings.KeyConflictContext;
import net.neoforged.neoforge.client.settings.KeyModifier;
import org.lwjgl.glfw.GLFW;

import java.util.Collection;
Expand Down Expand Up @@ -64,7 +64,7 @@ default ResourceLocation getID() {
}

/**
* This is called when a {@link net.minecraftforge.fml.event.config.ModConfigEvent} is received for the mod.
* This is called when a {@link net.neoforged.fml.event.config.ModConfigEvent} is received for the mod.
*/
default void initConfig() {}

Expand All @@ -82,7 +82,7 @@ default void saveToConfig() {}
void tickClient(ICommonArmorHandler armorHandler, boolean isEnabled);

/**
* Called in the 3D render stage (via {@link net.minecraftforge.client.event.RenderLevelStageEvent})
* Called in the 3D render stage (via {@link net.neoforged.neoforge.client.event.RenderLevelStageEvent})
*
* @param matrixStack the matrix stack
* @param buffer the render type buffer
Expand All @@ -91,7 +91,7 @@ default void saveToConfig() {}
void render3D(PoseStack matrixStack, MultiBufferSource buffer, float partialTicks);

/**
* Called in the 2D render stage (via Forge's {@link net.minecraftforge.client.gui.overlay.IGuiOverlay} system).
* Called in the 2D render stage (via Forge's {@link net.neoforged.neoforge.client.gui.overlay.IGuiOverlay} system).
*
* @param graphics the matrix stack
* @param partialTicks partial ticks since last world tick
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.neoforged.neoforge.capabilities.BlockCapability;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -107,10 +106,12 @@ public interface IBlockTrackEntry {
* @param cap the capability
* @return true if the provider provides the capability on any face, including the null "face"
*/
static boolean hasCapabilityOnAnyFace(ICapabilityProvider provider, Capability<?> cap) {
static boolean hasCapabilityOnAnyFace(BlockEntity provider, BlockCapability<?,Direction> cap) {
for (Direction face : Direction.values()) {
if (provider.getCapability(cap, face).isPresent()) return true;
if (provider.getLevel().getCapability(cap, provider.getBlockPos(), provider.getBlockState(), provider, face) != null) {
return true;
}
}
return provider.getCapability(cap).isPresent();
return provider.getLevel().getCapability(cap, provider.getBlockPos(), provider.getBlockState(), provider, null) != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -76,7 +76,7 @@ default void addHUDMessage(Component title) {

/**
* Registers the client handler for a Pneumatic Armor upgrade. This must be called from a {@link FMLClientSetupEvent}
* handler; do <strong>not</strong> use {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent#enqueueWork(Runnable)}.
* handler; do <strong>not</strong> use {@link net.neoforged.fml.event.lifecycle.FMLClientSetupEvent#enqueueWork(Runnable)}.
* This also registers any keybindings referenced by the render handler
* (see {@link IArmorUpgradeClientHandler#getInitialKeyBinding()} and {@link IArmorUpgradeClientHandler#getSubKeybinds()}.
*
Expand Down
Loading

0 comments on commit 054f76f

Please sign in to comment.