use of com.lying.variousoddities.capabilities.PlayerData in project VariousOddities by Lyinginbedmon.
the class FactionReputation method resetPlayerReputation.
/**
* Returns the given player's reputation with the given faction to its configured starting value
* @param player
* @param factionName
* @return
*/
public static int resetPlayerReputation(PlayerEntity player, String factionName) {
factionName = validateName(factionName);
FactionManager manager = FactionManager.get(player.getEntityWorld());
Faction faction = manager.getFaction(factionName);
int rep = faction == null ? 0 : faction.startingRep;
PlayerData data = PlayerData.forPlayer(player);
if (data != null)
data.reputation.setReputation(factionName, rep);
return rep;
}
use of com.lying.variousoddities.capabilities.PlayerData in project VariousOddities by Lyinginbedmon.
the class IngameGuiMixin method func_238454_b_.
@Inject(method = "func_238454_b_(Lcom/mojang/blaze3d/matrix/MatrixStack;I)V", at = @At("HEAD"), cancellable = true)
public void func_238454_b_(MatrixStack matrixStack, int xPos, final CallbackInfo ci) {
Minecraft mc = Minecraft.getInstance();
PlayerEntity player = mc.player;
if (player == null)
return;
PlayerData data = PlayerData.forPlayer(player);
if (data == null || PlayerData.isPlayerNormalFunction(player))
return;
ci.cancel();
AbstractGui gui = (AbstractGui) (Object) this;
ITextComponent displayText = null;
switch(data.getBodyCondition()) {
case DEAD:
float progress = 1F - data.timeToRespawnable();
mc.getProfiler().startSection("expBar");
mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION);
int k = (int) (progress * 183.0F);
int l = this.scaledHeight - 32 + 3;
gui.blit(matrixStack, xPos, l, 0, 64, 182, 5);
if (k > 0)
gui.blit(matrixStack, xPos, l, 0, 69, k, 5);
mc.getProfiler().endSection();
if (progress >= 1F) {
KeyBinding inv = mc.gameSettings.keyBindInventory;
displayText = new TranslationTextComponent("gui." + Reference.ModInfo.MOD_ID + ".dead_player_respawn", inv.func_238171_j_().getString().toUpperCase());
}
case UNCONSCIOUS:
if (!LivingData.forEntity(player).isUnconscious() && data.getSoulCondition() == SoulCondition.ALIVE) {
KeyBinding inv = mc.gameSettings.keyBindInventory;
displayText = new TranslationTextComponent("gui." + Reference.ModInfo.MOD_ID + ".unconscious_player_awaken", inv.func_238171_j_().getString().toUpperCase());
}
default:
;
}
if (displayText != null) {
String s = displayText.getString();
int textX = (scaledWidth - getFontRenderer().getStringWidth(s)) / 2;
int textY = this.scaledHeight - 31 - 7;
FontRenderer fontRenderer = getFontRenderer();
fontRenderer.drawString(matrixStack, s, (float) (textX + 1), (float) textY, 0);
fontRenderer.drawString(matrixStack, s, (float) (textX - 1), (float) textY, 0);
fontRenderer.drawString(matrixStack, s, (float) textX, (float) (textY + 1), 0);
fontRenderer.drawString(matrixStack, s, (float) textX, (float) (textY - 1), 0);
fontRenderer.drawString(matrixStack, s, (float) textX, (float) textY, -1);
}
}
use of com.lying.variousoddities.capabilities.PlayerData in project VariousOddities by Lyinginbedmon.
the class MinecraftMixin method processKeyBinds.
@Inject(method = "processKeyBinds()V", at = @At("HEAD"), cancellable = true)
public void processKeyBinds(final CallbackInfo ci) {
PlayerEntity player = ((Minecraft) (Object) this).player;
if (player == null)
return;
PlayerData data = PlayerData.forPlayer(player);
if (data == null)
return;
Minecraft mc = Minecraft.getInstance();
if (PlayerData.isPlayerNormalFunction(player) || VOHelper.isCreativeOrSpectator(player))
return;
else
ci.cancel();
while (mc.gameSettings.keyBindInventory.isPressed()) {
switch(data.getBodyCondition()) {
case DEAD:
// Send respawn packet if delay completed
if (data.timeToRespawnable() == 0F)
PacketHandler.sendToServer(new PacketDeadDeath());
case UNCONSCIOUS:
// Send wakeup packet if no longer unconscious
if (!LivingData.forEntity(player).isUnconscious() && data.getSoulCondition() == SoulCondition.ALIVE)
PacketHandler.sendToServer(new PacketUnconsciousAwaken());
default:
;
}
}
processVitalKeys(mc);
if (this.player.isHandActive())
this.playerController.onStoppedUsingItem(this.player);
this.sendClickBlockToController(false);
}
use of com.lying.variousoddities.capabilities.PlayerData in project VariousOddities by Lyinginbedmon.
the class NearestAttackableTargetGoalMixin method getPredicate.
private static Predicate<LivingEntity> getPredicate(LivingEntity goalOwnerIn) {
return new Predicate<LivingEntity>() {
public boolean test(LivingEntity target) {
// Undead mobs do not target other undead
if (goalOwnerIn.isNonBoss() && goalOwnerIn.isEntityUndead())
if (target.isEntityUndead())
return false;
// Mobs do not attack creatures that have mind-controlled them somehow
LivingData mobData = LivingData.forEntity(goalOwnerIn);
if (mobData != null && mobData.isTargetingHindered(target))
return false;
// Faction mobs do not attack mobs with good reputation
if (goalOwnerIn instanceof IFactionMob) {
FactionManager factionManager = FactionManager.get(target.getEntityWorld());
Faction ownerFaction = factionManager.getFaction(goalOwnerIn);
if (ownerFaction != null)
if (target.getType() == EntityType.PLAYER) {
PlayerData data = PlayerData.forPlayer((PlayerEntity) target);
if (data != null) {
int reputation = data.reputation.getReputation(ownerFaction.name);
if (reputation == Integer.MIN_VALUE) {
data.reputation.setReputation(ownerFaction.name, ownerFaction.startingRep);
reputation = ownerFaction.startingRep;
}
return EnumAttitude.fromRep(reputation).allowsInteraction(EnumInteraction.ATTACK);
}
} else if (target instanceof IFactionMob) {
Faction inputFaction = factionManager.getFaction(target);
if (inputFaction != null)
return ownerFaction.relationWith(inputFaction.name).allowsInteraction(EnumInteraction.ATTACK);
}
}
return true;
}
};
}
use of com.lying.variousoddities.capabilities.PlayerData in project VariousOddities by Lyinginbedmon.
the class VOBusClient method noclipHideEntities.
@SuppressWarnings({ "rawtypes", "unchecked" })
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public static <T extends LivingEntity, M extends EntityModel<T>> void noclipHideEntities(RenderLivingEvent.Pre event) {
LivingEntity renderTarget = event.getEntity();
if (playerInWall()) {
Vector3d posFeet = renderTarget.getPositionVec();
Vector3d posEyes = posFeet.add(0D, renderTarget.getEyeHeight(), 0D);
PlayerEntity player = mc.player;
Vector3d posView = player.getPositionVec().add(0D, player.getEyeHeight(), 0D);
if (posView.distanceTo(posFeet) > 8D || posView.distanceTo(posEyes) > 8D)
event.setCanceled(true);
}
if (skipRenderEvent)
skipRenderEvent = false;
else if (renderTarget instanceof PlayerEntity) {
PlayerData data = PlayerData.forPlayer((PlayerEntity) renderTarget);
if (!AbilityRegistry.getAbilitiesOfType(renderTarget, AbilityPhasing.class).isEmpty() || (data != null && data.getBodyCondition() != BodyCondition.ALIVE)) {
event.setCanceled(true);
IRenderTypeBuffer.Impl iRenderTypeBuffer = mc.getRenderTypeBuffers().getBufferSource();
event.getMatrixStack().push();
skipRenderEvent = true;
event.getRenderer().render(renderTarget, renderTarget.rotationYaw, event.getPartialRenderTick(), event.getMatrixStack(), iRenderTypeBuffer, 0xffffff);
event.getMatrixStack().pop();
}
}
}
Aggregations