diff --git a/build.gradle b/build.gradle index 5459956..90290f2 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ targetCompatibility = 1.8 group = "io.github.lxgaming" archivesBaseName = "Sledgehammer" -version = "1.12.2-1.2.11" +version = "1.12.2-1.2.12" minecraft { version = "1.12.2-14.23.4.2705" diff --git a/src/main/java/io/github/lxgaming/sledgehammer/Sledgehammer.java b/src/main/java/io/github/lxgaming/sledgehammer/Sledgehammer.java index 07e90d1..345277d 100644 --- a/src/main/java/io/github/lxgaming/sledgehammer/Sledgehammer.java +++ b/src/main/java/io/github/lxgaming/sledgehammer/Sledgehammer.java @@ -81,7 +81,6 @@ private void registerMappings() { getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.forge.world.storage.MixinWorldInfo", MixinCategory::isCeremonyRain); // Mixin SpongeForge - getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.spongeforge.mod.item.inventory.fabric.MixinIItemHandlerFabric", MixinCategory::isItemHandlerFabric); // Mixin SpongeVanilla } 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 7ce1676..6915e6d 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 @@ -40,9 +40,6 @@ public class MixinCategory { @Setting(value = "harvest-block", comment = "Prevents ClassCastException caused by Sponge assuming things") private boolean harvestBlock = false; - @Setting(value = "item-handler-fabric", comment = "Prevent item duplication with certain modded inventories") - private boolean itemHandlerFabric = false; - @Setting(value = "network-system", comment = "Fixes potential deadlock on shutdown") private boolean networkSystem = false; @@ -73,10 +70,6 @@ public boolean isHarvestBlock() { return harvestBlock; } - public boolean isItemHandlerFabric() { - return itemHandlerFabric; - } - public boolean isNetworkSystem() { return networkSystem; } diff --git a/src/main/java/io/github/lxgaming/sledgehammer/integrations/SpongeIntegration_ItemTeleport.java b/src/main/java/io/github/lxgaming/sledgehammer/integrations/SpongeIntegration_ItemTeleport.java index 6c6a7ce..ffda2cc 100644 --- a/src/main/java/io/github/lxgaming/sledgehammer/integrations/SpongeIntegration_ItemTeleport.java +++ b/src/main/java/io/github/lxgaming/sledgehammer/integrations/SpongeIntegration_ItemTeleport.java @@ -22,9 +22,11 @@ import io.github.lxgaming.sledgehammer.util.Toolbox; import org.apache.commons.lang3.StringUtils; import org.spongepowered.api.Sponge; +import org.spongepowered.api.block.BlockTypes; import org.spongepowered.api.entity.Item; import org.spongepowered.api.event.Listener; import org.spongepowered.api.event.Order; +import org.spongepowered.api.event.block.CollideBlockEvent; import org.spongepowered.api.event.entity.MoveEntityEvent; import org.spongepowered.api.event.filter.cause.Root; import org.spongepowered.api.text.Text; @@ -41,13 +43,36 @@ public boolean prepareIntegration() { return true; } + @Listener(order = Order.LAST) + public void onCollideBlock(CollideBlockEvent event, @Root Item item) { + if (event.getTargetBlock().getType() != BlockTypes.PORTAL && event.getTargetBlock().getType() != BlockTypes.END_PORTAL) { + return; + } + + if (item.isRemoved()) { + return; + } + + item.remove(); + + Sledgehammer.getInstance().debugMessage("Item {} removed", item.getItemType().getId()); + Sledgehammer.getInstance().getConfig().map(Config::getMessageCategory).map(MessageCategory::getItemTeleport).filter(StringUtils::isNotBlank).ifPresent(message -> { + item.getCreator().flatMap(Sponge.getServer()::getPlayer).ifPresent(player -> { + player.sendMessage(Text.of(Toolbox.getTextPrefix(), Toolbox.convertColor(message.replace("[ITEM]", item.getItemType().getId())))); + }); + }); + } + @Listener(order = Order.LAST) public void onMoveEntity(MoveEntityEvent.Teleport event, @Root Item item) { if (event.getFromTransform().getExtent() == event.getToTransform().getExtent()) { return; } - event.setCancelled(true); + if (item.isRemoved()) { + return; + } + item.remove(); Sledgehammer.getInstance().debugMessage("Item {} removed", item.getItemType().getId()); diff --git a/src/main/java/io/github/lxgaming/sledgehammer/mixin/spongeforge/mod/item/inventory/fabric/MixinIItemHandlerFabric.java b/src/main/java/io/github/lxgaming/sledgehammer/mixin/spongeforge/mod/item/inventory/fabric/MixinIItemHandlerFabric.java deleted file mode 100644 index ea588d1..0000000 --- a/src/main/java/io/github/lxgaming/sledgehammer/mixin/spongeforge/mod/item/inventory/fabric/MixinIItemHandlerFabric.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 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.spongeforge.mod.item.inventory.fabric; - -import io.github.lxgaming.sledgehammer.Sledgehammer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.items.IItemHandler; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.mod.item.inventory.fabric.IItemHandlerFabric; - -@Mixin(value = IItemHandlerFabric.class, priority = 1337, remap = false) -public abstract class MixinIItemHandlerFabric { - - @Inject(method = "setIItemHandlerStack", at = @At(value = "HEAD"), cancellable = true) - private static void onSetIItemHandlerStack(IItemHandler handler, int index, ItemStack stack, CallbackInfo callbackInfo) { - callbackInfo.cancel(); - Sledgehammer.getInstance().debugMessage("IItemHandlerFabric::setIItemHandlerStack Cancelled"); - } -} \ No newline at end of file diff --git a/src/main/java/io/github/lxgaming/sledgehammer/util/Reference.java b/src/main/java/io/github/lxgaming/sledgehammer/util/Reference.java index 6bbd6d3..661c479 100644 --- a/src/main/java/io/github/lxgaming/sledgehammer/util/Reference.java +++ b/src/main/java/io/github/lxgaming/sledgehammer/util/Reference.java @@ -20,7 +20,7 @@ public class Reference { public static final String PLUGIN_ID = "sledgehammer"; public static final String PLUGIN_NAME = "Sledgehammer"; - public static final String PLUGIN_VERSION = "1.12.2-1.2.11"; + public static final String PLUGIN_VERSION = "1.12.2-1.2.12"; public static final String DESCRIPTION = "Smashes the stupid out of the server."; public static final String AUTHORS = "LX_Gaming"; public static final String SOURCE = "https://github.com/LXGaming/Sledgehammer/"; diff --git a/src/main/resources/mixins.sledgehammer.spongeforge.json b/src/main/resources/mixins.sledgehammer.spongeforge.json index 23c6aef..fddfb66 100644 --- a/src/main/resources/mixins.sledgehammer.spongeforge.json +++ b/src/main/resources/mixins.sledgehammer.spongeforge.json @@ -7,7 +7,6 @@ "target": "@env(DEFAULT)", "compatibilityLevel": "JAVA_8", "mixins": [ - "mod.item.inventory.fabric.MixinIItemHandlerFabric" ], "injectors": { "defaultRequire": 1