net.minecraft.util.ChunkCoordinates Java Examples

The following examples show how to use net.minecraft.util.ChunkCoordinates. 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: EntityCamera.java    From LookingGlass with GNU General Public License v3.0 6 votes vote down vote up
private int updateTargetPosition(ChunkCoordinates target) {
	int x = target.posX;
	int y = target.posY;
	int z = target.posZ;
	if (!this.worldObj.getChunkFromBlockCoords(x, z).isEmpty()) {
		if (this.worldObj.getBlock(x, y, z).getBlocksMovement(this.worldObj, x, y, z)) {
			while (y > 0 && this.worldObj.getBlock(x, --y, z).getBlocksMovement(this.worldObj, x, y, z))
				;
			if (y == 0) y = target.posY;
			else ++y;
		} else {
			while (y < 256 && !this.worldObj.getBlock(x, ++y, z).getBlocksMovement(this.worldObj, x, y, z))
				;
			if (y == 256) y = target.posY;
		}
		return y;
	}
	return target.posY;
}
 
Example #2
Source File: AuraEffectHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static void doBlockEffects(AuraEffect effect, World worldObj, double x, double y, double z) {
    int count = effect.getBlockCount(worldObj.rand);

    ChunkCoordinates origin = new ChunkCoordinates((int) x, (int) y, (int) z);
    List<ChunkCoordinates> foundBlocks = new ArrayList<ChunkCoordinates>();
    int intRange = (int) effect.getRange();
    for (int i = 0; i < count; i++) {
        int xx = worldObj.rand.nextInt(intRange) - worldObj.rand.nextInt(intRange);
        int yy = worldObj.rand.nextInt(intRange) - worldObj.rand.nextInt(intRange);
        int zz = worldObj.rand.nextInt(intRange) - worldObj.rand.nextInt(intRange);

        ChunkCoordinates blockCC = new ChunkCoordinates((int) x + xx, (int) y + yy, (int) z + zz);
        if(foundBlocks.contains(blockCC)) {
            count++;
        } else {
            foundBlocks.add(blockCC);
            effect.doBlockEffect(origin, blockCC, worldObj);
        }
    }
}
 
Example #3
Source File: AuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void doBlockEffect(ChunkCoordinates originTile, ChunkCoordinates selectedBlock, World world) {
    Class animalClass = animalClasses[world.rand.nextInt(animalClasses.length)];
    EntityLivingBase animal;
    try {
        animal = (EntityLivingBase) animalClass.getConstructor(World.class).newInstance(world);
    } catch (Exception e) {
        return;
    }
    boolean canSpawn = setAndCheckPosition(animal, selectedBlock, world, true);
    if(canSpawn) {
        ChunkCoordinates pos = new ChunkCoordinates((int) animal.posX, (int) animal.posY, (int) animal.posZ);
        pos = iterateDown(pos, world);
        animal.setPosition(pos.posX + 0.5, pos.posY, pos.posZ + 0.5);
        world.spawnEntityInWorld(animal);
    }
}
 
Example #4
Source File: EntityAuraCore.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void readEntityFromNBT(NBTTagCompound compound) {
    super.readEntityFromNBT(compound);

    this.internalAuraList = new PrimalAspectList();

    ticksExisted = compound.getInteger("ticksExisted");
    NBTTagList list = compound.getTagList("auraList", compound.getId());
    for (int i = 0; i < list.tagCount(); i++) {
        NBTTagCompound cmp = list.getCompoundTagAt(i);
        if(cmp.hasKey("tag") && cmp.hasKey("amt")) {
            internalAuraList.add(Aspect.getAspect(cmp.getString("tag")), cmp.getInteger("amt"));
        }
    }
    if(compound.hasKey("activationVecX") && compound.hasKey("activationVecY") && compound.hasKey("activationVecZ")) {
        int x = compound.getInteger("activationVecX");
        int y = compound.getInteger("activationVecY");
        int z = compound.getInteger("activationVecZ");
        activationLocation = new ChunkCoordinates(x, y, z);
    }
    sendAspectData(electParliament());

    initGathering();

    blockCount = compound.getInteger("blockCount");
}
 
Example #5
Source File: RenderTileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void renderBlackHoleEffect(double x, double y, double z, TileEssentiaCompressor te) {
    ChunkCoordinates cc = new ChunkCoordinates((int) x, (int) y, (int) z);
    FXVortex v;
    if (ownedVortex.containsKey(cc)) {
        v = ownedVortex.get(cc);
    } else {
        v = new FXVortex(x, y, z, te);
        ownedVortex.put(cc, v);
        v.registered = true;
        EffectHandler.getInstance().registerVortex(v);
    }
    if(!v.registered) {
        EffectHandler.getInstance().registerVortex(v);
    }
    v.notify(System.currentTimeMillis());
}
 
Example #6
Source File: EntityPermNoClipItem.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void readEntityFromNBT(NBTTagCompound com) {
    super.readEntityFromNBT(com);

    this.fixPosX = com.getFloat("fX");
    this.fixPosY = com.getFloat("fY");
    this.fixPosZ = com.getFloat("fZ");

    this.masterX = com.getInteger("mX");
    this.masterY = com.getInteger("mY");
    this.masterZ = com.getInteger("mZ");

    getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherMasterId, new ChunkCoordinates(masterX, masterY, masterZ));
    ChunkCoordinates cc = new ChunkCoordinates(Float.floatToIntBits(fixPosX), Float.floatToIntBits(fixPosY), Float.floatToIntBits(fixPosZ));
    getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherFixedId, cc);
}
 
Example #7
Source File: TileAIShutdown.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void removeTrackedEntities(World world, int x, int y, int z) {
    ChunkCoordinates cc = new ChunkCoordinates(x, y, z);
    if(trackedEntities.containsKey(cc)) {
        for (AffectedEntity ae : trackedEntities.get(cc)) {
            for (Object objE : world.getLoadedEntityList()) {
                if(objE != null && objE instanceof EntityLiving &&
                        !((EntityLiving) objE).isDead &&
                        ((EntityLiving) objE).getUniqueID().equals(ae.eUUID)) {
                    ((EntityLiving) objE).tasks.taskEntries = ae.tasks;
                    ((EntityLiving) objE).targetTasks.taskEntries = ae.targetTasks;
                    injEntityLivingBase.setObject(objE);
                    injEntityLivingBase.setField("ignoreCollisions", false);
                    injEntityLivingBase.setObject(null);
                }
            }
        }
        trackedEntities.remove(new ChunkCoordinates(x, y, z));
    }
}
 
Example #8
Source File: ProxyWorldManager.java    From LookingGlass with GNU General Public License v3.0 6 votes vote down vote up
public static WorldView createWorldView(int dimid, ChunkCoordinates spawn, int width, int height) {
	if (ModConfigs.disabled) return null;
	if (!DimensionManager.isDimensionRegistered(dimid)) return null;

	WorldClient proxyworld = ProxyWorldManager.getProxyworld(dimid);
	if (proxyworld == null) return null;

	Collection<WorldView> worldviews = worldviewsets.get(dimid);
	if (worldviews == null) return null;

	WorldView view = new WorldView(proxyworld, spawn, width, height);

	// Initialize the view rendering system
	Minecraft mc = Minecraft.getMinecraft();
	EntityLivingBase backup = mc.renderViewEntity;
	mc.renderViewEntity = view.camera;
	view.getRenderGlobal().setWorldAndLoadRenderers(proxyworld);
	mc.renderViewEntity = backup;

	// Inform the server of the new view
	LookingGlassPacketManager.bus.sendToServer(PacketCreateView.createPacket(view));
	worldviews.add(view);
	return view;
}
 
Example #9
Source File: TileAIShutdown.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void updateEntity() {
    if(worldObj == null) return;
    ticksExisted++;

    if(!worldObj.isRemote) {
        ChunkCoordinates cc = getCoords();
        if (!trackedEntities.containsKey(cc)) trackedEntities.put(cc, Lists.<AffectedEntity>newLinkedList());

        if ((ticksExisted & 15) == 0) {
            killAI();
        }
        if (((ticksExisted & 7) == 0)) {
            handleIO();
        }
        if (((ticksExisted & 31) == 0)) {
            drainDefaultEssentia();
        }
    }

}
 
Example #10
Source File: EventHandlerEntity.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void on(LivingSpawnEvent.CheckSpawn event) {
    if(event.entityLiving.isCreatureType(EnumCreatureType.monster, false)) {
        double rangeSq = AuraEffects.LUX.getRange() * AuraEffects.LUX.getRange();
        Vector3 entityPos = MiscUtils.getPositionVector(event.entity);
        for(ChunkCoordinates luxPylons : registeredLuxPylons) {
            Vector3 pylon = Vector3.fromCC(luxPylons);
            if(entityPos.distanceSquared(pylon) <= rangeSq) {
                event.setResult(Event.Result.DENY);
                return;
            }
        }
    }
}
 
Example #11
Source File: PacketWorldInfo.java    From LookingGlass with GNU General Public License v3.0 5 votes vote down vote up
public static FMLProxyPacket createPacket(int dimension) {
	WorldServer world = MinecraftServer.getServer().worldServerForDimension(dimension);
	if (world == null) {
		LoggerUtils.warn("Server-side world for dimension %i is null!", dimension);
		return null;
	}
	ChunkCoordinates cc = world.provider.getSpawnPoint();
	int posX = cc.posX;
	int posY = cc.posY;
	int posZ = cc.posZ;
	int skylightSubtracted = world.skylightSubtracted;
	float thunderingStrength = world.thunderingStrength;
	float rainingStrength = world.rainingStrength;
	long worldTime = world.provider.getWorldTime();

	// This line may look like black magic (and, well, it is), but it's actually just returning a class reference for this class. Copy-paste safe.
	ByteBuf data = PacketHandlerBase.createDataBuffer((Class<? extends PacketHandlerBase>) new Object() {}.getClass().getEnclosingClass());

	data.writeInt(dimension);
	data.writeInt(posX);
	data.writeInt(posY);
	data.writeInt(posZ);
	data.writeInt(skylightSubtracted);
	data.writeFloat(thunderingStrength);
	data.writeFloat(rainingStrength);
	data.writeLong(worldTime);

	return buildPacket(data);
}
 
Example #12
Source File: CommandBaseAdv.java    From LookingGlass with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the given ICommandSender as a EntityPlayer or throw an exception.
 */
public static TileEntity getCommandSenderAsTileEntity(ICommandSender sender) {
	try {
		World world = sender.getEntityWorld();
		ChunkCoordinates coords = sender.getPlayerCoordinates();
		return world.getTileEntity(coords.posX, coords.posY, coords.posZ);
	} catch (Exception e) {
		throw new CommandException("Could not get tile entity");
	}
}
 
Example #13
Source File: BookMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(IItemPortalActivator target, ItemStack stack) {
	final ILinkInfo linkInfo = getLinkInfo(stack);
	if (linkInfo == null) return null;

	final String unlocalizedName = stack.getUnlocalizedName();
	final boolean isLinkbook = "item.myst.linkbook".equals(unlocalizedName);
	final boolean isAgebook = "item.myst.agebook".equals(unlocalizedName);

	Map<String, Object> result = Maps.newHashMap();

	result.put("type", isLinkbook? "link" : (isAgebook? "age" : "unknown"));
	result.put("destination", linkInfo.getDisplayName());
	result.put("dimension", linkInfo.getDimensionUID());

	final LinkPropertyAPI linkPropertiesApi = MystcraftAccess.linkPropertiesApi;
	if (linkPropertiesApi != null) {
		final Collection<String> allProperties = linkPropertiesApi.getLinkProperties();

		Set<String> flags = Sets.newHashSet();
		for (String flag : allProperties)
			if (linkInfo.getFlag(flag)) flags.add(flag);

		result.put("flags", flags);
	}

	{
		ChunkCoordinates coords = linkInfo.getSpawn();
		if (coords != null) result.put("spawn", Lists.newArrayList(coords.posX, coords.posY, coords.posZ));
	}

	result.put("spawnYaw", linkInfo.getSpawnYaw());

	return result;

}
 
Example #14
Source File: WorldView.java    From LookingGlass with GNU General Public License v3.0 5 votes vote down vote up
public WorldView(WorldClient worldObj, ChunkCoordinates coords, int width, int height) {
	this.width = width;
	this.height = height;
	this.worldObj = worldObj;
	this.coords = coords;
	this.camera = new EntityCamera(worldObj, coords);
	this.camerawrapper = new ViewCameraImpl(camera);
	this.renderGlobal = new RenderGlobal(Minecraft.getMinecraft());
	this.effectRenderer = new EffectRenderer(worldObj, Minecraft.getMinecraft().getTextureManager());
	// Technically speaking, this is poor practice as it leaks a reference to the view before it's done constructing.
	this.fbo = FrameBufferContainer.createNewFramebuffer(this, width, height);
}
 
Example #15
Source File: PacketCreateView.java    From LookingGlass with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handle(ByteBuf data, EntityPlayer player) {
	if (ModConfigs.disabled) return;
	int dim = data.readInt();
	int xPos = data.readInt();
	int yPos = data.readInt();
	int zPos = data.readInt();
	byte renderDistance = data.readByte();

	if (!DimensionManager.isDimensionRegistered(dim)) return;
	WorldServer world = MinecraftServer.getServer().worldServerForDimension(dim);
	if (world == null) return;
	int x;
	int y;
	int z;
	if (yPos < 0) {
		ChunkCoordinates c = world.getSpawnPoint();
		x = c.posX >> 4;
		y = c.posY >> 4;
		z = c.posZ >> 4;
	} else {
		x = xPos;
		y = yPos;
		z = zPos;
	}
	if (renderDistance > ModConfigs.renderDistance) renderDistance = ModConfigs.renderDistance;
	ChunkFinderManager.instance.addFinder(new ChunkFinder(new ChunkCoordinates(x, y, z), dim, world.getChunkProvider(), player, renderDistance));
	//TODO: Add to tracking list.  Send time/data updates at intervals. Keep in mind to catch player disconnects when tracking clients.
	//Register ChunkFinder, and support change of finder location.
	//TODO: This is a repeat of the handling of PacketRequestWorldInfo
	net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new ClientWorldInfoEvent(dim, (EntityPlayerMP) player));
	LookingGlassPacketManager.bus.sendTo(PacketWorldInfo.createPacket(dim), (EntityPlayerMP) player);
}
 
Example #16
Source File: AuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void doBlockEffect(ChunkCoordinates originTile, ChunkCoordinates selectedBlock, World world) {
    EntityBrainyZombie zombie = new EntityBrainyZombie(world);
    boolean canSpawn = setAndCheckPosition(zombie, selectedBlock, world, true) && zombie.getCanSpawnHere(); //Position for getCanSpawn here is updated.
    if(canSpawn) {
        ChunkCoordinates pos = new ChunkCoordinates((int) zombie.posX, (int) zombie.posY, (int) zombie.posZ);
        pos = iterateDown(pos, world);
        zombie.setPosition(pos.posX + 0.5, pos.posY, pos.posZ + 0.5);
        world.spawnEntityInWorld(zombie);
    }
}
 
Example #17
Source File: AuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void doEntityEffect(ChunkCoordinates originTile, Entity e) {
    EntityPlayer player = (EntityPlayer) e;

    for(Aspect a : Aspect.getPrimalAspects()) {
        if(a != null && e.worldObj.rand.nextInt(40) == 0) {
            if(e.worldObj.rand.nextInt(20) == 0) {
                //1 temp warp.
                Thaumcraft.addWarpToPlayer(player, 1, true);
            }
            ScanManager.checkAndSyncAspectKnowledge(player, a, 1);
        }
    }
}
 
Example #18
Source File: AuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void doEntityEffect(ChunkCoordinates originTile, Entity e) {
    EntityPlayer player = (EntityPlayer) e;

    if(player.getHeldItem() != null && player.getHeldItem().getItem() != null && player.getHeldItem().getItem() instanceof ItemWandCasting) {
        ItemStack wand = player.getHeldItem();
        ItemWandCasting wandCasting = (ItemWandCasting) wand.getItem();
        AspectList al = wandCasting.getAspectsWithRoom(wand);
        for(Aspect a : al.getAspects()) {
            if(a != null) wandCasting.addRealVis(wand, a, 4, true);
        }
    }
}
 
Example #19
Source File: TileAdditionalEldritchPortal.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void informSessionStart(EntityPlayer player) {
    if(trackedPortalActivity.containsKey(player)) {
        ExtendedChunkCoordinates tileCoords = trackedPortalActivity.get(player);
        trackedPortalActivity.remove(player);
        if(tileCoords != null) {
            ChunkCoordinates cc = tileCoords.coordinates;
            WorldServer ws = MinecraftServer.getServer().worldServerForDimension(tileCoords.dimId);
            ws.removeTileEntity(cc.posX, cc.posY, cc.posZ);
            ws.setBlockToAir(cc.posX, cc.posY, cc.posZ);
            ws.markBlockForUpdate(cc.posX, cc.posY, cc.posZ);
        }
    }
}
 
Example #20
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Vec3 getRelPedestalLoc(int pedestalId) {
    try {
        ChunkCoordinates cc = bufferedCCPedestals.get(pedestalId);
        return Vec3.createVectorHelper(xCoord - cc.posX, yCoord - cc.posY, zCoord - cc.posZ);
    } catch (Exception exc) {}
    return Vec3.createVectorHelper(0, 0, 0);
}
 
Example #21
Source File: AuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static ChunkCoordinates iterateDown(ChunkCoordinates pos, World world) {
    while(world.isAirBlock(pos.posX, pos.posY, pos.posZ)) {
        pos.posY -= 1;
    }
    pos.posY += 1;
    return pos;
}
 
Example #22
Source File: EntityAuraCore.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readSpawnData(ByteBuf buffer) {
    ticksExisted = buffer.readInt();

    activationLocation = new ChunkCoordinates();
    activationLocation.posX = buffer.readInt();
    activationLocation.posY = buffer.readInt();
    activationLocation.posZ = buffer.readInt();
}
 
Example #23
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void consumeEldritchEyes() {
    for (ChunkCoordinates cc : bufferedCCPedestals) {
        try {
            TilePedestal pedestal = (TilePedestal) worldObj.getTileEntity(cc.posX, cc.posY, cc.posZ);
            pedestal.setInventorySlotContents(0, null);
            PacketStartAnimation packet = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, cc.posX, cc.posY, cc.posZ);
            PacketHandler.INSTANCE.sendToAllAround(packet, getTargetPoint(32));
        } catch (Exception exc) {}
    }
}
 
Example #24
Source File: AuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void doEntityEffect(ChunkCoordinates originTile, Entity e) {
    if(e.worldObj.rand.nextInt(4) == 0) {
        EntityMob mob = (EntityMob) e;
        PotionEffect effect = mob.getActivePotionEffect(RegisteredPotions.ELDRITCH);

        if(effect != null && effect.getAmplifier() > 4) {
            EntityUtils.makeChampion(mob, false);
            mob.removePotionEffect(RegisteredPotions.ELDRITCH.getId());
        } else {
            mob.addPotionEffect(new PotionEffect(RegisteredPotions.ELDRITCH.getId(), MiscUtils.ticksForMinutes(1), effect == null ? 1 : effect.getAmplifier() + 1));
        }
    }
}
 
Example #25
Source File: TileAIShutdown.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void killAI() {
    ChunkCoordinates cc = getCoords();
    List objEntityList = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, BOX.copy().offset(xCoord, yCoord, zCoord));
    for (Object o : objEntityList) {
        if(o != null && o instanceof EntityLiving &&
                !((EntityLiving) o).isDead && canAffect((EntityLiving) o)) {
            EntityLiving el = (EntityLiving) o;
            if(storedAmount <= 0) return;
            AffectedEntity affected = removeAI(el);
            trackedEntities.get(cc).add(affected);
        }
    }
}
 
Example #26
Source File: FakeWorldTCGeneration.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public TileEntity getTileEntity(int x, int y, int z) {
    TileEntity te = getBlock(x, y, z).createTileEntity(null, getBlockMetadata(x, y, z));
    if(te == null) return null;
    ChunkCoordinates cc = new ChunkCoordinates(x, y, z);
    if(!gettedTE.containsKey(cc)) gettedTE.put(cc, te);
    te.setWorldObj(this);
    te.xCoord = x;
    te.yCoord = y;
    te.zCoord = z;
    return te;
}
 
Example #27
Source File: AuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void doEntityEffect(ChunkCoordinates originTile, Entity e) {
    if (e == null || !(e instanceof EntityLivingBase)) return;

    EntityLivingBase living = (EntityLivingBase) e;
    addOrExtendPotionEffect(potion, living, durationCap, addedDuration, amplifier);
}
 
Example #28
Source File: MiscUtils.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static List<ChunkCoordinates> getCoordinatesAround(ChunkCoordinates center) {
    List<ChunkCoordinates> coords = new ArrayList<ChunkCoordinates>();
    coords.add(new ChunkCoordinates(center.posX, center.posY, center.posZ));
    coords.add(new ChunkCoordinates(center.posX + 1, center.posY,     center.posZ));
    coords.add(new ChunkCoordinates(center.posX,     center.posY,     center.posZ + 1));
    coords.add(new ChunkCoordinates(center.posX - 1, center.posY,     center.posZ));
    coords.add(new ChunkCoordinates(center.posX,     center.posY,     center.posZ - 1));
    coords.add(new ChunkCoordinates(center.posX,     center.posY - 1, center.posZ));
    coords.add(new ChunkCoordinates(center.posX,     center.posY + 1, center.posZ));
    return coords;
}
 
Example #29
Source File: BlockEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int these, float are, float some, float variables) { //LUL side, hitx, hity, hitz
    if(world.isRemote) return false;
    TileEntity te = world.getTileEntity(x, y, z);
    if(te == null || !(te instanceof TileEssentiaCompressor)) return false;
    if(((TileEssentiaCompressor) te).isMultiblockFormed()) {
        if(!((TileEssentiaCompressor) te).isMasterTile()) {
            int yOffset = ((TileEssentiaCompressor) te).getMultiblockYIndex();
            return RegisteredBlocks.blockEssentiaCompressor.onBlockActivated(world, x, y - yOffset, z, player, these, are, some, variables);
        }
    } else {
        ItemStack heldItem = player.getHeldItem();
        if(heldItem != null && heldItem.getItem() instanceof ItemWandCasting &&
                ResearchManager.isResearchComplete(player.getCommandSenderName(), SimpleResearchItem.getFullName("ESSENTIA_COMPRESSOR"))) {
            ChunkCoordinates lowest = findLowestCompressorBlock(world, x, y, z);
            boolean canForm = lowest != null && isMuliblockPossible(world, lowest);
            if(canForm && ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsCompressorMultiblock, true)) {
                int multiblockID = TileEssentiaCompressor.getAndIncrementNewMultiblockId();
                TileEssentiaCompressor compressor = (TileEssentiaCompressor) world.getTileEntity(lowest.posX, lowest.posY, lowest.posZ);
                compressor.setInMultiblock(true, 0, multiblockID);
                PacketStartAnimation pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, lowest.posX, lowest.posY, lowest.posZ);
                NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, lowest.posX, lowest.posY, lowest.posZ, 32);
                PacketHandler.INSTANCE.sendToAllAround(pkt, point);
                compressor = (TileEssentiaCompressor) world.getTileEntity(lowest.posX, lowest.posY + 1, lowest.posZ);
                compressor.setInMultiblock(false, 1, multiblockID);
                pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, lowest.posX, lowest.posY + 1, lowest.posZ);
                point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, lowest.posX, lowest.posY + 1, lowest.posZ, 32);
                PacketHandler.INSTANCE.sendToAllAround(pkt, point);
                compressor = (TileEssentiaCompressor) world.getTileEntity(lowest.posX, lowest.posY + 2, lowest.posZ);
                compressor.setInMultiblock(false, 2, multiblockID);
                pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, lowest.posX, lowest.posY + 2, lowest.posZ);
                point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, lowest.posX, lowest.posY + 2, lowest.posZ, 32);
                PacketHandler.INSTANCE.sendToAllAround(pkt, point);
            }
        }
    }
    return false;
}
 
Example #30
Source File: TileAIShutdown.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean canAffect(EntityLiving el) {
    ChunkCoordinates cc = getCoords();
    if(!trackedEntities.containsKey(cc)) return false;
    UUID uu = el.getUniqueID();
    for (AffectedEntity ae : trackedEntities.get(cc)) {
        if(ae.eUUID.equals(uu)) return false;
    }
    return true;
}