Search in sources :

Example 1 with TileHaloInfuser

use of com.teamwizardry.wizardry.common.tile.TileHaloInfuser in project Wizardry by TeamWizardry.

the class EntityHaloInfusionItem method setHaloInfusionItem.

public void setHaloInfusionItem(@Nonnull HaloInfusionItem haloInfusionItem, boolean soft) {
    this.haloInfusionItem = haloInfusionItem;
    if (soft)
        return;
    TileEntity tile = world.getTileEntity(infuserPos);
    if (tile instanceof TileHaloInfuser) {
        TileHaloInfuser haloInfuser = (TileHaloInfuser) tile;
        ItemStack halo = haloInfuser.getHalo();
        NBTTagList slots = ItemNBTHelper.getList(halo, "slots", NBTTagString.class);
        if (slots == null || slots.tagCount() < HaloInfusionItemRegistry.getItems().size() - 1) {
            slots = new NBTTagList();
            for (int i = 0; i < HaloInfusionItemRegistry.getItems().size(); i++) {
                slots.appendTag(new NBTTagString(HaloInfusionItemRegistry.EMPTY.getNbtName()));
            }
        }
        slots.set(slot, new NBTTagString(haloInfusionItem.getNbtName()));
        ItemNBTHelper.setList(halo, "slots", slots);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NBTTagList(net.minecraft.nbt.NBTTagList) TileHaloInfuser(com.teamwizardry.wizardry.common.tile.TileHaloInfuser) NBTTagString(net.minecraft.nbt.NBTTagString) ItemStack(net.minecraft.item.ItemStack)

Example 2 with TileHaloInfuser

use of com.teamwizardry.wizardry.common.tile.TileHaloInfuser in project Wizardry by TeamWizardry.

the class BlockHaloInfuser method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack heldItem = playerIn.getHeldItem(hand);
    // if (isStructureComplete(worldIn, pos)) {
    TileHaloInfuser infuser = getTE(worldIn, pos);
    if (infuser == null)
        return heldItem.isEmpty();
    if (!infuser.getHalo().isEmpty()) {
        playerIn.setHeldItem(hand, infuser.extractHalo());
        playerIn.openContainer.detectAndSendChanges();
    } else if (heldItem.getItem() == ModItems.FAKE_HALO) {
        infuser.setHalo(heldItem);
        playerIn.setHeldItem(hand, ItemStack.EMPTY);
        playerIn.openContainer.detectAndSendChanges();
    }
    // }
    return heldItem.isEmpty();
}
Also used : TileHaloInfuser(com.teamwizardry.wizardry.common.tile.TileHaloInfuser) ItemStack(net.minecraft.item.ItemStack)

Example 3 with TileHaloInfuser

use of com.teamwizardry.wizardry.common.tile.TileHaloInfuser in project Wizardry by TeamWizardry.

the class RenderHaloInfusionItem method doRender.

@Override
public void doRender(@Nonnull EntityHaloInfusionItem entity, double x, double y, double z, float entityYaw, float partialTicks) {
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
    if (entity.world == null || entity.getInfuserPos() == null)
        return;
    TileEntity tile = entity.world.getTileEntity(entity.getInfuserPos());
    if (!(tile instanceof TileHaloInfuser) || ((TileHaloInfuser) tile).getHalo().isEmpty()) {
        return;
    }
    if (!entity.getHaloInfusionItem().getStack().isEmpty() || RandUtil.nextInt(15) == 0)
        entity.getHaloInfusionItem().render(entity.world, entity.getPositionVector().addVector(0, entity.height / 2.0, 0));
    if (entity.getHaloInfusionItem().getStack().isEmpty())
        return;
    double depthRadius = 0.5;
    EntityPlayer player = Minecraft.getMinecraft().player;
    Vec3d playerSub = player.getPositionVector().addVector(0, player.eyeHeight, 0).subtract(entity.getPositionVector().addVector(0, entity.height, 0));
    Vec3d restricted = playerSub.scale(depthRadius / playerSub.lengthVector());
    restricted = new Vec3d(restricted.x, restricted.y / 2.0, restricted.z);
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);
    GlStateManager.translate(restricted.x, restricted.y + 0.5, restricted.z);
    GlStateManager.scale(0.4, 0.4, 0.4);
    GlStateManager.rotate(Minecraft.getMinecraft().player.rotationYaw * -1, 0, 1, 0);
    GlStateManager.rotate(Minecraft.getMinecraft().player.rotationPitch, 1, 0, 0);
    Minecraft.getMinecraft().getRenderItem().renderItem(entity.getHaloInfusionItem().getStack(), ItemCameraTransforms.TransformType.NONE);
    GlStateManager.popMatrix();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileHaloInfuser(com.teamwizardry.wizardry.common.tile.TileHaloInfuser) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Vec3d(net.minecraft.util.math.Vec3d)

Example 4 with TileHaloInfuser

use of com.teamwizardry.wizardry.common.tile.TileHaloInfuser in project Wizardry by TeamWizardry.

the class EntityHaloInfusionItem method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    if (world == null || infuserPos == null)
        return;
    TileEntity tile = world.getTileEntity(infuserPos);
    if (tile == null || !(tile instanceof TileHaloInfuser)) {
        world.removeEntity(this);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileHaloInfuser(com.teamwizardry.wizardry.common.tile.TileHaloInfuser)

Example 5 with TileHaloInfuser

use of com.teamwizardry.wizardry.common.tile.TileHaloInfuser in project Wizardry by TeamWizardry.

the class EntityHaloInfusionItem method processInitialInteract.

@Override
public boolean processInitialInteract(EntityPlayer player, EnumHand hand) {
    TileEntity tile = world.getTileEntity(infuserPos);
    if (tile == null || !(tile instanceof TileHaloInfuser)) {
        world.removeEntity(this);
        return false;
    }
    ItemStack heldItem = player.getHeldItem(hand);
    if (heldItem.isEmpty()) {
        ItemStack slotted = getHaloInfusionItem().getStack();
        if (!slotted.isEmpty()) {
            player.setHeldItem(hand, slotted);
            setHaloInfusionItem(HaloInfusionItemRegistry.EMPTY, false);
            return true;
        } else
            return true;
    }
    for (HaloInfusionItem haloInfusionItem : HaloInfusionItemRegistry.getItems()) {
        if (haloInfusionItem.getStack().isItemEqual(heldItem)) {
            setHaloInfusionItem(haloInfusionItem, false);
            // todo: remove from hand
            return true;
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileHaloInfuser(com.teamwizardry.wizardry.common.tile.TileHaloInfuser) HaloInfusionItem(com.teamwizardry.wizardry.api.item.halo.HaloInfusionItem) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileHaloInfuser (com.teamwizardry.wizardry.common.tile.TileHaloInfuser)5 TileEntity (net.minecraft.tileentity.TileEntity)4 ItemStack (net.minecraft.item.ItemStack)3 HaloInfusionItem (com.teamwizardry.wizardry.api.item.halo.HaloInfusionItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 NBTTagString (net.minecraft.nbt.NBTTagString)1 Vec3d (net.minecraft.util.math.Vec3d)1