diff --git a/.gitignore b/.gitignore index 01b7c3c88e..3a7dcd02b5 100644 --- a/.gitignore +++ b/.gitignore @@ -64,8 +64,7 @@ Thumbs.db .settings .checkstyle .factorypath -run -./eclipse +*/eclipse nbproject atlassian-ide-plugin.xml build.xml @@ -76,3 +75,5 @@ nb-configuration.xml /.apt_generated/ *.launch classes/ +# Ignore mixin generated folders. these contain compiled class transformed classes and potentially generated sourcecode. +.mixin.out/ diff --git a/SpongeCommon b/SpongeCommon index bd8fdfef01..ca8613e574 160000 --- a/SpongeCommon +++ b/SpongeCommon @@ -1 +1 @@ -Subproject commit bd8fdfef01ae62a0eb8ee84417507a6bafa995b0 +Subproject commit ca8613e5748973fa663fa6b6ff970304de5009c9 diff --git a/src/main/java/org/spongepowered/mod/event/SpongeEventHooks.java b/src/main/java/org/spongepowered/mod/event/SpongeEventHooks.java index be36662b89..73b63b807b 100644 --- a/src/main/java/org/spongepowered/mod/event/SpongeEventHooks.java +++ b/src/main/java/org/spongepowered/mod/event/SpongeEventHooks.java @@ -30,7 +30,7 @@ import net.minecraftforge.event.world.ChunkWatchEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.spongepowered.common.interfaces.IMixinChunk; -import org.spongepowered.common.interfaces.entity.IMixinEntity; +import org.spongepowered.common.bridge.entity.IMixinEntity; import org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer; import org.spongepowered.common.util.SpongeHooks; diff --git a/src/main/java/org/spongepowered/mod/event/SpongeToForgeEventFactory.java b/src/main/java/org/spongepowered/mod/event/SpongeToForgeEventFactory.java index d90779cf82..9c924a04df 100644 --- a/src/main/java/org/spongepowered/mod/event/SpongeToForgeEventFactory.java +++ b/src/main/java/org/spongepowered/mod/event/SpongeToForgeEventFactory.java @@ -630,7 +630,7 @@ private static void handleCustomStack(SpawnEntityEvent event) { } private static void handleCustomEntityFromIterator(ListIterator it, Entity entity) { - final ItemStack stack = EntityUtil.getItem(entity); + final ItemStack stack = entity instanceof EntityItem ? ((EntityItem) entity).getItem() : ItemStack.EMPTY; final Item item = stack.getItem(); if (item.hasCustomEntity(stack)) { diff --git a/src/main/java/org/spongepowered/mod/mixin/core/block/MixinBlockRailBase.java b/src/main/java/org/spongepowered/mod/mixin/core/block/MixinBlockRailBase.java index 39378d047f..efa71996ec 100644 --- a/src/main/java/org/spongepowered/mod/mixin/core/block/MixinBlockRailBase.java +++ b/src/main/java/org/spongepowered/mod/mixin/core/block/MixinBlockRailBase.java @@ -34,7 +34,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.common.entity.PlayerTracker; import org.spongepowered.common.interfaces.IMixinChunk; -import org.spongepowered.common.interfaces.entity.IMixinEntity; +import org.spongepowered.common.bridge.entity.IMixinEntity; import java.util.Optional; diff --git a/src/main/java/org/spongepowered/mod/mixin/core/common/MixinSpongeImplHooks.java b/src/main/java/org/spongepowered/mod/mixin/core/common/MixinSpongeImplHooks.java index 2934841b48..86d50d644e 100644 --- a/src/main/java/org/spongepowered/mod/mixin/core/common/MixinSpongeImplHooks.java +++ b/src/main/java/org/spongepowered/mod/mixin/core/common/MixinSpongeImplHooks.java @@ -24,12 +24,15 @@ */ package org.spongepowered.mod.mixin.core.common; +import static com.google.common.base.Preconditions.checkNotNull; + import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.Streams; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.crash.CrashReport; +import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; @@ -44,6 +47,7 @@ import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraft.launchwrapper.Launch; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.DamageSource; @@ -63,6 +67,7 @@ import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.capabilities.CapabilityDispatcher; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -76,8 +81,11 @@ import org.spongepowered.api.Sponge; import org.spongepowered.api.block.tileentity.TileEntityType; import org.spongepowered.api.command.args.ChildCommandElementExecutor; +import org.spongepowered.api.data.DataContainer; import org.spongepowered.api.data.type.Profession; import org.spongepowered.api.event.block.InteractBlockEvent; +import org.spongepowered.api.item.ItemType; +import org.spongepowered.api.item.ItemTypes; import org.spongepowered.api.item.inventory.Inventory; import org.spongepowered.api.item.inventory.ItemStack; import org.spongepowered.api.item.inventory.crafting.CraftingGridInventory; @@ -89,6 +97,9 @@ import org.spongepowered.common.SpongeImpl; import org.spongepowered.common.SpongeImplHooks; import org.spongepowered.common.command.SpongeCommandFactory; +import org.spongepowered.common.data.persistence.NbtTranslator; +import org.spongepowered.common.data.util.DataQueries; +import org.spongepowered.common.data.util.NbtDataUtil; import org.spongepowered.common.entity.EntityUtil; import org.spongepowered.common.entity.SpongeProfession; import org.spongepowered.common.event.tracking.PhaseContext; @@ -101,6 +112,7 @@ import org.spongepowered.common.interfaces.world.IMixinITeleporter; import org.spongepowered.common.item.inventory.util.InventoryUtil; import org.spongepowered.common.item.inventory.util.ItemStackUtil; +import org.spongepowered.common.registry.type.ItemTypeRegistryModule; import org.spongepowered.common.registry.type.block.TileEntityTypeRegistryModule; import org.spongepowered.common.registry.type.entity.ProfessionRegistryModule; import org.spongepowered.common.registry.type.world.PortalAgentRegistryModule; @@ -114,6 +126,7 @@ import org.spongepowered.mod.interfaces.IMixinVillagerProfession; import org.spongepowered.mod.item.inventory.adapter.IItemHandlerAdapter; import org.spongepowered.mod.mixin.core.forge.IMixinVillagerRegistry; +import org.spongepowered.mod.mixin.core.item.AccessorForgeItemStack; import org.spongepowered.mod.plugin.SpongeModPluginContainer; import org.spongepowered.mod.util.StaticMixinForgeHelper; import org.spongepowered.mod.util.WrappedArrayList; @@ -956,9 +969,11 @@ public static EnumActionResult onForgeItemUseFirst(EntityPlayer player, net.mine * @param entity The vanilla entity item * @return The custom item entity for the dropped item */ + @Nullable @Overwrite public static Entity getCustomEntityIfItem(Entity entity) { - final net.minecraft.item.ItemStack stack = EntityUtil.getItem(entity); + final net.minecraft.item.ItemStack stack = + entity instanceof EntityItem ? ((EntityItem) entity).getItem() : net.minecraft.item.ItemStack.EMPTY; final Item item = stack.getItem(); if (item.hasCustomEntity(stack)) { @@ -972,4 +987,86 @@ public static Entity getCustomEntityIfItem(Entity entity) { return entity; } + /** + * @author gabizou - June 10th, 2019 - 1.12.2 + * @reason Forge supports replacing registry entries, + * and for Items, that's being done pretty much by half the + * larger library mods out there. + * + * @param mixinItem_api The item + * @return The resource location + */ + @Overwrite + @Nullable + public static ResourceLocation getItemResourceLocation(Item mixinItem_api) { + return mixinItem_api.getRegistryName(); + } + + /** + * @author gabizou - June 10th, 2019 - 1.12.2 + * @reason Forge supports item registration replacements, we have to abide + * by that. + * + * @param id The numerical id + * @param name The item name/id being registered to like "minecraft:diamond_sword" + * @param item The item + */ + @Overwrite + public static void registerItemForSpongeRegistry(int id, ResourceLocation name, Item item) { + final Item registered; + final ResourceLocation nameForObject = Item.REGISTRY.getNameForObject(item); + if (nameForObject == null) { + registered = checkNotNull(Item.REGISTRY.getObject(name), "Someone replaced a vanilla item with a null item!!!"); + } else { + registered = item; + } + ItemTypeRegistryModule.getInstance().registerAdditionalCatalog((ItemType) registered); + } + + /** + * @author gabizou - June 10th, 2019 + * @reason Access forge capabilities to write to DataView + * for the implementation of {@link ItemStack#toContainer()}. + */ + @SuppressWarnings("ConstantConditions") + @Overwrite + public static void writeItemStackCapabilitiesToDataView(DataContainer container, net.minecraft.item.ItemStack stack) { + final CapabilityDispatcher capabilities = ((AccessorForgeItemStack) (Object) stack).accessor$getCapabilities(); + if (capabilities != null) { + final NBTTagCompound caps = capabilities.serializeNBT(); + if (caps != null && !caps.isEmpty()) { + final DataContainer capsView = NbtTranslator.getInstance().translate(caps); + container.set(DataQueries.UNSAFE_NBT.then(NbtDataUtil.FORGE_CAPS), capsView); + } + } + } + + /** + * @author gabizou - June 10th, 2019 + * @reason Forge adds some changes to allow enchantments on items or books. + * + * @param enchantment The enchantment + * @param stack The item stack + * @return True if it can be applied + */ + @Overwrite + public static boolean canEnchantmentBeAppliedToItem(Enchantment enchantment, net.minecraft.item.ItemStack stack) { + return (stack.getItem() == ItemTypes.BOOK) ? enchantment.isAllowedOnBooks() : enchantment.canApply((net.minecraft.item.ItemStack) (Object) stack); + } + + /** + * @author gabizou - June 10th, 2019 + * @reason Forge adds capabilities and we need to deserialize them + * from the compound. + * + * @param stack The item stack + * @param compoundTag The compound tag + */ + @Overwrite + public static void setCapabilitiesFromSpongeBuilder(ItemStack stack, NBTTagCompound compoundTag) { + final CapabilityDispatcher capabilities = ((AccessorForgeItemStack) stack).accessor$getCapabilities(); + if (capabilities != null) { + capabilities.deserializeNBT(compoundTag); + } + } } diff --git a/src/main/java/org/spongepowered/mod/mixin/core/entity/MixinEntity.java b/src/main/java/org/spongepowered/mod/mixin/core/entity/MixinEntity.java index 7a65f10b63..cec32ef25a 100644 --- a/src/main/java/org/spongepowered/mod/mixin/core/entity/MixinEntity.java +++ b/src/main/java/org/spongepowered/mod/mixin/core/entity/MixinEntity.java @@ -33,7 +33,7 @@ import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.entity.EntityUtil; -import org.spongepowered.common.interfaces.entity.IMixinEntity; +import org.spongepowered.common.bridge.entity.IMixinEntity; import org.spongepowered.common.interfaces.world.IMixinITeleporter; import org.spongepowered.mod.util.WrappedArrayList; @@ -65,7 +65,7 @@ public abstract class MixinEntity implements IMixinEntity { public net.minecraft.entity.Entity changeDimension(int toDimensionId, ITeleporter teleporter) { if (!this.world.isRemote && !this.isDead) { // Sponge Start - Handle teleportation solely in TrackingUtil where everything can be debugged. - return EntityUtil.transferEntityToDimension(this, toDimensionId, (IMixinITeleporter) teleporter, null); + return EntityUtil.transferEntityToDimension((Entity) (Object) this, toDimensionId, (IMixinITeleporter) teleporter, null); // Sponge End } return null; diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/inventory/MixinItemStackHandler.java b/src/main/java/org/spongepowered/mod/mixin/core/forge/items/MixinItemStackHandler_Forge.java similarity index 96% rename from src/main/java/org/spongepowered/mod/mixin/core/item/inventory/MixinItemStackHandler.java rename to src/main/java/org/spongepowered/mod/mixin/core/forge/items/MixinItemStackHandler_Forge.java index 9f7ca7c464..a721530220 100644 --- a/src/main/java/org/spongepowered/mod/mixin/core/item/inventory/MixinItemStackHandler.java +++ b/src/main/java/org/spongepowered/mod/mixin/core/forge/items/MixinItemStackHandler_Forge.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.mod.mixin.core.item.inventory; +package org.spongepowered.mod.mixin.core.forge.items; import net.minecraftforge.items.ItemStackHandler; import org.spongepowered.api.item.inventory.EmptyInventory; @@ -51,7 +51,7 @@ @SuppressWarnings("rawtypes") @Mixin(ItemStackHandler.class) @Implements(@Interface(iface = Inventory.class, prefix = "inventory$")) -public abstract class MixinItemStackHandler implements MinecraftInventoryAdapter, IMixinInventory { +public abstract class MixinItemStackHandler_Forge implements MinecraftInventoryAdapter, IMixinInventory { @Nullable protected Inventory parent; protected SlotCollection slots; diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/inventory/MixinSlotItemHandler.java b/src/main/java/org/spongepowered/mod/mixin/core/forge/items/MixinSlotItemHandler.java similarity index 94% rename from src/main/java/org/spongepowered/mod/mixin/core/item/inventory/MixinSlotItemHandler.java rename to src/main/java/org/spongepowered/mod/mixin/core/forge/items/MixinSlotItemHandler.java index d93151f6a4..dc658357c1 100644 --- a/src/main/java/org/spongepowered/mod/mixin/core/item/inventory/MixinSlotItemHandler.java +++ b/src/main/java/org/spongepowered/mod/mixin/core/forge/items/MixinSlotItemHandler.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.mod.mixin.core.item.inventory; +package org.spongepowered.mod.mixin.core.forge.items; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; @@ -30,7 +30,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.mixin.core.item.inventory.MixinSlot; +import org.spongepowered.common.mixin.core.inventory.MixinSlot; import org.spongepowered.mod.item.inventory.adapter.IItemHandlerAdapter; @Mixin(value = SlotItemHandler.class, remap = false) diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/inventory/MixinInvWrapper.java b/src/main/java/org/spongepowered/mod/mixin/core/forge/items/wrapper/MixinInvWrapper_Forge.java similarity index 96% rename from src/main/java/org/spongepowered/mod/mixin/core/item/inventory/MixinInvWrapper.java rename to src/main/java/org/spongepowered/mod/mixin/core/forge/items/wrapper/MixinInvWrapper_Forge.java index 5da16be688..7b54f20ed0 100644 --- a/src/main/java/org/spongepowered/mod/mixin/core/item/inventory/MixinInvWrapper.java +++ b/src/main/java/org/spongepowered/mod/mixin/core/forge/items/wrapper/MixinInvWrapper_Forge.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.mod.mixin.core.item.inventory; +package org.spongepowered.mod.mixin.core.forge.items.wrapper; import net.minecraftforge.items.wrapper.InvWrapper; import org.spongepowered.api.item.inventory.EmptyInventory; @@ -51,7 +51,7 @@ @SuppressWarnings("rawtypes") @Mixin(InvWrapper.class) @Implements(@Interface(iface = Inventory.class, prefix = "inventory$")) -public abstract class MixinInvWrapper implements MinecraftInventoryAdapter, IMixinInventory { +public abstract class MixinInvWrapper_Forge implements MinecraftInventoryAdapter, IMixinInventory { @Nullable protected Inventory parent; protected SlotCollection slots; diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/AccessorForgeItemStack.java b/src/main/java/org/spongepowered/mod/mixin/core/item/AccessorForgeItemStack.java new file mode 100644 index 0000000000..8a784c9176 --- /dev/null +++ b/src/main/java/org/spongepowered/mod/mixin/core/item/AccessorForgeItemStack.java @@ -0,0 +1,17 @@ +package org.spongepowered.mod.mixin.core.item; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.capabilities.CapabilityDispatcher; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import javax.annotation.Nullable; + +@Mixin(ItemStack.class) +public interface AccessorForgeItemStack { + + @Nullable + @Accessor(value = "capabilities", remap = false) + CapabilityDispatcher accessor$getCapabilities(); + +} diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinEnchantment.java b/src/main/java/org/spongepowered/mod/mixin/core/item/MixinEnchantment.java deleted file mode 100644 index 293ebc453d..0000000000 --- a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinEnchantment.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of Sponge, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.mod.mixin.core.item; - -import org.spongepowered.api.item.ItemTypes; -import org.spongepowered.api.item.enchantment.EnchantmentType; -import org.spongepowered.api.item.inventory.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(net.minecraft.enchantment.Enchantment.class) -public abstract class MixinEnchantment implements EnchantmentType { - - @Shadow public abstract boolean canApply(net.minecraft.item.ItemStack stack); - @Shadow(remap = false) - public abstract boolean isAllowedOnBooks(); - - @Override - public boolean canBeAppliedToStack(ItemStack stack) { - return (stack.getType() == ItemTypes.BOOK) ? isAllowedOnBooks() : canApply((net.minecraft.item.ItemStack) (Object) stack); - } - -} diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItem.java b/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItem.java deleted file mode 100644 index eb6afccec9..0000000000 --- a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItem.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is part of Sponge, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.mod.mixin.core.item; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import net.minecraft.entity.Entity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; -import org.spongepowered.api.item.ItemType; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -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.common.interfaces.item.IMixinItem; -import org.spongepowered.common.registry.type.ItemTypeRegistryModule; - -import java.util.Optional; - -import javax.annotation.Nullable; - -@Mixin(value = Item.class, priority = 1050) -public abstract class MixinItem implements ItemType, IMixinItem { - - @Shadow(remap = false) public abstract boolean hasCustomEntity(ItemStack stack); - @Shadow(remap = false) @Nullable public abstract Entity createEntity(World world, Entity location, ItemStack itemstack); - - @Override - public String getId() { - final ResourceLocation resourceLocation = ((Item) (Object) this).getRegistryName(); - checkState(resourceLocation != null, "Attempted to access the id before the registry name is set."); - return resourceLocation.toString(); - } - - @Inject(method = "registerItem(ILnet/minecraft/util/ResourceLocation;Lnet/minecraft/item/Item;)V", at = @At("RETURN")) - private static void registerMinecraftItem(int id, ResourceLocation name, Item item, CallbackInfo ci) { - final Item registered; - final ResourceLocation nameForObject = Item.REGISTRY.getNameForObject(item); - if (nameForObject == null) { - registered = checkNotNull(Item.REGISTRY.getObject(name), "Someone replaced a vanilla item with a null item!!!"); - } else { - registered = item; - } - ItemTypeRegistryModule.getInstance().registerAdditionalCatalog((ItemType) registered); - } - - @Override - public Optional getCustomEntityItem(World world, Entity location, ItemStack itemstack) { - if (this.hasCustomEntity(itemstack)) { - return Optional.ofNullable(createEntity(world, location, itemstack)); - } - return Optional.empty(); - } -} diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemDye.java b/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemDye_Forge.java similarity index 98% rename from src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemDye.java rename to src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemDye_Forge.java index 10c6da8f3c..286dbe1cdb 100644 --- a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemDye.java +++ b/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemDye_Forge.java @@ -50,7 +50,7 @@ import javax.annotation.Nullable; @Mixin(ItemDye.class) -public abstract class MixinItemDye extends MixinItem { +public abstract class MixinItemDye_Forge extends MixinItem { /** * @author gabizou - March 20th, 2019 - 1.12.2 diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemLilyPad.java b/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemLilyPad.java deleted file mode 100644 index 79523861a2..0000000000 --- a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemLilyPad.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of Sponge, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.mod.mixin.core.item; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockLiquid; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemColored; -import net.minecraft.item.ItemLilyPad; -import net.minecraft.item.ItemStack; -import net.minecraft.stats.StatList; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - -@Mixin(ItemLilyPad.class) -public abstract class MixinItemLilyPad extends ItemColored { - - public MixinItemLilyPad(Block block, boolean hasSubtypes) { - super(block, hasSubtypes); - } - - /** - * @author bloodmc - December 16th, 2015 - * @reason Restored to vanilla method as we do not need Forge's - * block snapshot calls nor event call due to our tracking system. - */ - @Override - @Overwrite - public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { - ItemStack itemstack = playerIn.getHeldItem(handIn); - RayTraceResult rayTraceResult = this.rayTrace(worldIn, playerIn, true); - - if (rayTraceResult == null) { - return new ActionResult<>(EnumActionResult.PASS, itemstack); - } else { - if (rayTraceResult.typeOfHit == RayTraceResult.Type.BLOCK) { - BlockPos blockpos = rayTraceResult.getBlockPos(); - - if (!worldIn.isBlockModifiable(playerIn, blockpos)) { - return new ActionResult<>(EnumActionResult.FAIL, itemstack); - } - - if (!playerIn.canPlayerEdit(blockpos.offset(rayTraceResult.sideHit), rayTraceResult.sideHit, itemstack)) { - return new ActionResult<>(EnumActionResult.FAIL, itemstack); - } - - BlockPos blockpos1 = blockpos.up(); - IBlockState iblockstate = worldIn.getBlockState(blockpos); - - if (iblockstate.getMaterial() == Material.WATER && iblockstate.getValue(BlockLiquid.LEVEL) - == 0 && worldIn.isAirBlock(blockpos1)) { - worldIn.setBlockState(blockpos1, Blocks.WATERLILY.getDefaultState()); - - if (!playerIn.capabilities.isCreativeMode) { - itemstack.shrink(1); - } - - playerIn.addStat(StatList.getObjectUseStats(this)); - } - } - - return new ActionResult<>(EnumActionResult.FAIL, itemstack); - } - } -} diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemLilyPad_Forge.java b/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemLilyPad_Forge.java new file mode 100644 index 0000000000..e3822c1538 --- /dev/null +++ b/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemLilyPad_Forge.java @@ -0,0 +1,81 @@ +/* + * This file is part of Sponge, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.mod.mixin.core.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemLilyPad; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.common.util.BlockSnapshot; +import net.minecraftforge.event.world.BlockEvent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.common.mixin.core.item.MixinItem; + +@Mixin(ItemLilyPad.class) +public abstract class MixinItemLilyPad_Forge extends MixinItem { + + @Redirect(method = "onItemRightClick", + at = @At(value = "INVOKE", + target = "Lnet/minecraftforge/common/util/BlockSnapshot;getBlockSnapshot(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraftforge/common/util/BlockSnapshot;", + remap = false + ) + ) + private BlockSnapshot sponge$IgnoreSnapshotCreationDuetoTracking(World world, BlockPos pos) { + return null; + } + + @SuppressWarnings("deprecation") + @Redirect(method = "onItemRightClick", + at = @At( + value = "INVOKE", + target = "Lnet/minecraftforge/event/ForgeEventFactory;onPlayerBlockPlace(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraftforge/common/util/BlockSnapshot;Lnet/minecraft/util/EnumFacing;Lnet/minecraft/util/EnumHand;)Lnet/minecraftforge/event/world/BlockEvent$PlaceEvent;", + remap = false + ) + ) + private BlockEvent.PlaceEvent sponge$IgnoreForgeEventDueToTracker(EntityPlayer player, BlockSnapshot blockSnapshot, EnumFacing direction, EnumHand hand) { + return null; + } + + /** + * @author gabizou - June 10th, 2019 - 1.12.2 + * @reason Because we null out the event creation so that we can ignore the cancellation, we also + * need to redirect the actual event call for isCancelled so it doesn't NPE. This always returns false. + * In essence though, this will effectively turn Forge's event changes to three method calls + * and one of them being always constant. Certainly better than performing an overwrite that needs to be maintained. + * + * @param placeEvent The place event + * @return Always false, we handle this in the Sponge implementation for interactions + */ + @Redirect(method = "onItemRightClick", + at = @At(value = "INVOKE", target = "Lnet/minecraftforge/event/world/BlockEvent$PlaceEvent;isCanceled()Z") + ) + private boolean sponge$IgnoreEventCancellation(BlockEvent.PlaceEvent placeEvent) { + return false; + } +} diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemShears.java b/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemShears_Forge.java similarity index 95% rename from src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemShears.java rename to src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemShears_Forge.java index 3a5e3ded72..a40323cf7e 100644 --- a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemShears.java +++ b/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemShears_Forge.java @@ -50,8 +50,8 @@ import java.util.List; import java.util.Random; -@Mixin(value = ItemShears.class, remap = false) -public abstract class MixinItemShears extends Item { +@Mixin(value = ItemShears.class) +public abstract class MixinItemShears_Forge extends Item { /** @@ -63,10 +63,9 @@ public abstract class MixinItemShears extends Item { * Returns true if the item can be used on the given entity, e.g. shears on sheep. */ @SuppressWarnings({"unchecked", "rawtypes"}) - @Overwrite + @Overwrite(remap = false) @Override - public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity, - EnumHand hand) { + public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) { if (entity.world.isRemote) { return false; @@ -93,7 +92,7 @@ public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player final ItemStackSnapshot snapshot = ItemStackUtil.snapshotOf(drop); original.add(snapshot); try (final CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) { - item = EntityUtil.throwDropItemAndConstructEvent(EntityUtil.toMixin(entity), posX, posY, posZ, snapshot, original, frame); + item = EntityUtil.throwDropItemAndConstructEvent(entity, posX, posY, posZ, snapshot, original, frame); } if (item == null || item.isEmpty()) { diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemStack.java b/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemStack.java deleted file mode 100644 index ee7ee0e5d5..0000000000 --- a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemStack.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file is part of Sponge, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.mod.mixin.core.item; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.stats.StatList; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.capabilities.CapabilityDispatcher; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.common.interfaces.item.IMixinItemStack; - -import javax.annotation.Nullable; - -@Mixin(net.minecraft.item.ItemStack.class) -public abstract class MixinItemStack implements IMixinItemStack { - - @Shadow public abstract net.minecraft.item.Item shadow$getItem(); - - // Disable Forge PlaceEvent patch as we handle this in World setBlockState - - @Shadow(remap = false) @Nullable private CapabilityDispatcher capabilities; - - /** - * @author blood - October 7th, 2015 - * @reason Rewrites the method to vanilla logic where we handle events. - * The forge event is thrown within our system. - * - * @param playerIn The player using the item - * @param worldIn The world the item is being used - * @param pos The position of the block being interacted with - * @param side The side of the block - * @param hitX The hit position from 0 to 1 of the face of the block - * @param hitY The hit position from 0 to 1 on the depth of the block - * @param hitZ The hit position from 0 to 1 on the height of the block - * @return True if the use was successful - */ - @Overwrite - public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing - side, float hitX, float hitY, float hitZ) { - final EnumActionResult result = this.shadow$getItem().onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ); - - if (result == EnumActionResult.SUCCESS) { - playerIn.addStat(StatList.getObjectUseStats(this.shadow$getItem())); - } - - return result; - } - - - @Nullable - @Override - public NBTTagCompound getCapabitilitiesForSpongeContainer() { - if (this.capabilities != null) { - return this.capabilities.serializeNBT(); - } - return null; - } - - @Override - public void setCapabilitiesFromSpongeBuilder(NBTTagCompound compound) { - if (this.capabilities != null) { - this.capabilities.deserializeNBT(compound); - } - } -} diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemStack_Forge.java b/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemStack_Forge.java new file mode 100644 index 0000000000..85a223c4e6 --- /dev/null +++ b/src/main/java/org/spongepowered/mod/mixin/core/item/MixinItemStack_Forge.java @@ -0,0 +1,67 @@ +/* + * This file is part of Sponge, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.mod.mixin.core.item; + +import net.minecraft.world.World; +import org.spongepowered.asm.lib.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.Slice; + +@Mixin(net.minecraft.item.ItemStack.class) +public abstract class MixinItemStack_Forge { + + /** + * @author gabizou - June 10th, 2019 - 1.12.2 + * @reason Since we handle placement logic already in common, we override + * the {@code world.isRemote} to return {@code true} so that forge's hook + * is never called on. This will allow us to essentially keep/retain vanilla + * logic. + * + * @param world The world being used + * @return True, always true, we handle the logic in our mixins in common + */ + @Redirect( + method = "onItemUse", + at = @At( + value = "FIELD", + target = "Lnet/minecraft/world/World;isRemote:Z", + opcode = Opcodes.GETFIELD + ), + slice = @Slice( + from = @At("HEAD"), + to = @At( + value = "INVOKE", + target = "Lnet/minecraftforge/common/ForgeHooks;onPlaceItemIntoWorld(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;FFFLnet/minecraft/util/EnumHand;)Lnet/minecraft/util/EnumActionResult;", + remap = false + ) + ) + ) + private boolean sponge$ReturnTrueForWorldSoForgeEventIsIgnored(World world) { + return true; + } + +} diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/inventory/package-info.java b/src/main/java/org/spongepowered/mod/mixin/core/item/inventory/package-info.java deleted file mode 100644 index 822100a5d8..0000000000 --- a/src/main/java/org/spongepowered/mod/mixin/core/item/inventory/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of Sponge, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -@org.spongepowered.api.util.annotation.NonnullByDefault -package org.spongepowered.mod.mixin.core.item.inventory; \ No newline at end of file diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/recipe/MixinSpongeRecipe.java b/src/main/java/org/spongepowered/mod/mixin/core/item/recipe/crafting/MixinDelegateSpongeCraftingRecipe_Forge.java similarity index 93% rename from src/main/java/org/spongepowered/mod/mixin/core/item/recipe/MixinSpongeRecipe.java rename to src/main/java/org/spongepowered/mod/mixin/core/item/recipe/crafting/MixinDelegateSpongeCraftingRecipe_Forge.java index 62b6d06941..5850e20e59 100644 --- a/src/main/java/org/spongepowered/mod/mixin/core/item/recipe/MixinSpongeRecipe.java +++ b/src/main/java/org/spongepowered/mod/mixin/core/item/recipe/crafting/MixinDelegateSpongeCraftingRecipe_Forge.java @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.mod.mixin.core.item.recipe; +package org.spongepowered.mod.mixin.core.item.recipe.crafting; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.ResourceLocation; @@ -33,7 +33,7 @@ import javax.annotation.Nullable; @Mixin(value = DelegateSpongeCraftingRecipe.class, remap = false) -public abstract class MixinSpongeRecipe implements IForgeRegistryEntry { +public abstract class MixinDelegateSpongeCraftingRecipe_Forge implements IForgeRegistryEntry { private ResourceLocation registryName; diff --git a/src/main/java/org/spongepowered/mod/mixin/core/item/recipe/package-info.java b/src/main/java/org/spongepowered/mod/mixin/core/item/recipe/package-info.java deleted file mode 100644 index f938c0b264..0000000000 --- a/src/main/java/org/spongepowered/mod/mixin/core/item/recipe/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of Sponge, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -@org.spongepowered.api.util.annotation.NonnullByDefault -package org.spongepowered.mod.mixin.core.item.recipe; diff --git a/src/main/java/org/spongepowered/mod/mixin/core/nbt/MixinNBTTagCompound.java b/src/main/java/org/spongepowered/mod/mixin/core/nbt/MixinNBTTagCompound_Forge.java similarity index 96% rename from src/main/java/org/spongepowered/mod/mixin/core/nbt/MixinNBTTagCompound.java rename to src/main/java/org/spongepowered/mod/mixin/core/nbt/MixinNBTTagCompound_Forge.java index 525f743441..32277c5219 100644 --- a/src/main/java/org/spongepowered/mod/mixin/core/nbt/MixinNBTTagCompound.java +++ b/src/main/java/org/spongepowered/mod/mixin/core/nbt/MixinNBTTagCompound_Forge.java @@ -41,10 +41,10 @@ import java.lang.reflect.Method; @Mixin(NBTTagCompound.class) -public class MixinNBTTagCompound { +public class MixinNBTTagCompound_Forge { @Inject(method = "setTag(Ljava/lang/String;Lnet/minecraft/nbt/NBTBase;)V", at = @At("HEAD")) - private void checkNullTag(String key, NBTBase value, CallbackInfo callbackInfo) { + private void sponge$throwNPEForNullTag(String key, NBTBase value, CallbackInfo callbackInfo) { if (value == null) { final PrettyPrinter printer = new PrettyPrinter(60); printer.add("Null being stored in NBT!").centre().hr(); diff --git a/src/main/java/org/spongepowered/mod/mixin/entityactivation/MixinWorld_Activation.java b/src/main/java/org/spongepowered/mod/mixin/entityactivation/MixinWorld_Activation.java index 0fbfbce867..1b6784f838 100644 --- a/src/main/java/org/spongepowered/mod/mixin/entityactivation/MixinWorld_Activation.java +++ b/src/main/java/org/spongepowered/mod/mixin/entityactivation/MixinWorld_Activation.java @@ -32,7 +32,7 @@ import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.common.interfaces.IMixinChunk; -import org.spongepowered.common.interfaces.entity.IMixinEntity; +import org.spongepowered.common.bridge.entity.IMixinEntity; import org.spongepowered.common.interfaces.world.IMixinWorld; import org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer; import org.spongepowered.common.mixin.plugin.entityactivation.EntityActivationRange; diff --git a/src/main/java/org/spongepowered/mod/registry/SpongeForgeGameDictionary.java b/src/main/java/org/spongepowered/mod/registry/SpongeForgeGameDictionary.java index 660df5ed9f..ad0eb86fcf 100644 --- a/src/main/java/org/spongepowered/mod/registry/SpongeForgeGameDictionary.java +++ b/src/main/java/org/spongepowered/mod/registry/SpongeForgeGameDictionary.java @@ -43,7 +43,7 @@ private SpongeForgeGameDictionary() { @Override public void register(String key, Entry entry) { - ItemStack stack = ((SpongeGameDictionaryEntry) entry).createDictionaryStack(OreDictionary.WILDCARD_VALUE); + ItemStack stack = ((SpongeGameDictionaryEntry) entry).bridge$createDictionaryStack(OreDictionary.WILDCARD_VALUE); stack.setCount(1); OreDictionary.registerOre(key, stack); } diff --git a/src/main/resources/mixins.forge.core.json b/src/main/resources/mixins.forge.core.json index 5e636efcde..1b7c64f8c5 100644 --- a/src/main/resources/mixins.forge.core.json +++ b/src/main/resources/mixins.forge.core.json @@ -64,17 +64,15 @@ "forge.fluids.MixinFluid", "forge.fluids.MixinFluidRegistry", "forge.fluids.MixinFluidStack", - "item.MixinEnchantment", - "item.MixinItem", - "item.MixinItemDye", - "item.MixinItemShears", - "item.MixinItemStack", - "item.MixinItemLilyPad", - "item.inventory.MixinInvWrapper", - "item.inventory.MixinItemStackHandler", - "item.inventory.MixinSlotItemHandler", - "item.recipe.MixinSpongeRecipe", - "nbt.MixinNBTTagCompound", + "item.MixinItemDye_Forge", + "item.MixinItemShears_Forge", + "item.MixinItemStack_Forge", + "item.MixinItemLilyPad_Forge", + "forge.items.wrapper.MixinInvWrapper_Forge", + "forge.items.MixinItemStackHandler_Forge", + "forge.items.MixinSlotItemHandler", + "item.recipe.crafting.MixinDelegateSpongeCraftingRecipe_Forge", + "nbt.MixinNBTTagCompound_Forge", "network.packet.MixinCPacketClickWindow", "network.packet.MixinCPacketPlayerDigging", "network.packet.MixinCPacketPlayerTryUseItemOnBlock",