diff --git a/build.gradle b/build.gradle index 5e4447c6c45..29b2ba602bf 100644 --- a/build.gradle +++ b/build.gradle @@ -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. @@ -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) @@ -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 } } @@ -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) } diff --git a/dependencies.gradle b/dependencies.gradle index fb869ab4336..26cf283342c 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -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. diff --git a/gradle.properties b/gradle.properties index 2cc4c9a9e46..e213ae3b547 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/api/java/mods/railcraft/api/items/IToolCrowbar.java b/src/api/java/mods/railcraft/api/items/IToolCrowbar.java new file mode 100644 index 00000000000..7b8006b5ec2 --- /dev/null +++ b/src/api/java/mods/railcraft/api/items/IToolCrowbar.java @@ -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 + */ +public interface IToolCrowbar { + String ORE_TAG = "toolCrowbar"; + + /** + * Controls non-rotational interactions with blocks. Crowbar specific stuff. + *

+ * 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); +} diff --git a/src/api/java/mrtjp/projectred/api/IScrewdriver.java b/src/api/java/mrtjp/projectred/api/IScrewdriver.java new file mode 100644 index 00000000000..a6298fecefd --- /dev/null +++ b/src/api/java/mrtjp/projectred/api/IScrewdriver.java @@ -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 +} diff --git a/src/main/java/gregtech/api/GTValues.java b/src/main/java/gregtech/api/GTValues.java index 9f2d7a6b7fd..d85bf34651e 100644 --- a/src/main/java/gregtech/api/GTValues.java +++ b/src/main/java/gregtech/api/GTValues.java @@ -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() { diff --git a/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java b/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java index a241b32b3a0..cc2ce878aee 100644 --- a/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java +++ b/src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java @@ -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()); diff --git a/src/main/java/gregtech/api/capability/impl/EnergyContainerHandler.java b/src/main/java/gregtech/api/capability/impl/EnergyContainerHandler.java index 81972c3f5d7..37688a4deec 100644 --- a/src/main/java/gregtech/api/capability/impl/EnergyContainerHandler.java +++ b/src/main/java/gregtech/api/capability/impl/EnergyContainerHandler.java @@ -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; @@ -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; diff --git a/src/main/java/gregtech/api/capability/impl/MultiblockRecipeLogic.java b/src/main/java/gregtech/api/capability/impl/MultiblockRecipeLogic.java index 3917d4a7bda..1ebb3e73c82 100644 --- a/src/main/java/gregtech/api/capability/impl/MultiblockRecipeLogic.java +++ b/src/main/java/gregtech/api/capability/impl/MultiblockRecipeLogic.java @@ -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 diff --git a/src/main/java/gregtech/api/fluids/FluidBuilder.java b/src/main/java/gregtech/api/fluids/FluidBuilder.java index 757369b75ae..f7a75111cc4 100644 --- a/src/main/java/gregtech/api/fluids/FluidBuilder.java +++ b/src/main/java/gregtech/api/fluids/FluidBuilder.java @@ -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; diff --git a/src/main/java/gregtech/api/fluids/store/FluidStorage.java b/src/main/java/gregtech/api/fluids/store/FluidStorage.java index f9a232b0d27..fe7505423d0 100644 --- a/src/main/java/gregtech/api/fluids/store/FluidStorage.java +++ b/src/main/java/gregtech/api/fluids/store/FluidStorage.java @@ -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 { @@ -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; } diff --git a/src/main/java/gregtech/api/fluids/store/FluidStorageKey.java b/src/main/java/gregtech/api/fluids/store/FluidStorageKey.java index 01f44dcc8da..7b58514aa35 100644 --- a/src/main/java/gregtech/api/fluids/store/FluidStorageKey.java +++ b/src/main/java/gregtech/api/fluids/store/FluidStorageKey.java @@ -24,6 +24,7 @@ public final class FluidStorageKey { private final Function 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, @@ -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"); } @@ -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; diff --git a/src/main/java/gregtech/api/fluids/store/FluidStorageKeys.java b/src/main/java/gregtech/api/fluids/store/FluidStorageKeys.java index 10407e03b03..3b9a6be51e8 100644 --- a/src/main/java/gregtech/api/fluids/store/FluidStorageKeys.java +++ b/src/main/java/gregtech/api/fluids/store/FluidStorageKeys.java @@ -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() {} } diff --git a/src/main/java/gregtech/api/items/toolitem/IGTTool.java b/src/main/java/gregtech/api/items/toolitem/IGTTool.java index 300c36f537e..4c3ba369341 100644 --- a/src/main/java/gregtech/api/items/toolitem/IGTTool.java +++ b/src/main/java/gregtech/api/items/toolitem/IGTTool.java @@ -40,6 +40,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.EntityEquipmentSlot; @@ -68,6 +69,8 @@ import forestry.api.arboriculture.IToolGrafter; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; +import mods.railcraft.api.items.IToolCrowbar; +import mrtjp.projectred.api.IScrewdriver; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -91,10 +94,12 @@ @Optional.Interface(modid = GTValues.MODID_COFH, iface = "cofh.api.item.IToolHammer"), @Optional.Interface(modid = GTValues.MODID_EIO, iface = "crazypants.enderio.api.tool.ITool"), @Optional.Interface(modid = GTValues.MODID_FR, iface = "forestry.api.arboriculture.IToolGrafter"), + @Optional.Interface(modid = GTValues.MODID_PROJRED_CORE, iface = "mrtjp.projectred.api.IScrewdriver"), + @Optional.Interface(modid = GTValues.MODID_RC, iface = "mods.railcraft.api.items.IToolCrowbar"), @Optional.Interface(modid = GTValues.MODID_ECORE, iface = "com.enderio.core.common.interfaces.IOverlayRenderAware") }) public interface IGTTool extends ItemUIFactory, IAEWrench, IToolWrench, IToolHammer, ITool, IToolGrafter, - IOverlayRenderAware { + IOverlayRenderAware, IScrewdriver, IToolCrowbar { /** * @return the modid of the tool @@ -1042,4 +1047,47 @@ default float getSaplingModifier(ItemStack stack, World world, EntityPlayer play default void renderItemOverlayIntoGUI(@NotNull ItemStack stack, int xPosition, int yPosition) { ToolChargeBarRenderer.renderBarsTool(this, stack, xPosition, yPosition); } + + // IScrewdriver + @Override + default boolean canUse(EntityPlayer player, ItemStack stack) { + return get().getToolClasses(stack).contains(ToolClasses.SCREWDRIVER); + } + + @Override + default void damageScrewdriver(EntityPlayer player, ItemStack stack) { + damageItem(stack, player); + } + + // IToolCrowbar + + @Override + default boolean canWhack(EntityPlayer player, EnumHand hand, ItemStack crowbar, BlockPos pos) { + return get().getToolClasses(crowbar).contains(ToolClasses.CROWBAR); + } + + @Override + default void onWhack(EntityPlayer player, EnumHand hand, ItemStack crowbar, BlockPos pos) { + damageItem(crowbar, player); + } + + @Override + default boolean canLink(EntityPlayer player, EnumHand hand, ItemStack crowbar, EntityMinecart cart) { + return get().getToolClasses(crowbar).contains(ToolClasses.CROWBAR); + } + + @Override + default void onLink(EntityPlayer player, EnumHand hand, ItemStack crowbar, EntityMinecart cart) { + damageItem(crowbar, player); + } + + @Override + default boolean canBoost(EntityPlayer player, EnumHand hand, ItemStack crowbar, EntityMinecart cart) { + return get().getToolClasses(crowbar).contains(ToolClasses.CROWBAR); + } + + @Override + default void onBoost(EntityPlayer player, EnumHand hand, ItemStack crowbar, EntityMinecart cart) { + damageItem(crowbar, player); + } } diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockWithDisplayBase.java b/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockWithDisplayBase.java index a94c78ccdff..55723ef456d 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockWithDisplayBase.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockWithDisplayBase.java @@ -275,7 +275,7 @@ public boolean isMufflerFaceFree() { } /** - * @deprecated Use {@link gregtech.client.particle.VanillaParticleEffects#MUFFLER_SMOKE} instead. + * @deprecated Override {@link #getMufflerParticle()} instead. */ @ApiStatus.ScheduledForRemoval(inVersion = "2.9") @Deprecated @@ -284,6 +284,11 @@ public void runMufflerEffect(float xPos, float yPos, float zPos, float xSpd, flo getWorld().spawnParticle(EnumParticleTypes.SMOKE_LARGE, xPos, yPos, zPos, xSpd, ySpd, zSpd); } + @SideOnly(Side.CLIENT) + public @NotNull EnumParticleTypes getMufflerParticle() { + return EnumParticleTypes.SMOKE_LARGE; + } + /** * Sets the recovery items of this multiblock * diff --git a/src/main/java/gregtech/api/recipes/builders/AssemblyLineRecipeBuilder.java b/src/main/java/gregtech/api/recipes/builders/AssemblyLineRecipeBuilder.java index 2d9d5006c1b..9ddc9d6851b 100644 --- a/src/main/java/gregtech/api/recipes/builders/AssemblyLineRecipeBuilder.java +++ b/src/main/java/gregtech/api/recipes/builders/AssemblyLineRecipeBuilder.java @@ -155,6 +155,7 @@ public static class ResearchRecipeEntry { private final String researchId; private final ItemStack researchStack; private final ItemStack dataStack; + private final boolean ignoreNBT; private final int duration; private final int EUt; private final int CWUt; @@ -166,6 +167,9 @@ public static class ResearchRecipeEntry { * @param duration the duration of the recipe * @param EUt the EUt of the recipe * @param CWUt how much computation per tick this recipe needs if in Research Station + *

+ * By default, will ignore NBT on researchStack input. If NBT matching is desired, see + * {@link #ResearchRecipeEntry(String, ItemStack, ItemStack, boolean, int, int, int)} */ public ResearchRecipeEntry(@NotNull String researchId, @NotNull ItemStack researchStack, @NotNull ItemStack dataStack, int duration, int EUt, int CWUt) { @@ -175,6 +179,26 @@ public ResearchRecipeEntry(@NotNull String researchId, @NotNull ItemStack resear this.duration = duration; this.EUt = EUt; this.CWUt = CWUt; + this.ignoreNBT = true; + } + + /** + * @param researchId the id of the research to store + * @param researchStack the stack to scan for research + * @param dataStack the stack to contain the data + * @param duration the duration of the recipe + * @param EUt the EUt of the recipe + * @param CWUt how much computation per tick this recipe needs if in Research Station + */ + public ResearchRecipeEntry(@NotNull String researchId, @NotNull ItemStack researchStack, + @NotNull ItemStack dataStack, boolean ignoreNBT, int duration, int EUt, int CWUt) { + this.researchId = researchId; + this.researchStack = researchStack; + this.dataStack = dataStack; + this.ignoreNBT = ignoreNBT; + this.duration = duration; + this.EUt = EUt; + this.CWUt = CWUt; } @NotNull @@ -192,6 +216,10 @@ public ItemStack getDataStack() { return dataStack; } + public boolean getIgnoreNBT() { + return ignoreNBT; + } + public int getDuration() { return duration; } diff --git a/src/main/java/gregtech/api/recipes/builders/ResearchRecipeBuilder.java b/src/main/java/gregtech/api/recipes/builders/ResearchRecipeBuilder.java index bbbda50d520..b20da993e70 100644 --- a/src/main/java/gregtech/api/recipes/builders/ResearchRecipeBuilder.java +++ b/src/main/java/gregtech/api/recipes/builders/ResearchRecipeBuilder.java @@ -15,12 +15,22 @@ public abstract class ResearchRecipeBuilder> protected ItemStack researchStack; protected ItemStack dataStack; + protected boolean ignoreNBT; protected String researchId; protected int eut; public T researchStack(@NotNull ItemStack researchStack) { if (!researchStack.isEmpty()) { this.researchStack = researchStack; + this.ignoreNBT = true; + } + return (T) this; + } + + public T researchStack(@NotNull ItemStack researchStack, boolean ignoreNBT) { + if (!researchStack.isEmpty()) { + this.researchStack = researchStack; + this.ignoreNBT = ignoreNBT; } return (T) this; } @@ -99,7 +109,8 @@ protected AssemblyLineRecipeBuilder.ResearchRecipeEntry build() { validateResearchItem(); if (duration <= 0) duration = DEFAULT_SCANNER_DURATION; if (eut <= 0) eut = DEFAULT_SCANNER_EUT; - return new AssemblyLineRecipeBuilder.ResearchRecipeEntry(researchId, researchStack, dataStack, duration, + return new AssemblyLineRecipeBuilder.ResearchRecipeEntry(researchId, researchStack, dataStack, ignoreNBT, + duration, eut, 0); } } @@ -148,7 +159,8 @@ protected AssemblyLineRecipeBuilder.ResearchRecipeEntry build() { int duration = totalCWU; if (eut <= 0) eut = DEFAULT_STATION_EUT; - return new AssemblyLineRecipeBuilder.ResearchRecipeEntry(researchId, researchStack, dataStack, duration, + return new AssemblyLineRecipeBuilder.ResearchRecipeEntry(researchId, researchStack, dataStack, ignoreNBT, + duration, eut, cwut); } } diff --git a/src/main/java/gregtech/api/recipes/recipeproperties/FusionEUToStartProperty.java b/src/main/java/gregtech/api/recipes/recipeproperties/FusionEUToStartProperty.java index 12fd90e7748..60188d8cd5f 100644 --- a/src/main/java/gregtech/api/recipes/recipeproperties/FusionEUToStartProperty.java +++ b/src/main/java/gregtech/api/recipes/recipeproperties/FusionEUToStartProperty.java @@ -6,6 +6,7 @@ import net.minecraft.client.resources.I18n; import org.apache.commons.lang3.Validate; +import org.apache.commons.lang3.tuple.Pair; import java.util.Map; import java.util.TreeMap; @@ -14,7 +15,7 @@ public class FusionEUToStartProperty extends RecipeProperty { public static final String KEY = "eu_to_start"; - private static final TreeMap registeredFusionTiers = new TreeMap<>(); + private static final TreeMap> registeredFusionTiers = new TreeMap<>(); private static FusionEUToStartProperty INSTANCE; @@ -33,23 +34,29 @@ public static FusionEUToStartProperty getInstance() { @Override public void drawInfo(Minecraft minecraft, int x, int y, int color, Object value) { minecraft.fontRenderer.drawString(I18n.format("gregtech.recipe.eu_to_start", - TextFormattingUtil.formatLongToCompactString(castValue(value))) + getFusionTier(castValue(value)), x, y, + TextFormattingUtil.formatLongToCompactString(castValue(value))) + getFusionTierName(castValue(value)), + x, y, color); } - private static String getFusionTier(Long eu) { - Map.Entry mapEntry = registeredFusionTiers.ceilingEntry(eu); + private static String getFusionTierName(Long eu) { + Map.Entry> mapEntry = registeredFusionTiers.ceilingEntry(eu); if (mapEntry == null) { throw new IllegalArgumentException("Value is above registered maximum EU values"); } - return String.format(" %s", mapEntry.getValue()); + return String.format(" %s", mapEntry.getValue().getRight()); + } + + public static int getFusionTier(Long eu) { + Map.Entry> mapEntry = registeredFusionTiers.ceilingEntry(eu); + return mapEntry == null ? 0 : mapEntry.getValue().getLeft(); } public static void registerFusionTier(int tier, String shortName) { Validate.notNull(shortName); long maxEU = 16 * 10000000L * (long) Math.pow(2, tier - 6); - registeredFusionTiers.put(maxEU, shortName); + registeredFusionTiers.put(maxEU, Pair.of(tier, shortName)); } } diff --git a/src/main/java/gregtech/api/unification/material/materials/ElementMaterials.java b/src/main/java/gregtech/api/unification/material/materials/ElementMaterials.java index 37c745dc5c5..8d4af1f4fa7 100644 --- a/src/main/java/gregtech/api/unification/material/materials/ElementMaterials.java +++ b/src/main/java/gregtech/api/unification/material/materials/ElementMaterials.java @@ -42,6 +42,7 @@ public static void register() { Americium = new Material.Builder(3, gregtechId("americium")) .ingot(3) .liquid(new FluidBuilder().temperature(1449)) + .plasma() .color(0x287869).iconSet(METALLIC) .flags(EXT_METAL, GENERATE_FOIL, GENERATE_FINE_WIRE, GENERATE_DOUBLE_PLATE) .element(Elements.Am) @@ -814,6 +815,7 @@ public static void register() { Tin = new Material.Builder(112, gregtechId("tin")) .ingot(1) .liquid(new FluidBuilder().temperature(505)) + .plasma() .ore() .color(0xDCDCDC) .flags(EXT2_METAL, MORTAR_GRINDABLE, GENERATE_ROTOR, GENERATE_SPRING, GENERATE_SPRING_SMALL, diff --git a/src/main/java/gregtech/api/unification/ore/OrePrefix.java b/src/main/java/gregtech/api/unification/ore/OrePrefix.java index 64eb11cd7fa..30239988324 100644 --- a/src/main/java/gregtech/api/unification/ore/OrePrefix.java +++ b/src/main/java/gregtech/api/unification/ore/OrePrefix.java @@ -467,6 +467,7 @@ public static void init() { block.modifyMaterialAmount(Materials.Glowstone, 4); block.modifyMaterialAmount(Materials.NetherQuartz, 4); + block.modifyMaterialAmount(Materials.CertusQuartz, 4); block.modifyMaterialAmount(Materials.Brick, 4); block.modifyMaterialAmount(Materials.Clay, 4); block.modifyMaterialAmount(Materials.Glass, 1); diff --git a/src/main/java/gregtech/api/util/AssemblyLineManager.java b/src/main/java/gregtech/api/util/AssemblyLineManager.java index f4f577996b2..a2652acfa84 100644 --- a/src/main/java/gregtech/api/util/AssemblyLineManager.java +++ b/src/main/java/gregtech/api/util/AssemblyLineManager.java @@ -121,33 +121,56 @@ public static void createDefaultResearchRecipe(@NotNull AssemblyLineRecipeBuilde for (AssemblyLineRecipeBuilder.ResearchRecipeEntry entry : builder.getRecipeEntries()) { createDefaultResearchRecipe(entry.getResearchId(), entry.getResearchStack(), entry.getDataStack(), + entry.getIgnoreNBT(), entry.getDuration(), entry.getEUt(), entry.getCWUt()); } } + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.9") public static void createDefaultResearchRecipe(@NotNull String researchId, @NotNull ItemStack researchItem, @NotNull ItemStack dataItem, int duration, int EUt, int CWUt) { + createDefaultResearchRecipe(researchId, researchItem, dataItem, true, duration, EUt, CWUt); + } + + public static void createDefaultResearchRecipe(@NotNull String researchId, @NotNull ItemStack researchItem, + @NotNull ItemStack dataItem, boolean ignoreNBT, int duration, + int EUt, int CWUt) { if (!ConfigHolder.machines.enableResearch) return; NBTTagCompound compound = GTUtility.getOrCreateNbtCompound(dataItem); writeResearchToNBT(compound, researchId); if (CWUt > 0) { - RecipeMaps.RESEARCH_STATION_RECIPES.recipeBuilder() + RecipeBuilder researchBuilder = RecipeMaps.RESEARCH_STATION_RECIPES.recipeBuilder() .inputNBT(dataItem.getItem(), 1, dataItem.getMetadata(), NBTMatcher.ANY, NBTCondition.ANY) - .inputs(researchItem) .outputs(dataItem) .EUt(EUt) .CWUt(CWUt) - .totalCWU(duration) - .buildAndRegister(); + .totalCWU(duration); + + if (ignoreNBT) { + researchBuilder.inputNBT(researchItem.getItem(), 1, researchItem.getMetadata(), NBTMatcher.ANY, + NBTCondition.ANY); + } else { + researchBuilder.inputs(researchItem); + } + + researchBuilder.buildAndRegister(); } else { RecipeBuilder builder = RecipeMaps.SCANNER_RECIPES.recipeBuilder() .inputNBT(dataItem.getItem(), 1, dataItem.getMetadata(), NBTMatcher.ANY, NBTCondition.ANY) - .inputs(researchItem) .outputs(dataItem) .duration(duration) .EUt(EUt); + + if (ignoreNBT) { + builder.inputNBT(researchItem.getItem(), 1, researchItem.getMetadata(), NBTMatcher.ANY, + NBTCondition.ANY); + } else { + builder.inputs(researchItem); + } + builder.applyProperty(ScanProperty.getInstance(), true); builder.buildAndRegister(); } diff --git a/src/main/java/gregtech/client/particle/VanillaParticleEffects.java b/src/main/java/gregtech/client/particle/VanillaParticleEffects.java index 2765d3945d9..ddfa0592369 100644 --- a/src/main/java/gregtech/client/particle/VanillaParticleEffects.java +++ b/src/main/java/gregtech/client/particle/VanillaParticleEffects.java @@ -26,35 +26,6 @@ public enum VanillaParticleEffects implements IMachineParticleEffect { mte.getWorld().spawnParticle(EnumParticleTypes.SMOKE_NORMAL, x, y, z, 0, 0, 0); }), - MUFFLER_SMOKE(mte -> { - if (mte.getWorld() == null || mte.getPos() == null) return; - - BlockPos pos = mte.getPos(); - EnumFacing facing = mte.getFrontFacing(); - float xPos = facing.getXOffset() * 0.76F + pos.getX() + 0.25F; - float yPos = facing.getYOffset() * 0.76F + pos.getY() + 0.25F; - float zPos = facing.getZOffset() * 0.76F + pos.getZ() + 0.25F; - - float ySpd = facing.getYOffset() * 0.1F + 0.2F + 0.1F * GTValues.RNG.nextFloat(); - float xSpd; - float zSpd; - - if (facing.getYOffset() == -1) { - float temp = GTValues.RNG.nextFloat() * 2 * (float) Math.PI; - xSpd = (float) Math.sin(temp) * 0.1F; - zSpd = (float) Math.cos(temp) * 0.1F; - } else { - xSpd = facing.getXOffset() * (0.1F + 0.2F * GTValues.RNG.nextFloat()); - zSpd = facing.getZOffset() * (0.1F + 0.2F * GTValues.RNG.nextFloat()); - } - - xPos += GTValues.RNG.nextFloat() * 0.5F; - yPos += GTValues.RNG.nextFloat() * 0.5F; - zPos += GTValues.RNG.nextFloat() * 0.5F; - - mte.getWorld().spawnParticle(EnumParticleTypes.SMOKE_LARGE, xPos, yPos, zPos, xSpd, ySpd, zSpd); - }), - PBF_SMOKE(mte -> { if (mte.getWorld() == null || mte.getPos() == null) return; @@ -167,12 +138,12 @@ public void runEffect(@NotNull MetaTileEntity metaTileEntity) { } @SideOnly(Side.CLIENT) - public static void defaultFrontEffect(MetaTileEntity mte, EnumParticleTypes... particles) { + public static void defaultFrontEffect(@NotNull MetaTileEntity mte, EnumParticleTypes... particles) { defaultFrontEffect(mte, 0.0F, particles); } @SideOnly(Side.CLIENT) - public static void defaultFrontEffect(MetaTileEntity mte, float yOffset, EnumParticleTypes... particles) { + public static void defaultFrontEffect(@NotNull MetaTileEntity mte, float yOffset, EnumParticleTypes... particles) { if (particles == null || particles.length == 0) return; if (mte.getWorld() == null || mte.getPos() == null) return; @@ -201,4 +172,34 @@ public static void defaultFrontEffect(MetaTileEntity mte, float yOffset, EnumPar mte.getWorld().spawnParticle(particle, x, y, z, 0, 0, 0); } } + + @SideOnly(Side.CLIENT) + public static void mufflerEffect(@NotNull MetaTileEntity mte, @NotNull EnumParticleTypes particle) { + if (mte.getWorld() == null || mte.getPos() == null) return; + + BlockPos pos = mte.getPos(); + EnumFacing facing = mte.getFrontFacing(); + float xPos = facing.getXOffset() * 0.76F + pos.getX() + 0.25F; + float yPos = facing.getYOffset() * 0.76F + pos.getY() + 0.25F; + float zPos = facing.getZOffset() * 0.76F + pos.getZ() + 0.25F; + + float ySpd = facing.getYOffset() * 0.1F + 0.2F + 0.1F * GTValues.RNG.nextFloat(); + float xSpd; + float zSpd; + + if (facing.getYOffset() == -1) { + float temp = GTValues.RNG.nextFloat() * 2 * (float) Math.PI; + xSpd = (float) Math.sin(temp) * 0.1F; + zSpd = (float) Math.cos(temp) * 0.1F; + } else { + xSpd = facing.getXOffset() * (0.1F + 0.2F * GTValues.RNG.nextFloat()); + zSpd = facing.getZOffset() * (0.1F + 0.2F * GTValues.RNG.nextFloat()); + } + + xPos += GTValues.RNG.nextFloat() * 0.5F; + yPos += GTValues.RNG.nextFloat() * 0.5F; + zPos += GTValues.RNG.nextFloat() * 0.5F; + + mte.getWorld().spawnParticle(particle, xPos, yPos, zPos, xSpd, ySpd, zSpd); + } } diff --git a/src/main/java/gregtech/client/renderer/pipe/PipeRenderer.java b/src/main/java/gregtech/client/renderer/pipe/PipeRenderer.java index 841d230d0f5..632bdad8f2b 100644 --- a/src/main/java/gregtech/client/renderer/pipe/PipeRenderer.java +++ b/src/main/java/gregtech/client/renderer/pipe/PipeRenderer.java @@ -100,7 +100,7 @@ public static void initializeRestrictor(TextureMap map) { static { FACE_BORDER_MAP.put(EnumFacing.DOWN, - borderMap(EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST)); + borderMap(EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.EAST)); FACE_BORDER_MAP.put(EnumFacing.UP, borderMap(EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.EAST)); FACE_BORDER_MAP.put(EnumFacing.NORTH, diff --git a/src/main/java/gregtech/common/CommonProxy.java b/src/main/java/gregtech/common/CommonProxy.java index 7cac0f93204..f8a956e201b 100644 --- a/src/main/java/gregtech/common/CommonProxy.java +++ b/src/main/java/gregtech/common/CommonProxy.java @@ -297,9 +297,9 @@ public static void initComponents(RegistryEvent.Register event) { @SubscribeEvent public static void registerRecipes(RegistryEvent.Register event) { // Registers Fusion tiers for the FusionEUToStartProperty - FusionEUToStartProperty.registerFusionTier(6, "(MK1)"); - FusionEUToStartProperty.registerFusionTier(7, "(MK2)"); - FusionEUToStartProperty.registerFusionTier(8, "(MK3)"); + FusionEUToStartProperty.registerFusionTier(GTValues.LuV, "(MK1)"); + FusionEUToStartProperty.registerFusionTier(GTValues.ZPM, "(MK2)"); + FusionEUToStartProperty.registerFusionTier(GTValues.UV, "(MK3)"); // Register data stick copying custom scanner logic AssemblyLineManager.registerScannerLogic(); diff --git a/src/main/java/gregtech/common/metatileentities/MetaTileEntities.java b/src/main/java/gregtech/common/metatileentities/MetaTileEntities.java index d35d77f79d8..c346ac65e23 100644 --- a/src/main/java/gregtech/common/metatileentities/MetaTileEntities.java +++ b/src/main/java/gregtech/common/metatileentities/MetaTileEntities.java @@ -267,7 +267,7 @@ public class MetaTileEntities { // UHV public static final MetaTileEntityRotorHolder[] ROTOR_HOLDER = new MetaTileEntityRotorHolder[6]; // HV, EV, IV, LuV, // ZPM, UV - public static final MetaTileEntityMufflerHatch[] MUFFLER_HATCH = new MetaTileEntityMufflerHatch[GTValues.UV]; // LV-UV + public static final MetaTileEntityMufflerHatch[] MUFFLER_HATCH = new MetaTileEntityMufflerHatch[GTValues.UV + 1]; // LV-UV public static final MetaTileEntityFusionReactor[] FUSION_REACTOR = new MetaTileEntityFusionReactor[3]; public static final MetaTileEntityQuantumChest[] QUANTUM_CHEST = new MetaTileEntityQuantumChest[10]; public static final MetaTileEntityQuantumTank[] QUANTUM_TANK = new MetaTileEntityQuantumTank[10]; @@ -1137,12 +1137,13 @@ public static void init() { CLEANING_MAINTENANCE_HATCH = registerMetaTileEntity(1401, new MetaTileEntityCleaningMaintenanceHatch(gregtechId("maintenance_hatch_cleanroom_auto"))); - // Muffler Hatches, IDs 1657- - for (int i = 0; i < MUFFLER_HATCH.length; i++) { - String voltageName = GTValues.VN[i + 1].toLowerCase(); - MUFFLER_HATCH[i] = new MetaTileEntityMufflerHatch(gregtechId("muffler_hatch." + voltageName), i + 1); + // Muffler Hatches, IDs 1657-1664 + for (int i = 0; i < MUFFLER_HATCH.length - 1; i++) { + int tier = i + 1; + String voltageName = GTValues.VN[tier].toLowerCase(); + MUFFLER_HATCH[tier] = new MetaTileEntityMufflerHatch(gregtechId("muffler_hatch." + voltageName), tier); - registerMetaTileEntity(1657 + i, MUFFLER_HATCH[i]); + registerMetaTileEntity(1657 + i, MUFFLER_HATCH[tier]); } CLIPBOARD_TILE = registerMetaTileEntity(1666, new MetaTileEntityClipboard(gregtechId("clipboard"))); diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityFusionReactor.java b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityFusionReactor.java index 8e667bedfcb..90b8b70886c 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityFusionReactor.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityFusionReactor.java @@ -30,6 +30,7 @@ import gregtech.api.recipes.Recipe; import gregtech.api.recipes.RecipeMaps; import gregtech.api.recipes.recipeproperties.FusionEUToStartProperty; +import gregtech.api.recipes.recipeproperties.IRecipePropertyStorage; import gregtech.api.util.RelativeDirection; import gregtech.api.util.TextComponentUtil; import gregtech.api.util.TextFormattingUtil; @@ -630,6 +631,19 @@ public boolean checkRecipe(@NotNull Recipe recipe) { return true; } + @Override + protected void modifyOverclockPre(int @NotNull [] values, @NotNull IRecipePropertyStorage storage) { + super.modifyOverclockPre(values, storage); + + // Limit the number of OCs to the difference in fusion reactor MK. + // I.e., a MK2 reactor can overclock a MK1 recipe once, and a + // MK3 reactor can overclock a MK2 recipe once, or a MK1 recipe twice. + long euToStart = storage.getRecipePropertyValue(FusionEUToStartProperty.getInstance(), 0L); + int fusionTier = FusionEUToStartProperty.getFusionTier(euToStart); + if (fusionTier != 0) fusionTier -= MetaTileEntityFusionReactor.this.tier; + values[2] = Math.min(fusionTier, values[2]); + } + @NotNull @Override public NBTTagCompound serializeNBT() { diff --git a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMufflerHatch.java b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMufflerHatch.java index 4b3e75a4c2c..5bc07d2e793 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMufflerHatch.java +++ b/src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityMufflerHatch.java @@ -11,6 +11,7 @@ import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.metatileentity.multiblock.IMultiblockAbilityPart; import gregtech.api.metatileentity.multiblock.MultiblockAbility; +import gregtech.api.metatileentity.multiblock.MultiblockControllerBase; import gregtech.api.metatileentity.multiblock.MultiblockWithDisplayBase; import gregtech.api.util.GTTransferUtils; import gregtech.api.util.GTUtility; @@ -69,7 +70,7 @@ public void update() { if (getWorld().isRemote && getController() instanceof MultiblockWithDisplayBase controller && controller.isActive()) { - VanillaParticleEffects.MUFFLER_SMOKE.runEffect(this); + VanillaParticleEffects.mufflerEffect(this, controller.getMufflerParticle()); } } @@ -112,12 +113,15 @@ private boolean checkFrontFaceFree() { return blockState.getBlock().isAir(blockState, getWorld(), frontPos) || GTUtility.isBlockSnow(blockState); } - /** @deprecated Use {@link VanillaParticleEffects#MUFFLER_SMOKE} instead. */ + /** @deprecated No longer needed. Multiblock controller sets the particle type. */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "2.9") @SideOnly(Side.CLIENT) public void pollutionParticles() { - VanillaParticleEffects.MUFFLER_SMOKE.runEffect(this); + MultiblockControllerBase controller = getController(); + if (controller instanceof MultiblockWithDisplayBase displayBase) { + VanillaParticleEffects.mufflerEffect(this, displayBase.getMufflerParticle()); + } } @Override diff --git a/src/main/java/gregtech/core/network/internal/NetworkHandler.java b/src/main/java/gregtech/core/network/internal/NetworkHandler.java index 60849c35415..3d6769891f9 100644 --- a/src/main/java/gregtech/core/network/internal/NetworkHandler.java +++ b/src/main/java/gregtech/core/network/internal/NetworkHandler.java @@ -7,6 +7,7 @@ import gregtech.api.network.INetworkHandler; import gregtech.api.network.IPacket; import gregtech.api.network.IServerExecutor; +import gregtech.api.util.GTLog; import gregtech.core.CoreModule; import net.minecraft.client.network.NetHandlerPlayClient; @@ -26,8 +27,11 @@ import net.minecraftforge.fml.relauncher.SideOnly; import io.netty.buffer.Unpooled; +import org.jetbrains.annotations.NotNull; -public class NetworkHandler implements INetworkHandler { +import java.lang.reflect.InvocationTargetException; + +public final class NetworkHandler implements INetworkHandler { private static final NetworkHandler INSTANCE = new NetworkHandler(); @@ -106,7 +110,7 @@ public void sendToServer(IPacket packet) { @SubscribeEvent @SideOnly(Side.CLIENT) - public void onClientPacket(FMLNetworkEvent.ClientCustomPacketEvent event) throws Exception { + public void onClientPacket(FMLNetworkEvent.@NotNull ClientCustomPacketEvent event) throws Exception { IPacket packet = toGTPacket(event.getPacket()); if (IClientExecutor.class.isAssignableFrom(packet.getClass())) { IClientExecutor executor = (IClientExecutor) packet; @@ -121,7 +125,7 @@ public void onClientPacket(FMLNetworkEvent.ClientCustomPacketEvent event) throws } @SubscribeEvent - public void onServerPacket(FMLNetworkEvent.ServerCustomPacketEvent event) throws Exception { + public void onServerPacket(FMLNetworkEvent.@NotNull ServerCustomPacketEvent event) throws Exception { IPacket packet = toGTPacket(event.getPacket()); if (IServerExecutor.class.isAssignableFrom(packet.getClass())) { IServerExecutor executor = (IServerExecutor) packet; @@ -135,17 +139,27 @@ public void onServerPacket(FMLNetworkEvent.ServerCustomPacketEvent event) throws } } - private FMLProxyPacket toFMLPacket(IPacket packet) { + private @NotNull FMLProxyPacket toFMLPacket(@NotNull IPacket packet) { PacketBuffer buf = new PacketBuffer(Unpooled.buffer()); buf.writeVarInt(packetHandler.getPacketId(packet.getClass())); packet.encode(buf); return new FMLProxyPacket(buf, GTValues.MODID); } - private IPacket toGTPacket(FMLProxyPacket proxyPacket) throws Exception { + private @NotNull IPacket toGTPacket(@NotNull FMLProxyPacket proxyPacket) throws NoSuchMethodException, + InvocationTargetException, + InstantiationException, + IllegalAccessException { PacketBuffer payload = (PacketBuffer) proxyPacket.payload(); - IPacket packet = packetHandler.getPacketClass(payload.readVarInt()).newInstance(); + var clazz = packetHandler.getPacketClass(payload.readVarInt()); + IPacket packet = clazz.getConstructor().newInstance(); packet.decode(payload); + + if (payload.readableBytes() != 0) { + GTLog.logger.error( + "NetworkHandler failed to finish reading packet with class {} and {} bytes remaining", + clazz.getName(), payload.readableBytes()); + } return packet; } } diff --git a/src/main/java/gregtech/integration/chisel/ChiselModule.java b/src/main/java/gregtech/integration/chisel/ChiselModule.java new file mode 100644 index 00000000000..c6dc3cafe05 --- /dev/null +++ b/src/main/java/gregtech/integration/chisel/ChiselModule.java @@ -0,0 +1,119 @@ +package gregtech.integration.chisel; + +import gregtech.api.GTValues; +import gregtech.api.block.VariantBlock; +import gregtech.api.modules.GregTechModule; +import gregtech.api.unification.material.Material; +import gregtech.api.unification.material.Materials; +import gregtech.common.blocks.BlockColored; +import gregtech.common.blocks.BlockCompressed; +import gregtech.common.blocks.BlockWarningSign; +import gregtech.common.blocks.BlockWarningSign1; +import gregtech.common.blocks.MetaBlocks; +import gregtech.common.blocks.StoneVariantBlock; +import gregtech.common.blocks.StoneVariantBlock.StoneType; +import gregtech.common.blocks.StoneVariantBlock.StoneVariant; +import gregtech.common.blocks.wood.BlockGregPlanks; +import gregtech.integration.IntegrationSubmodule; +import gregtech.modules.GregTechModules; + +import net.minecraft.block.Block; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IStringSerializable; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLInterModComms; + +import team.chisel.common.carving.Carving; + +import java.util.Objects; + +@GregTechModule( + moduleID = GregTechModules.MODULE_CHISEL, + containerID = GTValues.MODID, + modDependencies = GTValues.MODID_CHISEL, + name = "GregTech Chisel Integration", + description = "Chisel Integration Module") +public class ChiselModule extends IntegrationSubmodule { + + @Override + public void init(FMLInitializationEvent event) { + // GT custom groups + addVariations("gt_warning_sign", MetaBlocks.WARNING_SIGN, BlockWarningSign.SignType.values()); + addVariations("gt_warning_sign", MetaBlocks.WARNING_SIGN_1, BlockWarningSign1.SignType.values()); + addVariations("gt_studs", MetaBlocks.STUDS); + addVariations("gt_metal_sheet", MetaBlocks.METAL_SHEET); + addVariations("gt_large_metal_sheet", MetaBlocks.LARGE_METAL_SHEET); + for (EnumDyeColor color : EnumDyeColor.values()) { + Block lamp = MetaBlocks.LAMPS.get(color); + Block lampBorderless = MetaBlocks.BORDERLESS_LAMPS.get(color); + String group = "gt_lamp_" + color.getName().toLowerCase(); + for (int i = 0; i < 8; i++) { + addVariation(group, lamp, i); + addVariation(group, lampBorderless, i); + } + } + + // Chisel shared groups + addVariations("marble", StoneType.MARBLE, false); + addVariations("basalt", StoneType.BASALT, false); + addVariations("black_granite", StoneType.BLACK_GRANITE, false); + addVariations("red_granite", StoneType.RED_GRANITE, false); + addVariations("light_concrete", StoneType.CONCRETE_LIGHT, true); + addVariations("dark_concrete", StoneType.CONCRETE_DARK, true); + + // Mod-dependent groups + if (doesGroupExist("treated_wood")) { // IE Treated Wood group + addVariations("treated_wood", MetaBlocks.PLANKS, BlockGregPlanks.BlockType.TREATED_PLANK); + } + if (doesGroupExist("certus")) { // AE2 Certus Quartz group + addVariation("certus", Materials.CertusQuartz); + } + } + + @SafeVarargs + private & IStringSerializable, T extends VariantBlock> void addVariations(String group, + T block, + U... variants) { + if (variants != null) { + for (U variant : variants) { + addVariation(group, block, block.getMetaFromState(block.getState(variant))); + } + } + } + + private void addVariations(String group, BlockColored block) { + for (EnumDyeColor color : EnumDyeColor.values()) { + addVariation(group, block, color.getMetadata()); + } + } + + private void addVariations(String group, StoneType type, boolean enableCobbles) { + for (StoneVariantBlock.StoneVariant variant : StoneVariant.values()) { + if (!enableCobbles && (variant == StoneVariant.COBBLE || variant == StoneVariant.COBBLE_MOSSY)) { + continue; + } + StoneVariantBlock block = MetaBlocks.STONE_BLOCKS.get(variant); + int meta = block.getMetaFromState(block.getState(type)); + addVariation(group, block, meta); + } + } + + private void addVariation(String group, Material material) { + BlockCompressed block = MetaBlocks.COMPRESSED.get(material); + int meta = block.getMetaFromState(block.getBlock(material)); + addVariation(group, block, meta); + } + + private void addVariation(String group, Block block, int meta) { + NBTTagCompound tag = new NBTTagCompound(); + tag.setString("group", group); + tag.setString("block", Objects.requireNonNull(block.getRegistryName()).toString()); + tag.setInteger("meta", meta); + FMLInterModComms.sendMessage(GTValues.MODID_CHISEL, "add_variation", tag); + } + + private boolean doesGroupExist(String group) { + return Carving.chisel.getGroup(group) != null; + } +} diff --git a/src/main/java/gregtech/integration/crafttweaker/material/CTMaterialHelpers.java b/src/main/java/gregtech/integration/crafttweaker/material/CTMaterialHelpers.java index 751be8aa3ef..ca5d08a1efa 100644 --- a/src/main/java/gregtech/integration/crafttweaker/material/CTMaterialHelpers.java +++ b/src/main/java/gregtech/integration/crafttweaker/material/CTMaterialHelpers.java @@ -22,7 +22,7 @@ protected static FluidState validateFluidState(String fluidTypeName) { if (fluidTypeName.equals("gas")) return FluidState.GAS; if (fluidTypeName.equals("plasma")) return FluidState.PLASMA; - String message = "Fluid Type must be either \"liquid\", \"gas\", or \"acid\"!"; + String message = "Fluid Type must be either \"liquid\", \"gas\", or \"plasma\"!"; CraftTweakerAPI.logError(message); throw new IllegalArgumentException(message); } diff --git a/src/main/java/gregtech/integration/crafttweaker/material/MaterialPropertyExpansion.java b/src/main/java/gregtech/integration/crafttweaker/material/MaterialPropertyExpansion.java index 0f2c7a3d882..bf4624282cb 100644 --- a/src/main/java/gregtech/integration/crafttweaker/material/MaterialPropertyExpansion.java +++ b/src/main/java/gregtech/integration/crafttweaker/material/MaterialPropertyExpansion.java @@ -156,20 +156,27 @@ public static void addFluid(Material m) { public static void addFluid(Material m, @Optional String fluidTypeName, @Optional boolean hasBlock) { if (checkFrozen("add a Fluid to a material")) return; FluidState type = validateFluidState(fluidTypeName); - if (m.hasProperty(PropertyKey.FLUID)) { - FluidStorage storage = m.getProperty(PropertyKey.FLUID).getStorage(); - FluidBuilder builder = new FluidBuilder(); - if (hasBlock) builder.block(); + FluidProperty property = m.getProperty(PropertyKey.FLUID); + if (property == null) { + property = new FluidProperty(); + m.setProperty(PropertyKey.FLUID, property); + } + + FluidStorage storage = property.getStorage(); + FluidBuilder builder = switch (type) { + case LIQUID -> storage.getQueuedBuilder(FluidStorageKeys.LIQUID); + case GAS -> storage.getQueuedBuilder(FluidStorageKeys.GAS); + case PLASMA -> storage.getQueuedBuilder(FluidStorageKeys.PLASMA); + }; + if (builder == null) { + builder = new FluidBuilder(); switch (type) { case LIQUID -> storage.enqueueRegistration(FluidStorageKeys.LIQUID, builder); case GAS -> storage.enqueueRegistration(FluidStorageKeys.GAS, builder.state(FluidState.GAS)); case PLASMA -> storage.enqueueRegistration(FluidStorageKeys.PLASMA, builder.state(FluidState.PLASMA)); } - } else { - FluidProperty property = new FluidProperty(); - property.getStorage().enqueueRegistration(FluidStorageKeys.LIQUID, new FluidBuilder()); - m.setProperty(PropertyKey.FLUID, property); } + if (hasBlock) builder.block(); } @ZenMethod diff --git a/src/main/java/gregtech/integration/forestry/bees/GTBeeDefinition.java b/src/main/java/gregtech/integration/forestry/bees/GTBeeDefinition.java index 827eb307c28..97fed7a25c3 100644 --- a/src/main/java/gregtech/integration/forestry/bees/GTBeeDefinition.java +++ b/src/main/java/gregtech/integration/forestry/bees/GTBeeDefinition.java @@ -587,7 +587,8 @@ public enum GTBeeDefinition implements IBeeDefinition { AlleleHelper.getInstance().set(template, TOLERATES_RAIN, true); }, dis -> { - if (Loader.isModLoaded(GTValues.MODID_MB)) { + if (Loader.isModLoaded(GTValues.MODID_MB) && Loader.isModLoaded(GTValues.MODID_APPENG)) { + // MB Skystone bee is only registered if AE2 is also active dis.registerMutation(IRON, ForestryUtil.getSpecies(GTValues.MODID_MB, "AESkystone"), 17); } else { dis.registerMutation(IRON, BeeDefinition.IMPERIAL, 17); diff --git a/src/main/java/gregtech/loaders/OreDictionaryLoader.java b/src/main/java/gregtech/loaders/OreDictionaryLoader.java index b05fba4609b..a902983af39 100644 --- a/src/main/java/gregtech/loaders/OreDictionaryLoader.java +++ b/src/main/java/gregtech/loaders/OreDictionaryLoader.java @@ -25,12 +25,14 @@ public class OreDictionaryLoader { public static final String OREDICT_FUEL_COKE = "fuelCoke"; public static final String OREDICT_BLOCK_FUEL_COKE = "blockFuelCoke"; + public static final String OREDICT_BLOCK_COAL_COKE = "blockCoalCoke"; public static void init() { GTLog.logger.info("Registering OreDict entries."); OreDictionary.registerOre(OREDICT_FUEL_COKE, OreDictUnifier.get(OrePrefix.gem, Materials.Coke)); OreDictionary.registerOre(OREDICT_BLOCK_FUEL_COKE, OreDictUnifier.get(OrePrefix.block, Materials.Coke)); + OreDictionary.registerOre(OREDICT_BLOCK_COAL_COKE, OreDictUnifier.get(OrePrefix.block, Materials.Coke)); OreDictionary.registerOre("crystalCertusQuartz", OreDictUnifier.get(OrePrefix.gem, Materials.CertusQuartz)); OreDictUnifier.registerOre(new ItemStack(Blocks.CLAY), OrePrefix.block, Materials.Clay); diff --git a/src/main/java/gregtech/loaders/recipe/FuelRecipes.java b/src/main/java/gregtech/loaders/recipe/FuelRecipes.java index 94da5ecb799..740521e8657 100644 --- a/src/main/java/gregtech/loaders/recipe/FuelRecipes.java +++ b/src/main/java/gregtech/loaders/recipe/FuelRecipes.java @@ -291,6 +291,13 @@ public static void registerFuels() { RecipeMaps.PLASMA_GENERATOR_FUELS.recipeBuilder() .fluidInputs(Iron.getPlasma(1)) .fluidOutputs(Iron.getFluid(1)) + .duration(112) + .EUt((int) V[EV]) + .buildAndRegister(); + + RecipeMaps.PLASMA_GENERATOR_FUELS.recipeBuilder() + .fluidInputs(Tin.getPlasma(1)) + .fluidOutputs(Tin.getFluid(1)) .duration(128) .EUt((int) V[EV]) .buildAndRegister(); @@ -301,5 +308,12 @@ public static void registerFuels() { .duration(192) .EUt((int) V[EV]) .buildAndRegister(); + + RecipeMaps.PLASMA_GENERATOR_FUELS.recipeBuilder() + .fluidInputs(Americium.getPlasma(1)) + .fluidOutputs(Americium.getFluid(1)) + .duration(320) + .EUt((int) V[EV]) + .buildAndRegister(); } } diff --git a/src/main/java/gregtech/loaders/recipe/FusionLoader.java b/src/main/java/gregtech/loaders/recipe/FusionLoader.java index f5ec3a7b861..49515136876 100644 --- a/src/main/java/gregtech/loaders/recipe/FusionLoader.java +++ b/src/main/java/gregtech/loaders/recipe/FusionLoader.java @@ -38,16 +38,16 @@ public static void init() { RecipeMaps.FUSION_RECIPES.recipeBuilder() .fluidInputs(Materials.Silicon.getFluid(16)) .fluidInputs(Materials.Magnesium.getFluid(16)) - .fluidOutputs(Materials.Iron.getPlasma(16)) + .fluidOutputs(Materials.Iron.getPlasma(144)) .duration(32) .EUt(VA[IV]) - .EUToStart(360_000_000) + .EUToStart(300_000_000) .buildAndRegister(); RecipeMaps.FUSION_RECIPES.recipeBuilder() .fluidInputs(Materials.Potassium.getFluid(16)) .fluidInputs(Materials.Fluorine.getFluid(125)) - .fluidOutputs(Materials.Nickel.getPlasma(16)) + .fluidOutputs(Materials.Nickel.getPlasma(144)) .duration(16) .EUt(VA[LuV]) .EUToStart(480_000_000) @@ -62,6 +62,24 @@ public static void init() { .EUToStart(180_000_000) .buildAndRegister(); + RecipeMaps.FUSION_RECIPES.recipeBuilder() + .fluidInputs(Materials.Plutonium241.getFluid(144)) + .fluidInputs(Materials.Hydrogen.getFluid(2000)) + .fluidOutputs(Materials.Americium.getPlasma(144)) + .duration(64) + .EUt(98304) + .EUToStart(500_000_000) + .buildAndRegister(); + + RecipeMaps.FUSION_RECIPES.recipeBuilder() + .fluidInputs(Materials.Silver.getFluid(144)) + .fluidInputs(Materials.Helium3.getFluid(375)) + .fluidOutputs(Materials.Tin.getPlasma(144)) + .duration(16) + .EUt(49152) + .EUToStart(280_000_000) + .buildAndRegister(); + RecipeMaps.FUSION_RECIPES.recipeBuilder() .fluidInputs(Materials.Neodymium.getFluid(16)) .fluidInputs(Materials.Hydrogen.getFluid(375)) @@ -72,9 +90,9 @@ public static void init() { .buildAndRegister(); RecipeMaps.FUSION_RECIPES.recipeBuilder() - .fluidInputs(Materials.Lutetium.getFluid(32)) - .fluidInputs(Materials.Chrome.getFluid(32)) - .fluidOutputs(Materials.Americium.getFluid(32)) + .fluidInputs(Materials.Lutetium.getFluid(16)) + .fluidInputs(Materials.Chrome.getFluid(16)) + .fluidOutputs(Materials.Americium.getFluid(16)) .duration(64) .EUt(49152) .EUToStart(200_000_000) @@ -147,16 +165,16 @@ public static void init() { .fluidInputs(Materials.Gallium.getFluid(16)) .fluidInputs(Materials.Radon.getFluid(125)) .fluidOutputs(Materials.Duranium.getFluid(16)) - .duration(64) + .duration(32) .EUt(16384) .EUToStart(140_000_000) .buildAndRegister(); RecipeMaps.FUSION_RECIPES.recipeBuilder() - .fluidInputs(Materials.Titanium.getFluid(32)) + .fluidInputs(Materials.Titanium.getFluid(48)) .fluidInputs(Materials.Duranium.getFluid(32)) .fluidOutputs(Materials.Tritanium.getFluid(16)) - .duration(64) + .duration(16) .EUt(VA[LuV]) .EUToStart(200_000_000) .buildAndRegister(); diff --git a/src/main/java/gregtech/loaders/recipe/RecyclingRecipes.java b/src/main/java/gregtech/loaders/recipe/RecyclingRecipes.java index e4cbbab3310..ba4223d289f 100644 --- a/src/main/java/gregtech/loaders/recipe/RecyclingRecipes.java +++ b/src/main/java/gregtech/loaders/recipe/RecyclingRecipes.java @@ -140,7 +140,10 @@ private static void registerExtractorRecycling(ItemStack input, List ms.material.hasProperty(PropertyKey.FLUID)).findFirst() - .orElse(null); + MaterialStack fluidMs = materials.stream() + .filter(ms -> ms.material.hasProperty(PropertyKey.FLUID) && ms.material.getFluid() != null) + .findFirst().orElse(null); if (fluidMs == null) return; // Find the next MaterialStack, which will be the Item output. diff --git a/src/main/java/gregtech/modules/GregTechModules.java b/src/main/java/gregtech/modules/GregTechModules.java index de2c3d74f86..4a7aed4639a 100644 --- a/src/main/java/gregtech/modules/GregTechModules.java +++ b/src/main/java/gregtech/modules/GregTechModules.java @@ -18,6 +18,7 @@ public class GregTechModules implements IModuleContainer { public static final String MODULE_BAUBLES = "baubles_integration"; public static final String MODULE_FR = "fr_integration"; public static final String MODULE_EN = "en_integration"; + public static final String MODULE_CHISEL = "chisel_integration"; @Override public String getID() { diff --git a/src/main/resources/assets/gregtech/lang/en_us.lang b/src/main/resources/assets/gregtech/lang/en_us.lang index b10e9776881..6f8f8b831b3 100644 --- a/src/main/resources/assets/gregtech/lang/en_us.lang +++ b/src/main/resources/assets/gregtech/lang/en_us.lang @@ -5557,7 +5557,7 @@ gregtech.multiblock.pattern.error.batteries=§cMust have at least one non-empty gregtech.multiblock.pattern.error.filters=§cAll filters must be the same§r gregtech.multiblock.pattern.clear_amount_1=§6Must have a clear 1x1x1 space in front§r gregtech.multiblock.pattern.clear_amount_3=§6Must have a clear 3x3x1 space in front§r -gregtech.multiblock.pattern.single=§6Only this block can be used§r +gregtech.multiblock.pattern.single=§6Only this block type can be used§r gregtech.multiblock.pattern.location_end=§cVery End§r gregtech.multiblock.pattern.replaceable_air=Replaceable by Air