Search in sources :

Example 1 with EntityHaloInfusionItem

use of com.teamwizardry.wizardry.common.entity.EntityHaloInfusionItem in project Wizardry by TeamWizardry.

the class TileHaloInfuser method refreshEntities.

public void refreshEntities() {
    entities.forEach(entityHaloInfusionItem -> world.removeEntity(entityHaloInfusionItem));
    entities.clear();
    int count = HaloInfusionItemRegistry.getItems().size();
    double radius = 3;
    for (int i = 0; i < count; i++) {
        float angle = (float) (i * Math.PI * 2.0 / count);
        double x = (pos.getX() + 0.5 + MathHelper.cos(angle) * radius);
        double z = (pos.getZ() + 0.5 + MathHelper.sin(angle) * radius);
        EntityHaloInfusionItem entity = new EntityHaloInfusionItem(world, HaloInfusionItemRegistry.EMPTY, getPos(), i);
        entity.setPosition(x, pos.getY() + 2, z);
        entity.forceSpawn = true;
        world.spawnEntity(entity);
        entities.add(entity);
    }
}
Also used : EntityHaloInfusionItem(com.teamwizardry.wizardry.common.entity.EntityHaloInfusionItem)

Example 2 with EntityHaloInfusionItem

use of com.teamwizardry.wizardry.common.entity.EntityHaloInfusionItem in project Wizardry by TeamWizardry.

the class TileHaloInfuser method updateItems.

public void updateItems(boolean soft) {
    NBTTagList slots = NBTHelper.getList(getHalo(), "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()));
        }
        NBTHelper.setList(getHalo(), "slots", slots);
    }
    for (int i = 0; i < HaloInfusionItemRegistry.getItems().size(); i++) {
        EntityHaloInfusionItem entity = entities.get(i);
        String itemName = slots.getStringTagAt(i);
        entity.setHaloInfusionItem(HaloInfusionItemRegistry.getItemFromName(itemName), soft);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagString(net.minecraft.nbt.NBTTagString) EntityHaloInfusionItem(com.teamwizardry.wizardry.common.entity.EntityHaloInfusionItem) NBTTagString(net.minecraft.nbt.NBTTagString)

Aggregations

EntityHaloInfusionItem (com.teamwizardry.wizardry.common.entity.EntityHaloInfusionItem)2 NBTTagList (net.minecraft.nbt.NBTTagList)1 NBTTagString (net.minecraft.nbt.NBTTagString)1