Files
ThaumicTinkerer/src/main/java/thaumic/tinkerer/common/compat/EnderStorageFunctions.java
T
Jason Mitchell acbc864d76 Infused fire (#31)
* BS + SA

* Intellij Cleanups

* Add missing overrides

* Cleanup fire code

* Less allocations

* Get rid of BlockTuple -> Far fewer allocations (It was only used for Ordo Fire which isn't very useful for NH)
Neuter Ordo fire (will be reworked once we figure out what it should do)
Mixin to fix fire rendering on water -- call the subclass's canCatchFire instead of the base class
Properly tether the fire spread to 15 blocks from the source, which never burns out.

* rm

* Spotless
2023-09-10 07:17:59 -07:00

81 lines
3.4 KiB
Java

package thaumic.tinkerer.common.compat;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import codechicken.enderstorage.api.EnderStorageManager;
import codechicken.enderstorage.storage.item.EnderItemStorage;
import codechicken.enderstorage.storage.item.TileEnderChest;
import thaumcraft.common.items.wands.ItemWandCasting;
import thaumic.tinkerer.common.item.foci.ItemFocusEnderChest;
public class EnderStorageFunctions {
public static ItemStack onFocusRightClick(ItemStack stack, World world, EntityPlayer p, MovingObjectPosition pos) {
ItemWandCasting wand = (ItemWandCasting) stack.getItem();
ItemStack focus = wand.getFocusItem(stack);
if (world.isRemote) return stack;
if (!focus.hasTagCompound()) focus.setTagCompound(new NBTTagCompound());
if (pos != null) {
TileEntity tile = world.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
if (tile instanceof TileEnderChest && p.isSneaking()) {
TileEnderChest chest = (TileEnderChest) tile;
focus.getTagCompound().setInteger("freq", chest.freq);
focus.getTagCompound().setString("owner", chest.owner);
focus.getTagCompound().setBoolean("ender", true);
wand.setFocus(stack, focus);
return stack;
}
if (world.getBlock(pos.blockX, pos.blockY, pos.blockZ) == Blocks.obsidian && p.isSneaking()) {
focus.getTagCompound().setInteger("freq", -1);
focus.getTagCompound().setString("owner", p.getGameProfile().getName());
focus.getTagCompound().setBoolean("ender", false);
wand.setFocus(stack, focus);
return stack;
}
}
boolean vanilla = !focus.getTagCompound().getBoolean("ender");
if (wand.consumeAllVis(stack, p, ItemFocusEnderChest.visUsage, true, false)) {
if (vanilla) {
p.displayGUIChest(p.getInventoryEnderChest());
world.playSoundAtEntity(p, "mob.endermen.portal", 1F, 1F);
} else {
int freq = focus.getTagCompound().getInteger("freq");
((EnderItemStorage) EnderStorageManager.instance(world.isRemote)
.getStorage(getOwner(focus), freq & 0xFFF, "item")).openSMPGui(p, focus.getDisplayName());
}
}
return stack;
}
private static String getOwner(ItemStack stack) {
return stack.hasTagCompound() ? stack.getTagCompound().getString("owner") : "global";
}
public static void addFocusInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
if (stack.hasTagCompound() && !stack.getTagCompound().getString("owner").equals("global"))
list.add(stack.getTagCompound().getString("owner"));
}
public static String getSortingHelper(ItemStack focus) {
String base = "TTEC";
if (!focus.hasTagCompound()) return base + "-VANILLA";
boolean vanilla = !focus.getTagCompound().getBoolean("ender");
if (vanilla) return base + "-VANILLA";
int freq = focus.getTagCompound().getInteger("freq");
return base + Integer.toString(freq) + getOwner(focus);
}
}