use of com.lying.variousoddities.capabilities.LivingData in project VariousOddities by Lyinginbedmon.
the class VOBusServer method onPlayerRespawnEvent.
@SubscribeEvent
public static void onPlayerRespawnEvent(PlayerRespawnEvent event) {
LivingData livingData = LivingData.forEntity(event.getPlayer());
if (livingData != null)
livingData.getAbilities().markDirty();
if (AbilityRegistry.hasAbility(event.getPlayer(), AbilitySize.REGISTRY_NAME))
event.getPlayer().recalculateSize();
if (PlayerData.isPlayerBodyDead(event.getPlayer())) {
PlayerData playerData = PlayerData.forPlayer(event.getPlayer());
playerData.setBodyCondition(BodyCondition.ALIVE);
playerData.setSoulCondition(SoulCondition.ALIVE);
}
}
use of com.lying.variousoddities.capabilities.LivingData in project VariousOddities by Lyinginbedmon.
the class VOBusServer method applyNativeExtraplanar.
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void applyNativeExtraplanar(GetEntityTypesEvent event) {
LivingEntity entity = event.getEntity();
LivingData data = LivingData.forEntity(entity);
if (data == null)
return;
if (data.getHomeDimension() != null) {
List<EnumCreatureType> types = event.getTypes();
if (types.contains(EnumCreatureType.EXTRAPLANAR) || types.contains(EnumCreatureType.NATIVE))
return;
ResourceLocation currentDim = entity.getEntityWorld().getDimensionKey().getLocation();
if (currentDim.equals(data.getHomeDimension())) {
if (!types.contains(EnumCreatureType.EXTRAPLANAR) && EnumCreatureType.NATIVE.canApplyTo(types))
event.getTypes().add(EnumCreatureType.NATIVE);
} else {
if (!types.contains(EnumCreatureType.NATIVE) && EnumCreatureType.EXTRAPLANAR.canApplyTo(types))
event.getTypes().add(EnumCreatureType.EXTRAPLANAR);
}
}
}
use of com.lying.variousoddities.capabilities.LivingData in project VariousOddities by Lyinginbedmon.
the class VOBusServer method onPlayerLogInEvent.
@SubscribeEvent
public static void onPlayerLogInEvent(PlayerLoggedInEvent event) {
PlayerEntity player = event.getPlayer();
PacketHandler.sendTo((ServerPlayerEntity) player, new PacketSyncSpecies(VORegistries.SPECIES));
LivingData data = LivingData.forEntity(player);
if (data != null) {
PacketHandler.sendToAll((ServerWorld) player.getEntityWorld(), new PacketSyncLivingData(player.getUniqueID(), data));
data.getAbilities().markDirty();
if (!data.hasSelectedSpecies() && ConfigVO.MOBS.selectSpeciesOnLogin.get()) {
if (!player.getEntityWorld().isRemote)
PacketHandler.sendTo((ServerPlayerEntity) player, new PacketSpeciesOpenScreen());
player.addPotionEffect(new EffectInstance(Effects.RESISTANCE, Reference.Values.TICKS_PER_MINUTE * 15, 15, true, false));
}
}
}
use of com.lying.variousoddities.capabilities.LivingData in project VariousOddities by Lyinginbedmon.
the class AbilitySize method handleSize.
public void handleSize(EntityEvent.Size event) {
if (event.getEntity() instanceof LivingEntity && event.getEntity().getType() == EntityType.PLAYER) {
LivingEntity living = (LivingEntity) event.getEntity();
LivingData data = LivingData.forEntity(living);
if (data == null || !AbilityRegistry.hasAbility(living, REGISTRY_NAME))
return;
AbilitySize size = (AbilitySize) AbilityRegistry.getAbilityByName(living, REGISTRY_NAME);
if (size == null)
return;
if (!event.getEntity().isAddedToWorld())
return;
float scale = size.getScale();
EntitySize baseSize = event.getNewSize();
event.setNewSize(EntitySize.fixed(baseSize.width * scale, baseSize.height * scale));
event.setNewEyeHeight(event.getNewEyeHeight() * scale);
}
}
use of com.lying.variousoddities.capabilities.LivingData in project VariousOddities by Lyinginbedmon.
the class GuiHandler method renderBludgeoning.
@SuppressWarnings("deprecation")
public static void renderBludgeoning(RenderGameOverlayEvent.Pre event) {
mc = Minecraft.getInstance();
if (event.getType() != RenderGameOverlayEvent.ElementType.HEALTH || event.isCanceled() || !PlayerData.isPlayerNormalFunction(mc.player) || VOHelper.isCreativeOrSpectator(mc.player))
return;
profiler = mc.getProfiler();
profiler.startSection("varodd-hud-bludgeoning");
player = Minecraft.getInstance().player;
if (player != null) {
LivingData data = LivingData.forEntity(player);
if (data != null && !PlayerData.isPlayerBodyAsleep(player)) {
mc.getTextureManager().bindTexture(HUD_ICONS);
float bludgeoning = data.getBludgeoning();
float val = MathHelper.clamp(bludgeoning / player.getHealth(), 0F, 1F);
int width = (int) (val * 81);
int height = 9;
int right = mc.getMainWindow().getScaledWidth() / 2 - 91;
int top = mc.getMainWindow().getScaledHeight() - ForgeIngameGui.right_height;
RenderSystem.enableBlend();
RenderSystem.color4f(1F, 1F, 1F, 0.75F);
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mc.ingameGUI.blit(event.getMatrixStack(), right, top, 0, 0, width, height);
RenderSystem.disableBlend();
RenderSystem.color4f(1F, 1F, 1F, 1F);
mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION);
}
}
profiler.endSection();
}
Aggregations