Search in sources :

Example 1 with Tier

use of muramasa.antimatter.machine.Tier in project GT-4-Reimagined by Trinsdar.

the class CoverConveyor method onUpdate.

@Override
public void onUpdate(CoverStack<?> instance, Direction side) {
    if (instance.getTile() == null || instance.getTile().getWorld().getGameTime() % (speeds.get(tier)) != 0)
        return;
    boolean isMachine = instance.getTile() instanceof TileEntityMachine;
    BlockState state = instance.getTile().getWorld().getBlockState(instance.getTile().getPos().offset(side));
    // Drop into world.
    if (state == Blocks.AIR.getDefaultState() && isMachine) {
        World world = instance.getTile().getWorld();
        BlockPos pos = instance.getTile().getPos();
        ItemStack stack = ((TileEntityMachine) instance.getTile()).itemHandler.map(ih -> Utils.extractAny(ih.getOutputHandler())).orElse(ItemStack.EMPTY);
        if (stack.isEmpty())
            return;
        world.addEntity(new ItemEntity(world, pos.getX() + side.getXOffset(), pos.getY() + side.getYOffset(), pos.getZ() + side.getZOffset(), stack));
    }
    if (!(state.hasTileEntity()))
        return;
    TileEntity adjTile = instance.getTile().getWorld().getTileEntity(instance.getTile().getPos().offset(side));
    if (adjTile == null) {
        return;
    }
    if (isMachine) {
        ((TileEntityMachine) instance.getTile()).itemHandler.ifPresent(ih -> adjTile.getCapability(ITEM_HANDLER_CAPABILITY).ifPresent(other -> Utils.transferItems(ih.getOutputHandler(), other, true)));
    } else {
        Utils.transferItemsOnCap(instance.getTile(), adjTile, true);
    }
}
Also used : ImmutableMap(com.google.common.collect.ImmutableMap) TileEntityMachine(muramasa.antimatter.tile.TileEntityMachine) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) Direction(net.minecraft.util.Direction) CoverTiered(muramasa.antimatter.cover.CoverTiered) Utils(muramasa.antimatter.util.Utils) Blocks(net.minecraft.block.Blocks) ItemStack(net.minecraft.item.ItemStack) Tier(muramasa.antimatter.machine.Tier) Map(java.util.Map) CoverStack(muramasa.antimatter.cover.CoverStack) TileEntity(net.minecraft.tileentity.TileEntity) ITEM_HANDLER_CAPABILITY(net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) Ref(trinsdar.gt4r.Ref) BlockState(net.minecraft.block.BlockState) ItemEntity(net.minecraft.entity.item.ItemEntity) TileEntity(net.minecraft.tileentity.TileEntity) ItemEntity(net.minecraft.entity.item.ItemEntity) BlockState(net.minecraft.block.BlockState) TileEntityMachine(muramasa.antimatter.tile.TileEntityMachine) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Example 2 with Tier

use of muramasa.antimatter.machine.Tier in project AntimatterAPI by GregTech-Intergalactical.

the class Machine method addData.

protected void addData(Object... data) {
    List<Tier> tiers = new ObjectArrayList<>();
    Set<MachineFlag> flags = new ObjectOpenHashSet<>();
    for (Object o : data) {
        if (o instanceof RecipeMap) {
            recipeMap = (RecipeMap<?>) o;
            flags.add(RECIPE);
        }
        if (o instanceof Tier)
            tiers.add((Tier) o);
        if (o instanceof MachineFlag)
            flags.add((MachineFlag) o);
        if (o instanceof Texture)
            baseTexture = (Texture) o;
        if (o instanceof ItemGroup)
            group = (ItemGroup) o;
    // if (data[i] instanceof ITextureHandler) baseData = ((ITextureHandler) data[i]);
    }
    setTiers(tiers.size() > 0 ? tiers.toArray(new Tier[0]) : Tier.getStandard());
    addFlags(flags.toArray(new MachineFlag[0]));
}
Also used : MachineFlag(muramasa.antimatter.machine.MachineFlag) ObjectOpenHashSet(it.unimi.dsi.fastutil.objects.ObjectOpenHashSet) ItemGroup(net.minecraft.item.ItemGroup) ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) Tier(muramasa.antimatter.machine.Tier) IAntimatterObject(muramasa.antimatter.registration.IAntimatterObject) Texture(muramasa.antimatter.texture.Texture) RecipeMap(muramasa.antimatter.recipe.RecipeMap)

Example 3 with Tier

use of muramasa.antimatter.machine.Tier in project AntimatterAPI by GregTech-Intergalactical.

the class GuiData method add.

public GuiData add(String key, SlotData slot) {
    // TODO figure out better way to do this
    Tier tier = AntimatterAPI.get(Tier.class, key);
    if (tier != null && tier.getVoltage() > highestTier.getVoltage())
        highestTier = tier;
    COUNT_LOOKUP.addTo(slot.getType(), 1);
    if (SLOT_LOOKUP.containsKey(key)) {
        SLOT_LOOKUP.get(key).add(slot);
    } else {
        List<SlotData> list = new ObjectArrayList<>();
        list.add(slot);
        SLOT_LOOKUP.put(key, list);
    }
    return this;
}
Also used : Tier(muramasa.antimatter.machine.Tier)

Example 4 with Tier

use of muramasa.antimatter.machine.Tier in project AntimatterAPI by GregTech-Intergalactical.

the class Machine method getTextures.

public List<Texture> getTextures() {
    List<Texture> textures = new ObjectArrayList<>();
    for (Tier tier : getTiers()) {
        // textures.addAll(Arrays.asList(baseHandler.getBase(this, tier)));
        textures.add(getBaseTexture(tier));
    }
    textures.addAll(Arrays.asList(getOverlayTextures(MachineState.IDLE)));
    textures.addAll(Arrays.asList(getOverlayTextures(MachineState.ACTIVE)));
    return textures;
}
Also used : ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) Tier(muramasa.antimatter.machine.Tier) Texture(muramasa.antimatter.texture.Texture)

Aggregations

Tier (muramasa.antimatter.machine.Tier)4 ObjectArrayList (it.unimi.dsi.fastutil.objects.ObjectArrayList)2 Texture (muramasa.antimatter.texture.Texture)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ObjectOpenHashSet (it.unimi.dsi.fastutil.objects.ObjectOpenHashSet)1 Map (java.util.Map)1 CoverStack (muramasa.antimatter.cover.CoverStack)1 CoverTiered (muramasa.antimatter.cover.CoverTiered)1 MachineFlag (muramasa.antimatter.machine.MachineFlag)1 RecipeMap (muramasa.antimatter.recipe.RecipeMap)1 IAntimatterObject (muramasa.antimatter.registration.IAntimatterObject)1 TileEntityMachine (muramasa.antimatter.tile.TileEntityMachine)1 Utils (muramasa.antimatter.util.Utils)1 BlockState (net.minecraft.block.BlockState)1 Blocks (net.minecraft.block.Blocks)1 ItemEntity (net.minecraft.entity.item.ItemEntity)1 ItemGroup (net.minecraft.item.ItemGroup)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 Direction (net.minecraft.util.Direction)1