Skip to content

Commit

Permalink
Merge branch 'master' into exnihilo
Browse files Browse the repository at this point in the history
  • Loading branch information
Irgendwer01 authored Dec 17, 2023
2 parents 5dc1af1 + d17b339 commit ec3c4ab
Show file tree
Hide file tree
Showing 38 changed files with 568 additions and 109 deletions.
12 changes: 9 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1701739812
//version: 1702244235
/*
* DO NOT CHANGE THIS FILE!
* Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -79,6 +79,7 @@ propertyDefaultIfUnset("curseForgeRelations", "")
propertyDefaultIfUnsetWithEnvVar("releaseType", "release", "RELEASE_TYPE")
propertyDefaultIfUnset("generateDefaultChangelog", false)
propertyDefaultIfUnset("customMavenPublishUrl", "")
propertyDefaultIfUnset("mavenArtifactGroup", getDefaultArtifactGroup())
propertyDefaultIfUnset("enableModernJavaSyntax", false)
propertyDefaultIfUnset("enableSpotless", false)
propertyDefaultIfUnset("enableJUnit", false)
Expand Down Expand Up @@ -984,8 +985,8 @@ if (customMavenPublishUrl) {
}

// providers is not available here, use System for getting env vars
groupId = System.getenv('ARTIFACT_GROUP_ID') ?: project.group
artifactId = System.getenv('ARTIFACT_ID') ?: project.name
groupId = System.getenv('ARTIFACT_GROUP_ID') ?: project.mavenArtifactGroup
artifactId = System.getenv('ARTIFACT_ID') ?: project.modArchivesBaseName
version = System.getenv('RELEASE_VERSION') ?: publishedVersion
}
}
Expand Down Expand Up @@ -1130,6 +1131,11 @@ tasks.register('faq') {

// Helpers

def getDefaultArtifactGroup() {
def lastIndex = project.modGroup.lastIndexOf('.')
return lastIndex < 0 ? project.modGroup : project.modGroup.substring(0, lastIndex)
}

def getFile(String relativePath) {
return new File(projectDir, relativePath)
}
Expand Down
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies {
compileOnlyApi rfg.deobf("curse.maven:baubles-227083:2518667") // Baubles 1.5.2
compileOnlyApi rfg.deobf("curse.maven:forestry-59751:2684780") // Forestry 5.8.2.387
compileOnlyApi rfg.deobf("curse.maven:exnihilo-274456:2817545") // Ex Nihilo Creatio 0.4.7.2
compileOnlyApi rfg.deobf("curse.maven:chisel-235279:2915375") // Chisel 1.0.2.45

// Mods with Soft compat but which have no need to be in code, such as isModLoaded() checks and getModItem() recipes.
// Uncomment any of these to test them in-game.
Expand Down
17 changes: 16 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ modGroup = gregtech

# Version of your mod.
# This field can be left empty if you want your mod's version to be determined by the latest git tag instead.
modVersion = 2.8.2-beta
modVersion = 2.8.3-beta

# Whether to use the old jar naming structure (modid-mcversion-version) instead of the new version (modid-version)
includeMCVersionJar = true
Expand Down Expand Up @@ -52,6 +52,8 @@ accessTransformersFile = gregtech_at.cfg
usesMixins = false
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Automatically generates a mixin config json if enabled, with the name mixins.modid.json
generateMixinConfig=false
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
coreModClass = asm.GregTechLoadingPlugin
Expand All @@ -75,6 +77,7 @@ includeWellKnownRepositories = true
# Overrides the above setting to be always true, as these repositories are needed to fetch the mods
includeCommonDevEnvMods = true


# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
usesShadowedDependencies = false
Expand Down Expand Up @@ -120,6 +123,7 @@ curseForgeProjectId =
curseForgeRelations = requiredDependency:codechicken-lib-1-8;requiredDependency:modularui;requiredDependency:mixin-booter;incompatible:gregtechce

# This project's release type on CurseForge and/or Modrinth
# Alternatively this can be set with the 'RELEASE_TYPE' environment variable.
# Allowed types: release, beta, alpha
releaseType = beta

Expand All @@ -129,6 +133,17 @@ generateDefaultChangelog = false

# Prevent the source code from being published
noPublishedSources = false
# Publish to a custom maven location. Follows a few rules:
# Group ID can be set with the 'ARTIFACT_GROUP_ID' environment variable, default to 'project.group'
# Artifact ID can be set with the 'ARTIFACT_ID' environment variable, default to 'project.name'
# Version can be set with the 'RELEASE_VERSION' environment variable, default to 'modVersion'
# For maven credentials:
# Username is set with the 'MAVEN_USER' environment variable, default to "NONE"
# Password is set with the 'MAVEN_PASSWORD' environment variable, default to "NONE"
customMavenPublishUrl=
# The group for maven artifacts. Defaults to the 'project.modGroup' until the last '.' (if any).
# So 'mymod' becomes 'mymod' and 'com.myname.mymodid' 'becomes com.myname'
mavenArtifactGroup=

# Enable spotless checks
# Enforces code formatting on your source code
Expand Down
78 changes: 78 additions & 0 deletions src/api/java/mods/railcraft/api/items/IToolCrowbar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*------------------------------------------------------------------------------
Copyright (c) CovertJaguar, 2011-2020
This work (the API) is licensed under the "MIT" License,
see LICENSE.md for details.
-----------------------------------------------------------------------------*/
package mods.railcraft.api.items;

import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;

/**
* @author CovertJaguar <http://www.railcraft.info>
*/
public interface IToolCrowbar {
String ORE_TAG = "toolCrowbar";

/**
* Controls non-rotational interactions with blocks. Crowbar specific stuff.
* <p/>
* Rotational interaction is handled by the Block.rotateBlock() function,
* which should be called from the Item.onUseFirst() function of your tool.
*
* @param player the player
* @param crowbar the crowbar
* @param pos the block @return true if can whack a block
*/
boolean canWhack(EntityPlayer player, EnumHand hand, ItemStack crowbar, BlockPos pos);

/**
* Callback to do damage to the item.
*
* @param player the player
* @param crowbar the crowbar
* @param pos the block
*/
void onWhack(EntityPlayer player, EnumHand hand, ItemStack crowbar, BlockPos pos);

/**
* Controls whether you can link a cart.
*
* @param player the player
* @param crowbar the crowbar
* @param cart the cart @return true if can link a cart
*/
boolean canLink(EntityPlayer player, EnumHand hand, ItemStack crowbar, EntityMinecart cart);

/**
* Callback to do damage.
*
* @param player the player
* @param crowbar the crowbar
* @param cart the cart
*/
void onLink(EntityPlayer player, EnumHand hand, ItemStack crowbar, EntityMinecart cart);

/**
* Controls whether you can boost a cart.
*
* @param player the player
* @param crowbar the crowbar
* @param cart the cart @return true if can boost a cart
*/
boolean canBoost(EntityPlayer player, EnumHand hand, ItemStack crowbar, EntityMinecart cart);

/**
* Callback to do damage, boosting a cart usually does more damage than
* normal usage.
*
* @param player the player
* @param crowbar the crowbar
* @param cart the cart
*/
void onBoost(EntityPlayer player, EnumHand hand, ItemStack crowbar, EntityMinecart cart);
}
11 changes: 11 additions & 0 deletions src/api/java/mrtjp/projectred/api/IScrewdriver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package mrtjp.projectred.api;

import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.EntityPlayer;

public interface IScrewdriver {

boolean canUse(EntityPlayer player, ItemStack stack);

void damageScrewdriver(EntityPlayer player, ItemStack stack); // Damage the item on usage
}
5 changes: 4 additions & 1 deletion src/main/java/gregtech/api/GTValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ public class GTValues {
MODID_BOP = "biomesoplenty",
MODID_TCON = "tconstruct",
MODID_EN = "exnihilocreatio";

MODID_PROJRED_CORE = "projectred-core",
MODID_RC = "railcraft",
MODID_CHISEL = "chisel";

private static Boolean isClient;

public static boolean isClientSide() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,7 @@ protected int[] calculateOverclock(@NotNull Recipe recipe) {
* @param recipe the recipe to overclock
* @return an int array of {OverclockedEUt, OverclockedDuration}
*/
@NotNull
protected int[] performOverclocking(@NotNull Recipe recipe) {
protected int @NotNull [] performOverclocking(@NotNull Recipe recipe) {
int[] values = { recipe.getEUt(), recipe.getDuration(), getNumberOfOCs(recipe.getEUt()) };
modifyOverclockPre(values, recipe.getRecipePropertyStorage());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,16 @@ private boolean handleElectricItem(IElectricItem electricItem) {
// Check if the item is a battery (or similar), and if we can receive some amount of energy
if (electricItem.canProvideChargeExternally() && getEnergyCanBeInserted() > 0) {

// Drain from the battery if we are below half energy capacity, and if the tier matches
if (chargePercent <= 0.5 && chargeTier == machineTier) {
// Drain from the battery if we are below 1/3rd energy capacity, and if the tier matches
if (chargePercent <= 0.33 && chargeTier == machineTier) {
long dischargedBy = electricItem.discharge(getEnergyCanBeInserted(), machineTier, false, true, false);
addEnergy(dischargedBy);
return dischargedBy > 0L;
}
}

// Else, check if we have above 50% power
if (chargePercent > 0.5) {
// Else, check if we have above 2/3rds charge
if (chargePercent > 0.66) {
long chargedBy = electricItem.charge(getEnergyStored(), chargeTier, false, false);
removeEnergy(chargedBy);
return chargedBy > 0;
Expand All @@ -178,7 +178,7 @@ private boolean handleForgeEnergyItem(IEnergyStorage energyStorage) {
int machineTier = GTUtility.getTierByVoltage(Math.max(getInputVoltage(), getOutputVoltage()));
double chargePercent = getEnergyStored() / (getEnergyCapacity() * 1.0);

if (chargePercent > 0.5) {
if (chargePercent > 0.66) { // 2/3rds full
long chargedBy = FeCompat.insertEu(energyStorage, GTValues.V[machineTier]);
removeEnergy(chargedBy);
return chargedBy > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ protected boolean prepareRecipeDistinct(Recipe recipe) {
}

@Override
protected void modifyOverclockPre(@NotNull int[] values, @NotNull IRecipePropertyStorage storage) {
protected void modifyOverclockPre(int @NotNull [] values, @NotNull IRecipePropertyStorage storage) {
super.modifyOverclockPre(values, storage);

// apply maintenance bonuses
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gregtech/api/fluids/FluidBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ private void determineTemperature(@Nullable Material material) {
}
case GAS -> ROOM_TEMPERATURE;
case PLASMA -> {
if (material.hasFluid()) {
if (material.hasFluid() && material.getFluid() != null) {
yield BASE_PLASMA_TEMPERATURE + material.getFluid().getTemperature();
}
yield BASE_PLASMA_TEMPERATURE;
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/gregtech/api/fluids/store/FluidStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Comparator;
import java.util.Map;

public final class FluidStorage {
Expand Down Expand Up @@ -69,12 +70,14 @@ public void registerFluids(@NotNull Material material) {
enqueueRegistration(FluidStorageKeys.LIQUID, new FluidBuilder());
}

for (var entry : toRegister.entrySet()) {
Fluid fluid = entry.getValue().build(material.getModid(), material, entry.getKey());
if (!storeNoOverwrites(entry.getKey(), fluid)) {
GTLog.logger.error("{} already has an associated fluid for material {}", material);
}
}
toRegister.entrySet().stream()
.sorted(Comparator.comparingInt(e -> -e.getKey().getRegistrationPriority()))
.forEach(entry -> {
Fluid fluid = entry.getValue().build(material.getModid(), material, entry.getKey());
if (!storeNoOverwrites(entry.getKey(), fluid)) {
GTLog.logger.error("{} already has an associated fluid for material {}", material);
}
});
toRegister = null;
registered = true;
}
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/gregtech/api/fluids/store/FluidStorageKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public final class FluidStorageKey {
private final Function<Material, String> translationKeyFunction;
private final int hashCode;
private final FluidState defaultFluidState;
private final int registrationPriority;

public FluidStorageKey(@NotNull ResourceLocation resourceLocation, @NotNull MaterialIconType iconType,
@NotNull UnaryOperator<@NotNull String> registryNameOperator,
Expand All @@ -35,12 +36,20 @@ public FluidStorageKey(@NotNull ResourceLocation resourceLocation, @NotNull Mate
@NotNull UnaryOperator<@NotNull String> registryNameOperator,
@NotNull Function<@NotNull Material, @NotNull String> translationKeyFunction,
@Nullable FluidState defaultFluidState) {
this(resourceLocation, iconType, registryNameOperator, translationKeyFunction, defaultFluidState, 0);
}

public FluidStorageKey(@NotNull ResourceLocation resourceLocation, @NotNull MaterialIconType iconType,
@NotNull UnaryOperator<@NotNull String> registryNameOperator,
@NotNull Function<@NotNull Material, @NotNull String> translationKeyFunction,
@Nullable FluidState defaultFluidState, int registrationPriority) {
this.resourceLocation = resourceLocation;
this.iconType = iconType;
this.registryNameOperator = registryNameOperator;
this.translationKeyFunction = translationKeyFunction;
this.hashCode = resourceLocation.hashCode();
this.defaultFluidState = defaultFluidState;
this.registrationPriority = registrationPriority;
if (keys.containsKey(resourceLocation)) {
throw new IllegalArgumentException("Cannot create duplicate keys");
}
Expand Down Expand Up @@ -81,6 +90,14 @@ public FluidStorageKey(@NotNull ResourceLocation resourceLocation, @NotNull Mate
return defaultFluidState;
}

/**
* @return The registration priority for this fluid type, determining the build order for fluids.
* Useful for when your fluid building requires some properties from previous fluids.
*/
public int getRegistrationPriority() {
return registrationPriority;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class FluidStorageKeys {
public static final FluidStorageKey PLASMA = new FluidStorageKey(gregtechId("plasma"),
MaterialIconType.plasma,
s -> "plasma." + s, m -> "gregtech.fluid.plasma",
FluidState.PLASMA);
FluidState.PLASMA, -1);

private FluidStorageKeys() {}
}
Loading

0 comments on commit ec3c4ab

Please sign in to comment.