Search in sources :

Example 6 with IConveyorTile

use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile in project ImmersiveEngineering by BluSunrize.

the class ConveyorSplit method onEntityCollision.

@Override
public void onEntityCollision(TileEntity tile, Entity entity, EnumFacing facing) {
    if (!isActive(tile))
        return;
    EnumFacing redirect = null;
    if (entity != null && !entity.isDead) {
        String nbtKey = "immersiveengineering:conveyorDir" + Integer.toHexString(tile.getPos().hashCode());
        if (entity.getEntityData().hasKey(nbtKey))
            redirect = EnumFacing.values()[entity.getEntityData().getInteger(nbtKey)];
        else {
            redirect = this.outputFace;
            entity.getEntityData().setInteger(nbtKey, redirect.ordinal());
            BlockPos nextPos = tile.getPos().offset(this.outputFace.getOpposite());
            if (tile.getWorld().isBlockLoaded(nextPos)) {
                TileEntity nextTile = tile.getWorld().getTileEntity(nextPos);
                if (!(nextTile instanceof IConveyorTile))
                    this.outputFace = outputFace.getOpposite();
                else if (((IConveyorTile) nextTile).getFacing() != this.outputFace)
                    this.outputFace = outputFace.getOpposite();
            }
        }
    }
    super.onEntityCollision(tile, entity, facing);
    if (redirect != null) {
        String nbtKey = "immersiveengineering:conveyorDir" + Integer.toHexString(tile.getPos().hashCode());
        BlockPos nextPos = tile.getPos().offset(redirect);
        double distNext = Math.abs((redirect.getAxis() == Axis.Z ? nextPos.getZ() : nextPos.getX()) + .5 - (redirect.getAxis() == Axis.Z ? entity.posZ : entity.posX));
        double treshold = .4;
        boolean contact = distNext < treshold;
        if (contact)
            entity.getEntityData().removeTag(nbtKey);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) IConveyorTile(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile)

Example 7 with IConveyorTile

use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile in project ImmersiveEngineering by BluSunrize.

the class ConveyorVertical method isInwardConveyor.

protected boolean isInwardConveyor(TileEntity tile, EnumFacing f) {
    TileEntity te = tile.getWorld().getTileEntity(tile.getPos().offset(f));
    if (te instanceof IConveyorTile) {
        IConveyorBelt sub = ((IConveyorTile) te).getConveyorSubtype();
        if (sub != null)
            for (EnumFacing f2 : sub.sigTransportDirections(te, ((IConveyorTile) te).getFacing())) if (f2 == EnumFacing.UP)
                break;
            else if (f == f2.getOpposite())
                return true;
    }
    te = tile.getWorld().getTileEntity(tile.getPos().add(0, -1, 0).offset(f));
    if (te instanceof IConveyorTile) {
        IConveyorBelt sub = ((IConveyorTile) te).getConveyorSubtype();
        if (sub != null) {
            int b = 0;
            for (EnumFacing f2 : sub.sigTransportDirections(te, ((IConveyorTile) te).getFacing())) {
                if (f == f2.getOpposite())
                    b++;
                else if (EnumFacing.UP == f2)
                    b++;
                if (b == 2)
                    return true;
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) IConveyorBelt(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt) IConveyorTile(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile)

Example 8 with IConveyorTile

use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile in project ImmersiveEngineering by BluSunrize.

the class ConveyorDrop method handleInsertion.

@Override
public void handleInsertion(TileEntity tile, EntityItem entity, EnumFacing facing, ConveyorDirection conDir, double distX, double distZ) {
    BlockPos posDown = tile.getPos().down();
    TileEntity inventoryTile = tile.getWorld().getTileEntity(posDown);
    boolean contact = Math.abs(facing.getAxis() == Axis.Z ? (tile.getPos().getZ() + .5 - entity.posZ) : (tile.getPos().getX() + .5 - entity.posX)) < .2;
    if (contact && inventoryTile != null && !(inventoryTile instanceof IConveyorTile)) {
        if (!tile.getWorld().isRemote) {
            ItemStack stack = entity.getItem();
            if (!stack.isEmpty()) {
                ItemStack ret = ApiUtils.insertStackIntoInventory(inventoryTile, stack, EnumFacing.UP);
                if (ret.isEmpty())
                    entity.setDead();
                else if (ret.getCount() < stack.getCount())
                    entity.setItem(ret);
            }
        }
    } else if (contact && isEmptySpace(tile.getWorld(), posDown, inventoryTile)) {
        entity.motionX = 0;
        entity.motionZ = 0;
        entity.setPosition(tile.getPos().getX() + .5, tile.getPos().getY() - .5, tile.getPos().getZ() + .5);
        if (!(inventoryTile instanceof IConveyorTile))
            ConveyorHandler.revertMagnetSupression(entity, (IConveyorTile) tile);
    } else
        super.handleInsertion(tile, entity, facing, conDir, distX, distZ);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) IConveyorTile(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile)

Example 9 with IConveyorTile

use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile in project ImmersiveEngineering by BluSunrize.

the class EnderIOHelper method init.

@Override
public void init() {
    ChemthrowerHandler.registerEffect("nutrient_distillation", new ChemthrowerEffect_Potion(null, 0, MobEffects.NAUSEA, 80, 1));
    ChemthrowerHandler.registerEffect("liquid_sunshine", new ChemthrowerEffect_Potion(null, 0, new PotionEffect(MobEffects.GLOWING, 200, 0), new PotionEffect(MobEffects.LEVITATION, 40, 0)));
    ChemthrowerHandler.registerEffect("cloud_seed_concentrated", new ChemthrowerEffect_Potion(null, 0, MobEffects.BLINDNESS, 40, 0));
    ChemthrowerHandler.registerEffect("vapor_of_levity", new ChemthrowerEffect_Potion(null, 0, MobEffects.LEVITATION, 80, 2));
    ConveyorHandler.registerMagnetSupression(new BiConsumer<Entity, IConveyorTile>() {

        @Override
        public void accept(Entity entity, IConveyorTile iConveyorTile) {
            if (entity instanceof EntityItem) {
                NBTTagCompound data = entity.getEntityData();
                long pos = ((TileEntity) iConveyorTile).getPos().toLong();
                if (!data.hasKey(EIO_MAGNET_NBT) || data.getLong(EIO_MAGNET_NBT) != pos)
                    data.setLong(EIO_MAGNET_NBT, pos);
            }
        }
    }, new BiConsumer<Entity, IConveyorTile>() {

        @Override
        public void accept(Entity entity, IConveyorTile iConveyorTile) {
            if (entity instanceof EntityItem)
                entity.getEntityData().removeTag(EIO_MAGNET_NBT);
        }
    });
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) PotionEffect(net.minecraft.potion.PotionEffect) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ChemthrowerEffect_Potion(blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Potion) IConveyorTile(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

IConveyorTile (blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile)9 TileEntity (net.minecraft.tileentity.TileEntity)7 BlockPos (net.minecraft.util.math.BlockPos)4 EntityItem (net.minecraft.entity.item.EntityItem)3 ItemStack (net.minecraft.item.ItemStack)3 EnumFacing (net.minecraft.util.EnumFacing)3 IConveyorBelt (blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 Vec3d (net.minecraft.util.math.Vec3d)2 ChemthrowerEffect_Potion (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Potion)1 ConveyorChuteAluminum (blusunrize.immersiveengineering.common.blocks.metal.conveyors.ConveyorChute.ConveyorChuteAluminum)1 ConveyorChuteCopper (blusunrize.immersiveengineering.common.blocks.metal.conveyors.ConveyorChute.ConveyorChuteCopper)1 ConveyorChuteIron (blusunrize.immersiveengineering.common.blocks.metal.conveyors.ConveyorChute.ConveyorChuteIron)1 ConveyorChuteSteel (blusunrize.immersiveengineering.common.blocks.metal.conveyors.ConveyorChute.ConveyorChuteSteel)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 PotionEffect (net.minecraft.potion.PotionEffect)1