From 350bfb2062ce8f59591d350fdb09b94bbb32ce7e Mon Sep 17 00:00:00 2001 From: Alex Thomson Date: Sat, 8 Apr 2023 17:50:15 +1200 Subject: [PATCH] Fix Embers Melter Item Duplication Fixes https://github.com/LXGaming/Sledgehammer/issues/38 Fixes https://github.com/DaedalusGame/EmbersRekindled/issues/310 --- build.gradle | 2 + .../configuration/category/MixinCategory.java | 8 ++++ .../category/mixin/EmbersMixinCategory.java | 33 ++++++++++++++ .../tileentity/TileEntityFurnaceTopMixin.java | 43 +++++++++++++++++++ .../resources/mixins.sledgehammer.embers.json | 15 +++++++ 5 files changed, 101 insertions(+) create mode 100644 src/main/java/io/github/lxgaming/sledgehammer/configuration/category/mixin/EmbersMixinCategory.java create mode 100644 src/main/java/io/github/lxgaming/sledgehammer/mixin/embers/tileentity/TileEntityFurnaceTopMixin.java create mode 100644 src/main/resources/mixins.sledgehammer.embers.json diff --git a/build.gradle b/build.gradle index 4e00054..44eca3d 100644 --- a/build.gradle +++ b/build.gradle @@ -146,6 +146,7 @@ dependencies { compileOnly("curse.maven:codechicken-lib-1-8-242818:2779848") // CodeChicken Lib v1.12.2-3.2.3.358-universal compileOnly("curse.maven:cyclops-core-232758:3010617") // Cyclops Core v1.12.2-1.6.6 compileOnly("curse.maven:dank-null-272514:2831353") // /dank/null v1.12.2-1.7.89 + compileOnly("curse.maven:embers-rekindled-300777:3695248") // EmbersRekindled v1.19 compileOnly("curse.maven:ender-io-64578:2858816") // Ender IO v5.1.55 compileOnly("curse.maven:ender-storage-1-8-245174:2755787") // Ender Storage v1.12.2-2.4.6.137-universal compileOnly("curse.maven:flux-networks-248020:2645165") // Flux Networks v1.12.2-3.0.19 @@ -216,6 +217,7 @@ jar { + "mixins.sledgehammer.chesttransporter.json," + "mixins.sledgehammer.core.json," + "mixins.sledgehammer.danknull.json," + + "mixins.sledgehammer.embers.json," + "mixins.sledgehammer.enderio.json," + "mixins.sledgehammer.enderstorage.json," + "mixins.sledgehammer.fluxnetworks.json," diff --git a/src/main/java/io/github/lxgaming/sledgehammer/configuration/category/MixinCategory.java b/src/main/java/io/github/lxgaming/sledgehammer/configuration/category/MixinCategory.java index 504e2e8..cd01d67 100644 --- a/src/main/java/io/github/lxgaming/sledgehammer/configuration/category/MixinCategory.java +++ b/src/main/java/io/github/lxgaming/sledgehammer/configuration/category/MixinCategory.java @@ -31,6 +31,7 @@ import io.github.lxgaming.sledgehammer.configuration.category.mixin.ChestTransporterMixinCategory; import io.github.lxgaming.sledgehammer.configuration.category.mixin.CoreMixinCategory; import io.github.lxgaming.sledgehammer.configuration.category.mixin.DankNullMixinCategory; +import io.github.lxgaming.sledgehammer.configuration.category.mixin.EmbersMixinCategory; import io.github.lxgaming.sledgehammer.configuration.category.mixin.EnderIOMixinCategory; import io.github.lxgaming.sledgehammer.configuration.category.mixin.EnderStorageMixinCategory; import io.github.lxgaming.sledgehammer.configuration.category.mixin.FluxNetworksMixinCategory; @@ -115,6 +116,9 @@ public class MixinCategory { @Setting(value = "dank-null", comment = "DankNull") private DankNullMixinCategory dankNullMixinCategory = new DankNullMixinCategory(); + @Setting(value = "embers", comment = "Embers") + private EmbersMixinCategory embersMixinCategory = new EmbersMixinCategory(); + @Setting(value = "enderio", comment = "Ender IO") private EnderIOMixinCategory enderIOMixinCategory = new EnderIOMixinCategory(); @@ -274,6 +278,10 @@ public DankNullMixinCategory getDankNullMixinCategory() { return dankNullMixinCategory; } + public EmbersMixinCategory getEmbersMixinCategory() { + return embersMixinCategory; + } + public EnderIOMixinCategory getEnderIOMixinCategory() { return enderIOMixinCategory; } diff --git a/src/main/java/io/github/lxgaming/sledgehammer/configuration/category/mixin/EmbersMixinCategory.java b/src/main/java/io/github/lxgaming/sledgehammer/configuration/category/mixin/EmbersMixinCategory.java new file mode 100644 index 0000000..d611d10 --- /dev/null +++ b/src/main/java/io/github/lxgaming/sledgehammer/configuration/category/mixin/EmbersMixinCategory.java @@ -0,0 +1,33 @@ +/* + * Copyright 2023 Alex Thomson + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.github.lxgaming.sledgehammer.configuration.category.mixin; + +import io.github.lxgaming.sledgehammer.configuration.annotation.Mapping; +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class EmbersMixinCategory { + + @Mapping(value = "embers.tileentity.TileEntityFurnaceTopMixin", dependencies = "embers") + @Setting(value = "item-duplication", comment = "If 'true', fixes item duplication") + private boolean itemDuplication = false; + + public boolean isItemDuplication() { + return itemDuplication; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/lxgaming/sledgehammer/mixin/embers/tileentity/TileEntityFurnaceTopMixin.java b/src/main/java/io/github/lxgaming/sledgehammer/mixin/embers/tileentity/TileEntityFurnaceTopMixin.java new file mode 100644 index 0000000..07b2511 --- /dev/null +++ b/src/main/java/io/github/lxgaming/sledgehammer/mixin/embers/tileentity/TileEntityFurnaceTopMixin.java @@ -0,0 +1,43 @@ +/* + * Copyright 2023 Alex Thomson + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.github.lxgaming.sledgehammer.mixin.embers.tileentity; + +import net.minecraft.entity.Entity; +import net.minecraft.util.EntitySelectors; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import teamroots.embers.tileentity.TileEntityFurnaceTop; + +import java.util.List; + +@Mixin(value = TileEntityFurnaceTop.class, remap = false) +public abstract class TileEntityFurnaceTopMixin { + + @Redirect( + method = "func_73660_a", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/World;func_72872_a(Ljava/lang/Class;Lnet/minecraft/util/math/AxisAlignedBB;)Ljava/util/List;" + ) + ) + private List onGetEntitiesWithinAABB(World world, Class entityClass, AxisAlignedBB axisAlignedBB) { + return world.getEntitiesWithinAABB(entityClass, axisAlignedBB, entity -> EntitySelectors.NOT_SPECTATING.apply(entity) && entity.isEntityAlive()); + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.sledgehammer.embers.json b/src/main/resources/mixins.sledgehammer.embers.json new file mode 100644 index 0000000..f8d76e3 --- /dev/null +++ b/src/main/resources/mixins.sledgehammer.embers.json @@ -0,0 +1,15 @@ +{ + "required": false, + "minVersion": "0.7.10", + "package": "io.github.lxgaming.sledgehammer.mixin.embers", + "refmap": "mixins.sledgehammer.refmap.json", + "plugin": "io.github.lxgaming.sledgehammer.mixin.plugin.CorePlugin", + "target": "@env(DEFAULT)", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "tileentity.TileEntityFurnaceTopMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file