codechicken.lib.vec.BlockCoord Java Examples

The following examples show how to use codechicken.lib.vec.BlockCoord. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChunkLoaderManager.java    From ChickenChunks with MIT License 6 votes vote down vote up
public void revive(World world) {
    HashSet<BlockCoord> coords = dormantLoaders.get(CommonUtils.getDimension(world));
    if (coords == null)
        return;

    //addChunkLoader will add to the coord set if we are dormant
    ArrayList<BlockCoord> verifyCoords = new ArrayList<BlockCoord>(coords);
    coords.clear();

    for (BlockCoord coord : verifyCoords) {
        reviving = true;
        TileEntity tile = world.getTileEntity(coord.x, coord.y, coord.z);
        reviving = false;
        if (tile instanceof IChickenChunkLoader) {
            ChunkLoaderManager.addChunkLoader((IChickenChunkLoader) tile);
        }
    }
}
 
Example #2
Source File: ItemBlockChiselTorchPart.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
public boolean placePart(World world, BlockCoord pos, ItemStack item, int side, boolean doPlace) {
	TileMultipart tile = TileMultipart.getOrConvertTile(world, pos);
	if (tile == null) {
		return false;
	}
	TMultiPart part = createMultiPart(world, pos, item, side);
	if (part == null) {
		return false;
	}
	if (tile.canAddPart(part)) {
		if (doPlace) {
			TileMultipart.addPart(world, pos, part);
		}
		return true;
	}
	return false;
}
 
Example #3
Source File: RedstoneEtherFrequency.java    From WirelessRedstone with MIT License 6 votes vote down vote up
public void remTransmitter(World world, BlockCoord node, int dimension)
{
    if(useTemporarySet)
    {
        nodetrackers.get(dimension).temporarySet.add(new DelayedModification(node, 2));
        return;
    }
    
    Boolean wason = nodetrackers.get(dimension).transmittermap.get(node);
    nodetrackers.get(dimension).transmittermap.remove(node);

    if(wason != null && wason)
    {
        decrementActiveTransmitters(dimension);
        nodetrackers.get(dimension).setDirty();
    }
}
 
Example #4
Source File: MovementHandlerFMP.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Priority(PriorityEnum.OVERRIDE)
public BlockMovementType getMovementType(World world, int x, int y, int z, ForgeDirection side, IMovement movement) {

    TileMultipart tmp = TileMultipart.getTile(world, new BlockCoord(x, y, z));
    if (tmp == null)
        return null;

    for (TMultiPart p : tmp.jPartList()) {
        if (p instanceof TSlottedPart) {
            int slot = ((TSlottedPart) p).getSlotMask();
            if (slot == PartMap.face(side.ordinal()).mask && (p instanceof FaceMicroblock || p instanceof HollowMicroblock)) {
                if (((CommonMicroblock) p).getSize() == 1)
                    return BlockMovementType.UNMOVABLE;
            }
        }
    }

    return null;
}
 
Example #5
Source File: FrameMovementRegistry.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
public List<IFrame> findFrames(World world, int x, int y, int z) {

    if (world == null)
        return null;

    List<IFrame> l = new ArrayList<IFrame>();

    Block b = world.getBlock(x, y, z);
    if (b instanceof IFrame)
        l.add((IFrame) b);

    TileEntity te = world.getTileEntity(x, y, z);
    if (te != null && te instanceof IFrame)
        l.add((IFrame) te);

    TileMultipart tmp = TileMultipart.getTile(world, new BlockCoord(x, y, z));
    if (tmp != null)
        for (TMultiPart p : tmp.jPartList())
            if (p instanceof IFrame)
                l.add((IFrame) p);// FIXME actual multipart handling

    return l;
}
 
Example #6
Source File: ItemPartFrame.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
public TMultiPart newPart(ItemStack item, EntityPlayer player, World world, BlockCoord loc, int side, Vector3 hit) {

    NBTTagCompound tag = item.getTagCompound();

    if (tag == null)
        return null;
    if (!tag.hasKey("modifiers"))
        return null;

    NBTTagList l = tag.getTagList("modifiers", new NBTTagString().getId());
    List<IFrameModifier> mods = new ArrayList<IFrameModifier>();
    for (int i = 0; i < l.tagCount(); i++) {
        IFrameModifier mod = FrameModifierRegistry.instance().findModifier(l.getStringTagAt(i));
        if (mod != null)
            mods.add(mod);
    }

    return FrameFactory.createFrame(PartFrame.class, mods);
}
 
Example #7
Source File: RedstoneEtherServer.java    From WirelessRedstone with MIT License 6 votes vote down vote up
private void entityJamTest(World world)
{
    if(world.getTotalWorldTime() % 10 != 0)
        return;
    
    int dimension = CommonUtils.getDimension(world);
    for(Iterator<BlockCoord> iterator = ethers.get(dimension).jammerset.iterator(); iterator.hasNext();)
    {
        BlockCoord jammer = iterator.next();
        List<Entity> entitiesinrange = world.getEntitiesWithinAABBExcludingEntity(null, AxisAlignedBB.getBoundingBox(jammer.x-9.5, jammer.y-9.5, jammer.z-9.5, jammer.x+10.5, jammer.y+10.5, jammer.z+10.5));
        for(Iterator<Entity> iterator2 = entitiesinrange.iterator(); iterator2.hasNext();)
        {
            Entity entity = iterator2.next();
            if(!(entity instanceof EntityLivingBase))
                continue;
            
            if(entity instanceof EntityPlayer)
                if(isPlayerJammed((EntityPlayer)entity))
                    continue;
            
            jamEntitySometime((EntityLivingBase) entity);
        }
    }
}
 
Example #8
Source File: RedstoneEtherServer.java    From WirelessRedstone with MIT License 6 votes vote down vote up
public BlockCoord getClosestJammer(BlockCoord node, int dimension)
{
    BlockCoord closestjammer = null;
    double closestdist = jammerrangePow2;
    for(Iterator<BlockCoord> iterator = ethers.get(dimension).jammerset.iterator(); iterator.hasNext();)
    {
        BlockCoord jammer = iterator.next();
        double distance = pythagorasPow2(jammer, node);
        if(distance < closestdist)
        {
            closestjammer = jammer;
            closestdist = distance;
        }
    }
    return closestjammer;
}
 
Example #9
Source File: ChunkLoaderManager.java    From ChickenChunks with MIT License 6 votes vote down vote up
public void addChunkLoader(IChickenChunkLoader loader) {
    if (reviving)
        return;

    int dim = CommonUtils.getDimension(loader.getWorld());
    if (dormant) {
        HashSet<BlockCoord> coords = dormantLoaders.get(dim);
        if (coords == null)
            dormantLoaders.put(dim, coords = new HashSet<BlockCoord>());
        coords.add(loader.getPosition());
    } else {
        forcedChunksByLoader.put(loader, new HashSet<ChunkCoordIntPair>());
        forceChunks(loader, dim, loader.getChunks());
    }
    setDirty();
}
 
Example #10
Source File: RedstoneEtherServer.java    From WirelessRedstone with MIT License 6 votes vote down vote up
public void verifyChunkTransmitters(World world, int chunkx, int chunkz)
{
    int dimension = CommonUtils.getDimension(world);
    DimensionalEtherHash ether = ethers.get(dimension);
    int blockxmin = chunkx * 16;
    int blockxmax = blockxmin + 15;
    int blockzmin = chunkz * 16;
    int blockzmax = blockzmin + 15;
    
    ArrayList<BlockCoord> transmittingblocks = new ArrayList<BlockCoord>(ether.transmittingblocks.keySet());
    
    for(BlockCoord node : transmittingblocks)
    {            
        if(node.x >= blockxmin && node.x <= blockxmax && node.z >= blockzmin && node.z <= blockzmax)
        {
            TileEntity tile = RedstoneEther.getTile(world, node);
            int freq = ether.transmittingblocks.get(node).freq;
            if(tile == null || !(tile instanceof ITileWireless) || ((ITileWireless)tile).getFreq() != freq)
            {
                remTransmitter(world, node.x, node.y, node.z, freq);
                System.out.println("Removed Badly Synced node at:"+node.x+","+node.y+","+node.z+" on "+freq+" in dim"+dimension);
            }
        }
    }
}
 
Example #11
Source File: WirelessPart.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public boolean dropIfCantStay() {
    BlockCoord pos = new BlockCoord(tile()).offset(side());
    if (!world().isSideSolid(pos.x, pos.y, pos.z, ForgeDirection.getOrientation(side() ^ 1))) {
        drop();
        return true;
    }
    return false;
}
 
Example #12
Source File: RedstoneEtherServer.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void jamNode(World world, BlockCoord node, int dimension, int freq)
{        
    ethers.get(dimension).jammednodes.put(node, getRandomTimeout(world.rand));

    freqarray[freq].remTransmitter(world, node, dimension);
    freqarray[freq].remReceiver(world, node, dimension);
}
 
Example #13
Source File: RedstoneEtherServerAddons.java    From WirelessRedstone with MIT License 5 votes vote down vote up
private void updatePlayerMapData(EntityPlayer player, World world, MapData mapdata, Map<BlockCoord, TXNodeInfo> txnodes, Set<WirelessTransmittingDevice> devices) {
    TreeSet<FreqCoord> mnodes = new TreeSet<FreqCoord>();
    TreeSet<FreqCoord> mdevices = new TreeSet<FreqCoord>();

    int blockwidth = 1 << mapdata.scale;
    int minx = mapdata.xCenter - blockwidth * 64;
    int minz = mapdata.zCenter - blockwidth * 64;
    int maxx = mapdata.xCenter + blockwidth * 64;
    int maxz = mapdata.zCenter + blockwidth * 64;

    for (Entry<BlockCoord, TXNodeInfo> entry : txnodes.entrySet()) {
        BlockCoord node = entry.getKey();
        TXNodeInfo info = entry.getValue();
        if (info.on && node.x > minx && node.x < maxx && node.z > minz && node.z < maxz && RedstoneEther.server().canBroadcastOnFrequency(player, info.freq)) {
            mnodes.add(new FreqCoord(node.x - mapdata.xCenter, node.y, node.z - mapdata.zCenter, info.freq));
        }
    }

    for (Iterator<WirelessTransmittingDevice> iterator = devices.iterator(); iterator.hasNext(); ) {
        WirelessTransmittingDevice device = iterator.next();
        Vector3 pos = device.getPosition();
        if (pos.x > minx && pos.x < maxx && pos.z > minz && pos.z < maxz && RedstoneEther.server().canBroadcastOnFrequency(player, device.getFreq())) {
            mdevices.add(new FreqCoord((int) pos.x, (int) pos.y, (int) pos.z, device.getFreq()));
        }
    }

    WirelessMapNodeStorage mapnodes = getMapNodes(player);

    mapnodes.nodes = mnodes;
    mapnodes.devices = mdevices;
}
 
Example #14
Source File: BlockTranslocator.java    From Translocators with MIT License 5 votes vote down vote up
public static boolean canExistOnSide(World world, int x, int y, int z, int side, int meta) {
    BlockCoord pos = new BlockCoord(x, y, z).offset(side);
    switch (meta) {
        case 0:
            return world.getTileEntity(pos.x, pos.y, pos.z) instanceof IInventory;
        case 1:
            return world.getTileEntity(pos.x, pos.y, pos.z) instanceof IFluidHandler;
    }
    return false;
}
 
Example #15
Source File: ItemTranslocator.java    From Translocators with MIT License 5 votes vote down vote up
/**
 * Returns true if the given ItemBlock can be placed on the given side of the given block position.
 */
public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack) {
    BlockCoord pos = new BlockCoord(x, y, z).offset(side);
    if (world.getBlock(pos.x, pos.y, pos.z) == field_150939_a && world.getBlockMetadata(pos.x, pos.y, pos.z) != stack.getItemDamage())
        return false;

    switch (stack.getItemDamage()) {
        case 0:
            return world.getTileEntity(x, y, z) instanceof IInventory;
        case 1:
            return world.getTileEntity(x, y, z) instanceof IFluidHandler;
    }
    return false;
}
 
Example #16
Source File: RedstoneEtherServer.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void unjamTile(World world, int x, int y, int z)
{
    BlockCoord node = new BlockCoord(x, y, z);
    int dimension = CommonUtils.getDimension(world);
    
    Integer timeout = ethers.get(dimension).jammednodes.remove(node);
    
    if(timeout != null && timeout >= 0)//tile was jammed
    {
        ITileWireless tile = (ITileWireless) getTile(world, node);
        tile.unjamTile();
    }
}
 
Example #17
Source File: RedstoneEtherFrequency.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void addReceiver(World world, BlockCoord node, int dimension)
{
    if(useTemporarySet)
    {
        nodetrackers.get(dimension).temporarySet.add(new DelayedModification(node, 1));
        return;
    }
    
    nodetrackers.get(dimension).receiverset.add(node);
    updateReceiver(world, node, isOn());
    
}
 
Example #18
Source File: StickyHandlerFMP.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean isSideSticky(World world, int x, int y, int z, ForgeDirection side, IMovement movement) {

    TileMultipart tmp = TileMultipart.getTile(world, new BlockCoord(x, y, z));
    if (tmp == null)
        return false;

    boolean is = false;

    for (TMultiPart p : tmp.jPartList()) {
        if (p instanceof TSlottedPart) {
            int slot = ((TSlottedPart) p).getSlotMask();
            if (PartMap.face(side.ordinal()).mask == slot) {
                if (p instanceof ISticky) {
                    return ((ISticky) p).isSideSticky(world, x, y, z, side, movement);
                } else if (p instanceof FaceMicroblock || p instanceof HollowMicroblock) {
                    if (((CommonMicroblock) p).getSize() == 1)
                        return false;
                }
            } else if (slot == PartMap.CENTER.mask && p instanceof ISticky)
                return ((ISticky) p).isSideSticky(world, x, y, z, side, movement);
        } else if (p instanceof ISticky)
            is |= ((ISticky) p).isSideSticky(world, x, y, z, side, movement);
    }

    return is;
}
 
Example #19
Source File: NEISPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void handleMobSpawnerID(World world, BlockCoord coord, String mobtype) {
    TileEntity tile = world.getTileEntity(coord.pos());
    if (tile instanceof TileEntityMobSpawner) {
        ((TileEntityMobSpawner) tile).getSpawnerBaseLogic().setEntityName(mobtype);
        tile.markDirty();
        world.markBlockForUpdate(coord.pos());
    }
}
 
Example #20
Source File: RedstoneEtherFrequency.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void remReceiver(World world, BlockCoord node, int dimension)
{
    if(useTemporarySet)            
    {
        nodetrackers.get(dimension).temporarySet.add(new DelayedModification(node, 0));
        return;
    }
    
    nodetrackers.get(dimension).receiverset.remove(node);
}
 
Example #21
Source File: RedstoneEtherFrequency.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void setTransmitter(World world, BlockCoord node, int dimension, boolean on)
{
    if(useTemporarySet)            
    {
        nodetrackers.get(dimension).temporarySet.add(new DelayedModification(node, 4|(on ? 1 : 0)));
        return;
    }
    
    Boolean wasnodeon = nodetrackers.get(dimension).transmittermap.get(node);
    boolean newtransmitter = wasnodeon == null;// if the get returned null the transmitter needsadding to the list

    nodetrackers.get(dimension).transmittermap.put(node, on);

    if(!newtransmitter && (on == wasnodeon))
    {
        return;
    }

    if(newtransmitter)
    {
        if(on)
        {
            incrementActiveTransmitters(dimension);
            nodetrackers.get(dimension).setDirty();
        }
    }
    else
    {
        if(on)
        {
            incrementActiveTransmitters(dimension);
            nodetrackers.get(dimension).setDirty();
        }
        else
        {
            decrementActiveTransmitters(dimension);
            nodetrackers.get(dimension).setDirty();
        }
    }
}
 
Example #22
Source File: FMP.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public TMultiPart convert(World world, BlockCoord pos){
    if(!Config.convertMultipartsToBlocks) {
        if(world.getBlock(pos.x, pos.y, pos.z) == Blockss.pressureTube) return new PartPressureTube((TileEntityPressureTube)world.getTileEntity(pos.x, pos.y, pos.z));
        if(world.getBlock(pos.x, pos.y, pos.z) == Blockss.advancedPressureTube) return new PartAdvancedPressureTube((TileEntityPressureTube)world.getTileEntity(pos.x, pos.y, pos.z));
    }
    return null;
}
 
Example #23
Source File: RedstoneEtherFrequency.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void updateReceiver(World world, BlockCoord node, boolean on)
{
    TileEntity tileentity = RedstoneEther.getTile(world, node);
    if(tileentity instanceof ITileReceiver)
    {
        ((ITileReceiver)tileentity).setActive(on);
    }
    else
    {
        System.out.println("Null Receiver");
    }
}
 
Example #24
Source File: SaveManager.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void saveFreq(int freq, int activetransmitters, TreeMap<BlockCoord, Boolean> transmittermap, Map<Integer, Integer> dimensionHash)
{        
    try
    {            
        freqDimensionHashes[freq] = new ArrayList<Entry<Integer, Integer>>(dimensionHash.entrySet());
        hashChanged = true;
        
        int numnodes = 0;
        ArrayList<BlockCoord> nodes = new ArrayList<BlockCoord>(activetransmitters);
        
        for(Iterator<BlockCoord> iterator = transmittermap.keySet().iterator(); iterator.hasNext() && numnodes < activetransmitters;)
        {
            BlockCoord node = iterator.next();
            if(transmittermap.get(node))
            {
                nodes.add(node);
                numnodes++;
            }
        }
        
        if(numnodes == 0)
        {
            setFreqSector(freq, -1);
            return;
        }
        
        writeNodes(freq, numnodes, nodes);
    }
    catch(Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
Example #25
Source File: RedstoneEtherFrequency.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void putActiveTransmittersInList(int dimension, ArrayList<FreqCoord> txnodes)
{
    DimensionalNodeTracker nodetracker = nodetrackers.get(dimension);
    for(Iterator<BlockCoord> iterator = nodetracker.transmittermap.keySet().iterator(); iterator.hasNext();)
    {
        BlockCoord node = iterator.next();
        if(nodetracker.transmittermap.get(node))
            txnodes.add(new FreqCoord(node, freq));
    }
}
 
Example #26
Source File: RedstoneEtherServer.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public boolean isPointInAOEofJammer(Vector3 point, int dimension)
{
    for(Iterator<BlockCoord> iterator = ethers.get(dimension).jammerset.iterator(); iterator.hasNext();)
    {
        BlockCoord jammer = iterator.next();
        if(pythagorasPow2(jammer, point) < jammerrangePow2)
        {
            return true;
        }
    }
    return false;
}
 
Example #27
Source File: RedstoneEtherServer.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public boolean isNodeInAOEofJammer(BlockCoord node, int dimension)
{
    for(Iterator<BlockCoord> iterator = ethers.get(dimension).jammerset.iterator(); iterator.hasNext();)
    {
        BlockCoord jammer = iterator.next();
        if(pythagorasPow2(jammer, node) < jammerrangePow2)
        {
            return true;
        }
    }
    return false;
}
 
Example #28
Source File: RedstoneEtherServer.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void remTransmitter(World world, int x, int y, int z, int freq)
{
    if(freq == 0)
    {
        return;
    }

    int dimension = CommonUtils.getDimension(world);
    BlockCoord node = new BlockCoord(x, y, z);
    
    ethers.get(dimension).jammednodes.remove(node);
    ethers.get(dimension).transmittingblocks.remove(node);
    freqarray[freq].remTransmitter(world, node, dimension);
}
 
Example #29
Source File: RedstoneEtherServer.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void addReceiver(World world, int x, int y, int z, int freq)
{
    if(freq == 0)
        return;
    
    BlockCoord node = new BlockCoord(x, y, z);
    int dimension = CommonUtils.getDimension(world);
    
    if(isNodeInAOEofJammer(node, dimension))
    {
        jamNodeSometime(world, node, dimension, freq);
    }
    ethers.get(dimension).recievingblocks.put(node, freq);
    freqarray[freq].addReceiver(world, node, dimension);
}
 
Example #30
Source File: RedstoneEtherServer.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void remReceiver(World world, int x, int y, int z, int freq)
{
    if(freq == 0)
        return;

    int dimension = CommonUtils.getDimension(world);
    BlockCoord node = new BlockCoord(x, y, z);

    ethers.get(dimension).jammednodes.remove(node);    
    ethers.get(dimension).recievingblocks.remove(node);
    freqarray[freq].remReceiver(world, node, dimension);
}