diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/HeaterBlockItem.java b/src/main/java/com/simibubi/create/content/contraptions/processing/HeaterBlockItem.java index 88be8b0f2..7235bb978 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/HeaterBlockItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/HeaterBlockItem.java @@ -1,10 +1,14 @@ package com.simibubi.create.content.contraptions.processing; +import java.util.ArrayList; +import java.util.List; + import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import mcp.MethodsReturnNonnullByDefault; import net.minecraft.block.Block; +import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.monster.BlazeEntity; import net.minecraft.entity.player.PlayerEntity; @@ -16,8 +20,12 @@ import net.minecraft.tileentity.MobSpawnerTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.WeightedSpawnerEntity; import net.minecraft.world.World; +import net.minecraft.world.spawner.AbstractSpawner; import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.fml.common.ObfuscationReflectionHelper; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault @@ -30,13 +38,24 @@ public class HeaterBlockItem extends BlockItem { public ActionResultType onItemUse(ItemUseContext context) { TileEntity te = context.getWorld() .getTileEntity(context.getPos()); - if (te instanceof MobSpawnerTileEntity && ((MobSpawnerTileEntity) te).getSpawnerBaseLogic() - .getCachedEntity() instanceof BlazeEntity) { - ItemStack itemWithBlaze = withBlaze(context.getItem()); - context.getItem() - .shrink(1); - dropOrPlaceBack(context.getWorld(), context.getPlayer(), itemWithBlaze); - return ActionResultType.SUCCESS; + if (te instanceof MobSpawnerTileEntity) { + AbstractSpawner spawner = ((MobSpawnerTileEntity) te).getSpawnerBaseLogic(); + List possibleSpawns = ObfuscationReflectionHelper + .getPrivateValue(AbstractSpawner.class, spawner, "field_98285_e"); + if (possibleSpawns.isEmpty()) { + possibleSpawns = new ArrayList<>(); + possibleSpawns.add( + ObfuscationReflectionHelper.getPrivateValue(AbstractSpawner.class, spawner, "field_98282_f")); + } + for (WeightedSpawnerEntity e : possibleSpawns) { + if (new ResourceLocation(e.getNbt().getString("id")).equals(EntityType.BLAZE.getRegistryName())) { + ItemStack itemWithBlaze = withBlaze(context.getItem()); + context.getItem() + .shrink(1); + dropOrPlaceBack(context.getWorld(), context.getPlayer(), itemWithBlaze); + return ActionResultType.SUCCESS; + } + } } return super.onItemUse(context); }