use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IHackableEntity in project pnc-repressurized by TeamPneumatic.
the class RenderTarget method update.
public void update() {
stat.update();
stat.setTitle(entity.getName());
EntityPlayer player = FMLClientHandler.instance().getClient().player;
if (ticksExisted >= 30 && !didMakeLockSound) {
didMakeLockSound = true;
player.world.playSound(player.posX, player.posY, player.posZ, Sounds.HUD_ENTITY_LOCK, SoundCategory.PLAYERS, 0.1F, 1.0F, true);
}
boolean tagged = NBTUtil.getInteger(player.getItemStackFromSlot(EntityEquipmentSlot.HEAD), NBTKeys.PNEUMATIC_HELMET_DEBUGGING_DRONE) == entity.getEntityId();
circle1.setRenderingAsTagged(tagged);
circle2.setRenderingAsTagged(tagged);
circle1.update();
circle2.update();
for (IEntityTrackEntry tracker : trackEntries) {
tracker.update(entity);
}
isLookingAtTarget = isPlayerLookingAtTarget();
if (hackTime > 0) {
IHackableEntity hackableEntity = HackableHandler.getHackableForEntity(entity, PneumaticCraftRepressurized.proxy.getPlayer());
if (hackableEntity != null) {
// = Math.min(hackTime + 1, hackableEntity.getHackTime(entity, PneumaticCraft.proxy.getPlayer()));
hackTime++;
} else {
hackTime = 0;
}
}
}
use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IHackableEntity in project pnc-repressurized by TeamPneumatic.
the class CommonHUDHandler method handleHacking.
private void handleHacking(EntityPlayer player) {
if (hackedBlock != null) {
IHackableBlock hackableBlock = HackableHandler.getHackableForCoord(hackedBlock, player);
if (hackableBlock != null) {
if (++hackTime >= hackableBlock.getHackTime(hackedBlock.world, hackedBlock.pos, player)) {
hackableBlock.onHackFinished(player.world, hackedBlock.pos, player);
PneumaticCraftRepressurized.proxy.getHackTickHandler().trackBlock(hackedBlock, hackableBlock);
NetworkHandler.sendToAllAround(new PacketHackingBlockFinish(hackedBlock), player.world);
setHackedBlock(null);
}
} else {
setHackedBlock(null);
}
} else if (hackedEntity != null) {
IHackableEntity hackableEntity = HackableHandler.getHackableForEntity(hackedEntity, player);
if (hackableEntity != null) {
if (++hackTime >= hackableEntity.getHackTime(hackedEntity, player)) {
hackableEntity.onHackFinished(hackedEntity, player);
PneumaticCraftRepressurized.proxy.getHackTickHandler().trackEntity(hackedEntity, hackableEntity);
NetworkHandler.sendToAllAround(new PacketHackingEntityFinish(hackedEntity), new NetworkRegistry.TargetPoint(hackedEntity.world.provider.getDimension(), hackedEntity.posX, hackedEntity.posY, hackedEntity.posZ, 64));
setHackedEntity(null);
}
} else {
setHackedEntity(null);
}
}
}
use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IHackableEntity in project pnc-repressurized by TeamPneumatic.
the class PacketHackingEntityFinish method handleClientSide.
@Override
public void handleClientSide(PacketHackingEntityFinish message, EntityPlayer player) {
Entity entity = player.world.getEntityByID(message.entityId);
if (entity != null) {
IHackableEntity hackableEntity = HackableHandler.getHackableForEntity(entity, player);
if (hackableEntity != null) {
hackableEntity.onHackFinished(entity, player);
PneumaticCraftRepressurized.proxy.getHackTickHandler().trackEntity(entity, hackableEntity);
CommonHUDHandler.getHandlerForPlayer(player).setHackedEntity(null);
player.playSound(Sounds.HELMET_HACK_FINISH, 1.0F, 1.0F);
}
}
}
use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IHackableEntity in project pnc-repressurized by TeamPneumatic.
the class HackableHandler method getHackableForEntity.
public static IHackableEntity getHackableForEntity(Entity entity, EntityPlayer player) {
// clean up the map
getInstance().trackedHackableEntities.entrySet().removeIf(entry -> entry.getKey().isDead || !entry.getValue().canHack(entry.getKey(), player) && !isInDisplayCooldown(entry.getValue(), entry.getKey()));
if (entity instanceof IHackableEntity && ((IHackableEntity) entity).canHack(entity, player))
return (IHackableEntity) entity;
IHackableEntity hackable = getInstance().trackedHackableEntities.get(entity);
if (hackable == null) {
for (Map.Entry<Class<? extends Entity>, Class<? extends IHackableEntity>> entry : PneumaticHelmetRegistry.getInstance().hackableEntities.entrySet()) {
if (entry.getKey().isAssignableFrom(entity.getClass())) {
try {
hackable = entry.getValue().newInstance();
if (hackable.canHack(entity, player)) {
getInstance().trackedHackableEntities.put(entity, hackable);
break;
} else {
hackable = null;
}
} catch (Exception e) {
// shouldn't happen, checked earlier.
e.printStackTrace();
}
}
}
}
return hackable;
}
Aggregations