net.minecraft.entity.item.EntityEnderCrystal Java Examples

The following examples show how to use net.minecraft.entity.item.EntityEnderCrystal. 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: NoDesyncModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void receivePacket(EventReceivePacket event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        if (event.getPacket() instanceof SPacketSoundEffect) {
            final SPacketSoundEffect packet = (SPacketSoundEffect) event.getPacket();
            if (packet.getCategory() == SoundCategory.BLOCKS && packet.getSound() == SoundEvents.ENTITY_GENERIC_EXPLODE) {
                for (Entity e : Minecraft.getMinecraft().world.loadedEntityList) {
                    if (e != null && e instanceof EntityEnderCrystal) {
                        if (e.getDistance(packet.getX(), packet.getY(), packet.getZ()) <= 6.0f) {
                            e.setDead();
                        }
                    }
                }
            }
        }
    }
}
 
Example #2
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
 
Example #3
Source File: ActivationRange.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
/**
 * These entities are excluded from Activation range checks.
 *
 * @param entity
 * @return boolean If it should always tick.
 */
public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config) {
    if (config == null && DimensionManager.getWorld(0) != null) {
        config = DimensionManager.getWorld(0).spigotConfig;
    } else {
        return true;
    }

    return ((entity.activationType == 3 && config.miscActivationRange == 0)
            || (entity.activationType == 2 && config.animalActivationRange == 0)
            || (entity.activationType == 1 && config.monsterActivationRange == 0)
            || entity instanceof EntityPlayer
            || entity instanceof EntityThrowable
            || entity instanceof MultiPartEntityPart
            || entity instanceof EntityWither
            || entity instanceof EntityFireball
            || entity instanceof EntityFallingBlock
            || entity instanceof EntityWeatherEffect
            || entity instanceof EntityTNTPrimed
            || entity instanceof EntityEnderCrystal
            || entity instanceof EntityFireworkRocket
            || (entity.getClass().getSuperclass() == Entity.class && !entity.isCreatureType(EnumCreatureType.CREATURE, false))
            && !entity.isCreatureType(EnumCreatureType.AMBIENT, false) && !entity.isCreatureType(EnumCreatureType.MONSTER, false)
            && !entity.isCreatureType(EnumCreatureType.WATER_CREATURE, false)
    );
}
 
Example #4
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage, boolean cancelOnZeroDamage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (cancelOnZeroDamage && event.getDamage() == 0);
}
 
Example #5
Source File: MetaTileEntityMagicEnergyAbsorber.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void update() {
    super.update();
    if (getWorld().isRemote)
        return;
    if (!(getWorld().provider instanceof WorldProviderEnd)) {
        return; //don't try to do anything outside end dimension
    }
    if (getTimer() % 20 == 0) {
        updateDragonEggStatus();
    }
    if (getTimer() % 200 == 0) {
        updateConnectedCrystals();
    }
    int totalEnergyGeneration = 0;
    for (int connectedCrystalId : connectedCrystalsIds.toArray()) {
        //since we don't check quite often, check twice before outputting energy
        if (getWorld().getEntityByID(connectedCrystalId) instanceof EntityEnderCrystal) {
            totalEnergyGeneration += hasDragonEggAmplifier ? 128 : 32;
        }
    }
    if (totalEnergyGeneration > 0) {
        energyContainer.changeEnergy(totalEnergyGeneration);
    }
    setActive(totalEnergyGeneration > 0);
}
 
Example #6
Source File: MetaTileEntityMagicEnergyAbsorber.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void resetConnectedEnderCrystals() {
    for (int connectedEnderCrystal : connectedCrystalsIds.toArray()) {
        EntityEnderCrystal entityEnderCrystal = (EntityEnderCrystal) getWorld().getEntityByID(connectedEnderCrystal);
        if (entityEnderCrystal != null && getPos().equals(entityEnderCrystal.getBeamTarget())) {
            //on removal, reset ender crystal beam location so somebody can use it
            entityEnderCrystal.setBeamTarget(null);
        }
    }
    connectedCrystalsIds.clear();
}
 
Example #7
Source File: MetaTileEntityMagicEnergyAbsorber.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void updateConnectedCrystals() {
    this.connectedCrystalsIds.clear();
    final double maxDistance = 64 * 64;
    List<EntityEnderCrystal> enderCrystals = Arrays.stream(BiomeEndDecorator.getSpikesForWorld(getWorld()))
        .flatMap(endSpike -> getWorld().getEntitiesWithinAABB(EntityEnderCrystal.class, endSpike.getTopBoundingBox()).stream())
        .filter(crystal -> crystal.getDistanceSq(getPos()) < maxDistance)
        .collect(Collectors.toList());

    for (EntityEnderCrystal entityEnderCrystal : enderCrystals) {
        BlockPos beamTarget = entityEnderCrystal.getBeamTarget();
        if (beamTarget == null) {
            //if beam target is null, set ourselves as beam target
            entityEnderCrystal.setBeamTarget(getPos());
            this.connectedCrystalsIds.add(entityEnderCrystal.getEntityId());
        } else if (beamTarget.equals(getPos())) {
            //if beam target is ourselves, just add it to list
            this.connectedCrystalsIds.add(entityEnderCrystal.getEntityId());
        }
    }

    for (EntityDragon entityDragon : getWorld().getEntities(EntityDragon.class, EntitySelectors.IS_ALIVE)) {
        if (entityDragon.healingEnderCrystal != null && connectedCrystalsIds.contains(entityDragon.healingEnderCrystal.getEntityId())) {
            //if dragon is healing from crystal we draw energy from, reset it's healing crystal
            entityDragon.healingEnderCrystal = null;
            //if dragon is holding pattern, than deal damage and set it's phase to attack ourselves
            if (entityDragon.getPhaseManager().getCurrentPhase().getType() == PhaseList.HOLDING_PATTERN) {
                entityDragon.attackEntityFrom(DamageSource.causeExplosionDamage((EntityLivingBase) null), 10.0f);
                entityDragon.getPhaseManager().setPhase(PhaseList.CHARGING_PLAYER);
                ((PhaseChargingPlayer) entityDragon.getPhaseManager().getCurrentPhase()).setTarget(new Vec3d(getPos()));
            }
        }
    }
}
 
Example #8
Source File: AutoCrystalMod.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onTick(LocalPlayerUpdateEvent event) {
  if (getWorld() != null && getLocalPlayer() != null) {
    // Short-circuit if the timer check will fail
    if (!timer.hasTimeElapsed(delay.get())) {
      return;
    }
    
    Vec3d delta = new Vec3d(maxDistance.get(), maxDistance.get(), maxDistance.get());
    AxisAlignedBB bb =
        new AxisAlignedBB(
            getLocalPlayer().getPositionVector().subtract(delta),
            getLocalPlayer().getPositionVector().add(delta));
    getWorld()
        .getEntitiesWithinAABB(EntityEnderCrystal.class, bb)
        .stream()
        // Re-check timer, since it may have been reset in a previous iteration
        .filter(__ -> timer.hasTimeElapsed(delay.get()))
        .filter(
            e ->
                e.getPosition().getY() - getLocalPlayer().getPosition().getY() >= minHeight.get())
        .filter(playerWithinDistance(maxDistance.get()))
        .filter(playerWithinDistance(minDistance.get()).negate())
        .filter(e -> !checkEnemy.get() || enemyWithinDistance(e, maxEnemyDistance.get()))
        .forEach(
            e -> {
              getNetworkManager().sendPacket(new CPacketUseEntity(e));
              getNetworkManager().sendPacket(new CPacketAnimation(EnumHand.MAIN_HAND));
              timer.start();
            });
  }
}
 
Example #9
Source File: ActivationRange.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
/**
 * These entities are excluded from Activation range checks.
 *
 * @param entity
 * @param world
 * @return boolean If it should always tick.
 */
public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
{
    // Cauldron start - another fix for Proxy Worlds
    if (config == null && DimensionManager.getWorld(0) != null)
    {
        config = DimensionManager.getWorld(0).spigotConfig;
    }
    else
    {
        return true;
    }
    // Cauldron end

    if ( ( entity.activationType == 3 && config.miscActivationRange == 0 )
            || ( entity.activationType == 2 && config.animalActivationRange == 0 )
            || ( entity.activationType == 1 && config.monsterActivationRange == 0 )
            || (entity instanceof EntityPlayer && !(entity instanceof FakePlayer)) // Cauldron
            || entity instanceof EntityThrowable
            || entity instanceof EntityDragon
            || entity instanceof EntityDragonPart
            || entity instanceof EntityWither
            || entity instanceof EntityFireball
            || entity instanceof EntityWeatherEffect
            || entity instanceof EntityTNTPrimed
            || entity instanceof EntityFallingBlock // PaperSpigot - Always tick falling blocks
            || entity instanceof EntityEnderCrystal
            || entity instanceof EntityFireworkRocket
            || entity instanceof EntityVillager
            // Cauldron start - force ticks for entities with superclass of Entity and not a creature/monster
            || (entity.getClass().getSuperclass() == Entity.class && !entity.isCreatureType(EnumCreatureType.creature, false)
            && !entity.isCreatureType(EnumCreatureType.ambient, false) && !entity.isCreatureType(EnumCreatureType.monster, false)
            && !entity.isCreatureType(EnumCreatureType.waterCreature, false)))
    {
        return true;
    }

    return false;
}
 
Example #10
Source File: PlacedEndCrystalRenderer.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public void doRender(EntityEnderCrystal crystal, double x, double y, double z, float p_76986_8_, float partialTickTime) {
	float rotation = crystal.innerRotation + partialTickTime;
	OpenGLHelper.pushMatrix();
	OpenGLHelper.translate(x, y, z);
	bindTexture(TEXTURE);
	float f3 = MathHelper.sin(rotation * 0.2F) / 2.0F + 0.5F;
	f3 += f3 * f3;
	MODEL.render(crystal, 0.0F, rotation * 3.0F, f3 * 0.2F, 0.0F, 0.0F, 0.0625F);
	OpenGLHelper.popMatrix();
}
 
Example #11
Source File: CraftEnderCrystal.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftEnderCrystal(CraftServer server, EntityEnderCrystal entity) {
    super(server, entity);
}
 
Example #12
Source File: CraftEnderCrystal.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityEnderCrystal getHandle() {
    return (EntityEnderCrystal) entity;
}
 
Example #13
Source File: CraftEnderCrystal.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftEnderCrystal(CraftServer server, EntityEnderCrystal entity) {
    super(server, entity);
}
 
Example #14
Source File: CraftEnderCrystal.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityEnderCrystal getHandle() {
    return (EntityEnderCrystal) entity;
}
 
Example #15
Source File: ChamsModule.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
private boolean checkFilter(Entity entity) {
    boolean ret = false;

    if (entity == Minecraft.getMinecraft().player) {
        ret = false;
    }

    final Entity riding = Minecraft.getMinecraft().player.getRidingEntity();

    if (riding != null && entity == riding) {
        ret = false;
    }

    if (this.players.getValue() && entity instanceof EntityPlayer && entity != Minecraft.getMinecraft().player) {
        ret = true;
    }

    if (this.animals.getValue() && entity instanceof IAnimals) {
        ret = true;
    }

    if (this.mobs.getValue() && entity instanceof IMob) {
        ret = true;
    }

    if (this.vehicles.getValue() && (entity instanceof EntityBoat || entity instanceof EntityMinecart || entity instanceof EntityMinecartContainer)) {
        ret = true;
    }

    if (this.crystals.getValue() && entity instanceof EntityEnderCrystal) {
        ret = true;
    }

    if (entity instanceof EntityLivingBase) {
        final EntityLivingBase entityLiving = (EntityLivingBase) entity;

        if (entityLiving.ticksExisted <= 0) {
            ret = false;
        }
    }

    return ret;
}
 
Example #16
Source File: EntityEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onEntityInteractEvent(PlayerInteractEvent.EntityInteract event)
{
    EntityPlayer player = event.getEntityPlayer();
    ItemStack stack = player.getHeldItem(event.getHand());

    if (stack.isEmpty())
    {
        return;
    }

    Item item = stack.getItem();
    boolean isRemote = player.getEntityWorld().isRemote;

    // This needs to be in the event instead of itemInteractionForEntity() if we want it to also work in creative mode...
    // (Otherwise in creative mode the NBT will get wiped after the use when the item is restored)
    if (item == EnderUtilitiesItems.LIVING_MANIPULATOR)
    {
        if (event.getTarget() instanceof EntityLivingBase)
        {
            if (isRemote == false)
            {
                ((ItemLivingManipulator)item).handleInteraction(stack, player, (EntityLivingBase)event.getTarget());
            }

            event.setCanceled(true);
            event.setCancellationResult(EnumActionResult.SUCCESS);
        }
    }
    else if (item == EnderUtilitiesItems.MOB_HARNESS && event.getTarget() instanceof EntityLivingBase)
    {
        ((ItemMobHarness) item).handleInteraction(stack, player, event.getTarget());
        event.setCanceled(true);
        event.setCancellationResult(EnumActionResult.SUCCESS);
    }
    else if (item == EnderUtilitiesItems.ENDER_LASSO && event.getTarget() instanceof EntityLivingBase)
    {
        if (Configs.enderLassoAllowPlayers || EntityUtils.doesEntityStackHavePlayers(event.getTarget()) == false)
        {
            if (OwnerData.canAccessSelectedModule(stack, ModuleType.TYPE_LINKCRYSTAL, player) &&
                UtilItemModular.useEnderCharge(stack, ItemEnderLasso.ENDER_CHARGE_COST, false))
            {
                if (event.getTarget() instanceof EntityLiving && UtilItemModular.getInstalledModuleCount(stack, ModuleType.TYPE_MOBPERSISTENCE) > 0)
                {
                    EntityUtils.applyMobPersistence((EntityLiving)event.getTarget());
                }

                if (isRemote || TeleportEntity.teleportEntityUsingModularItem(event.getTarget(), stack, true, true) != null)
                {
                    event.setCanceled(true);
                    event.setCancellationResult(EnumActionResult.SUCCESS);
                }
            }
        }
    }
    else if (item == EnderUtilitiesItems.PET_CONTRACT && event.getTarget() instanceof EntityLivingBase)
    {
        if (((ItemPetContract) stack.getItem()).itemInteractionForEntity(stack, player, (EntityLivingBase) event.getTarget(), event.getHand()))
        {
            event.setCanceled(true);
            event.setCancellationResult(EnumActionResult.SUCCESS);
        }
    }
    else if (WorldUtils.isEndDimension(player.getEntityWorld()) && event.getTarget() instanceof EntityEnderCrystal && isRemote == false)
    {
        if (item instanceof IChargeable)
        {
            IChargeable chargeable = (IChargeable)item;
            chargeable.addCharge(stack, chargeable.getCapacity(stack) >> 2, true);
        }
        else if (item == EnderUtilitiesItems.ENDER_PART && ((IModule) item).getModuleType(stack).equals(ModuleType.TYPE_ENDERCORE))
        {
            ItemEnderPart part = (ItemEnderPart) item;
            int tier = part.getModuleTier(stack);

            if (tier >= ItemEnderPart.ENDER_CORE_TYPE_INACTIVE_BASIC && tier <= ItemEnderPart.ENDER_CORE_TYPE_INACTIVE_ADVANCED)
            {
                part.activateEnderCore(stack);
            }
        }
    }
}
 
Example #17
Source File: TileEntityEnergyBridge.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private boolean isStructureValid(World world, BlockPos center, Type masterType)
{
    BlockInfo[] structure = this.getStructure(masterType);
    boolean isValid = false;

    for (BlockInfo info : structure)
    {
        BlockPos posTmp = center.add(info.getPos());
        IBlockState state = world.getBlockState(posTmp);

        if (state.getBlock() != EnderUtilitiesBlocks.ENERGY_BRIDGE ||
            state.getActualState(world, posTmp).withProperty(BlockEnergyBridge.ACTIVE, false) != info.getBlockState())
        {
            return false;
        }
    }

    if (masterType == Type.TRANSMITTER)
    {
        double xd = center.getX();
        double yd = center.getY();
        double zd = center.getZ();
        double d = 1.0d;
        List<EntityEnderCrystal> list = world.getEntitiesWithinAABB(EntityEnderCrystal.class,
                new AxisAlignedBB(xd - d, yd - d, zd - d, xd + d, yd + d, zd + d));

        if (list.size() >= 1)
        {
            isValid = true;
        }
    }
    else
    {
        isValid = true;
    }

    // Our machine blocks are all in the right configuration, now just check that there are no other obstructing blocks in the area
    if (isValid)
    {
        return this.isObstructed(world, center, masterType) == false;
    }

    return false;
}