use of de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgradeInst in project ClaySoldiersMod by SanAndreasP.
the class LayerHeldItem method renderHandItem.
private void renderHandItem(ISoldier soldier, EnumHand hand) {
ISoldierUpgradeInst upgInst;
switch(hand) {
case MAIN_HAND:
if (soldier.hasUpgrade(Upgrades.EM_COAL, EnumUpgradeType.ENHANCEMENT)) {
RenderUtils.renderStackInWorld(COALBLOCK, 0.0D, -0.12D, 0.25D, 0.0F, 0.0F, 0.0F, 0.549D);
}
if (soldier.hasUpgrade(Upgrades.MC_REDMUSHROOM, EnumUpgradeType.MISC)) {
RenderUtils.renderStackInWorld(REDMUSHROOM, 0.0D, -0.12D, 0.2D, 0.0F, 0.0F, 0.0F, 0.55D);
}
if (soldier.hasUpgrade(Upgrades.MC_REDSTONE, EnumUpgradeType.MISC)) {
RenderUtils.renderStackInWorld(REDSTONEBLOCK, 0.0D, -0.12D, 0.15D, 0.0F, 0.0F, 0.0F, 0.551D);
}
if (soldier.hasUpgrade(Upgrades.MC_SLIMEBALL, EnumUpgradeType.MISC)) {
RenderUtils.renderStackInWorld(SLIMEBLOCK, 0.0D, -0.12D, 0.1D, 0.0F, 0.0F, 0.0F, 0.552D);
}
if ((upgInst = soldier.getUpgradeInstance(Upgrades.MC_BUTTON, EnumUpgradeType.MISC)) != null) {
if (upgInst.getNbtData().getBoolean("isStone")) {
RenderUtils.renderStackInWorld(STONE, 0.0D, -0.12D, 0.0D, 0.0F, 0.0F, 0.0F, 0.553D);
} else {
RenderUtils.renderStackInWorld(WOOD, 0.0D, -0.12D, 0.0D, 0.0F, 0.0F, 0.0F, 0.553D);
}
}
if (soldier.hasUpgrade(Upgrades.MH_STICK, EnumUpgradeType.MAIN_HAND)) {
if (soldier.hasUpgrade(Upgrades.EM_FLINT, EnumUpgradeType.ENHANCEMENT)) {
RenderUtils.renderStackInWorld(ARROW, 0.0D, 0.2D, 0.1D, 0.0F, 90.0F, 135.0F, 0.75D);
} else {
RenderUtils.renderStackInWorld(STICK, 0.0D, 0.2D, 0.1D, 0.0F, 90.0F, -45.0F, 0.75D);
}
} else if (soldier.hasUpgrade(Upgrades.MH_BLAZEROD, EnumUpgradeType.MAIN_HAND)) {
RenderUtils.renderStackInWorld(BLAZEROD, 0.0D, 0.2D, 0.1D, 0.0F, 90.0F, -45.0F, 0.75D);
} else if (soldier.hasUpgrade(Upgrades.MOH_SHEARBLADE, EnumUpgradeType.MAIN_HAND)) {
if (soldier.hasUpgrade(Upgrades.EM_PRISMARINESHARD, EnumUpgradeType.ENHANCEMENT)) {
RenderUtils.renderStackInWorld(SHEARBLADEPRISM, 0.0D, 0.2D, 0.1D, 0.0F, 90.0F, 135.0F, 0.75D);
} else {
RenderUtils.renderStackInWorld(SHEARBLADE, 0.0D, 0.2D, 0.1D, 0.0F, 90.0F, 135.0F, 0.75D);
}
} else if (soldier.hasUpgrade(Upgrades.MH_SPECKLEDMELON, EnumUpgradeType.MAIN_HAND)) {
RenderUtils.renderStackInWorld(SPECLEDMELON, 0.0D, 0.2D, 0.1D, 0.0F, 90.0F, -90.0F, 0.75D);
} else if (soldier.hasUpgrade(Upgrades.MH_BONE, EnumUpgradeType.MAIN_HAND)) {
RenderUtils.renderStackInWorld(BONE, 0.0D, 0.2D, 0.1D, 0.0F, 90.0F, -45.0F, 0.75D);
}
break;
case OFF_HAND:
if (soldier.hasUpgrade(Upgrades.EM_SUGARCANE, EnumUpgradeType.ENHANCEMENT)) {
RenderUtils.renderStackInWorld(SUGARCANE, 0.0D, 0.1D, 0.05D, -35.0F, 0.0F, 135.0F, 0.5D);
}
if (soldier.hasUpgrade(Upgrades.EM_IRONBLOCK, EnumUpgradeType.ENHANCEMENT)) {
RenderUtils.renderStackInWorld(SHIELD_STD, 0.0D, 0.2D, 0.0D, 90.0F, 0.0F, 0.0F, 0.75D);
} else if (soldier.hasUpgrade(Upgrades.MOH_SHEARBLADE, EnumUpgradeType.OFF_HAND)) {
if (soldier.hasUpgrade(Upgrades.EM_PRISMARINESHARD, EnumUpgradeType.ENHANCEMENT)) {
RenderUtils.renderStackInWorld(SHEARBLADEPRISM, 0.0D, 0.2D, 0.0D, 0.0F, 90.0F, 135.0F, 0.75D);
} else {
RenderUtils.renderStackInWorld(SHEARBLADE, 0.0D, 0.2D, 0.0D, 0.0F, 90.0F, 135.0F, 0.75D);
}
} else if (soldier.hasUpgrade(Upgrades.OH_GRAVEL, EnumUpgradeType.OFF_HAND)) {
RenderUtils.renderStackInWorld(GRAVEL, 0.0D, -0.125D, -0.05D, 0.0F, 0.0F, 0.0F, 0.6D);
} else if (soldier.hasUpgrade(Upgrades.OH_SNOW, EnumUpgradeType.OFF_HAND)) {
RenderUtils.renderStackInWorld(SNOW, 0.0D, -0.125D, -0.05D, 0.0F, 0.0F, 0.0F, 0.6D);
} else if (soldier.hasUpgrade(Upgrades.OH_FIRECHARGE, EnumUpgradeType.OFF_HAND)) {
RenderUtils.renderStackInWorld(MAGMA, 0.0D, -0.125D, -0.05D, 0.0F, 0.0F, 0.0F, 0.6D);
} else if (soldier.hasUpgrade(Upgrades.OH_EMERALD, EnumUpgradeType.OFF_HAND)) {
RenderUtils.renderStackInWorld(EMERALDBLOCK, 0.0D, -0.125D, -0.05D, 0.0F, 0.0F, 0.0F, 0.6D);
} else if (soldier.hasUpgrade(Upgrades.OH_QUARTZ, EnumUpgradeType.OFF_HAND)) {
RenderUtils.renderStackInWorld(QUARTZ, 0.0D, -0.125D, -0.05D, 0.0F, 0.0F, 0.0F, 0.6D);
} else if (soldier.hasUpgrade(Upgrades.OH_BOWL, EnumUpgradeType.OFF_HAND)) {
RenderUtils.renderStackInWorld(SHIELD_NRM, 0.0D, 0.2D, 0.0D, 90.0F, 0.0F, 0.0F, 0.75D);
}
break;
}
GlStateManager.enableRescaleNormal();
}
use of de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgradeInst in project ClaySoldiersMod by SanAndreasP.
the class EntityClaySoldier method addUpgrade.
@Override
public ISoldierUpgradeInst addUpgrade(ISoldierUpgrade upgrade, EnumUpgradeType type, @Nonnull ItemStack stack) {
if (upgrade == null) {
return null;
}
ISoldierUpgradeInst upgInst = new SoldierUpgrade(upgrade, type, stack.copy().splitStack(1));
this.addUpgradeInternal(upgInst);
upgrade.onAdded(this, stack, upgInst);
this.callUpgradeFunc(EnumUpgFunctions.ON_UPGRADE_ADDED, upgInstCl -> upgInstCl.getUpgrade().onUpgradeAdded(this, upgInstCl, upgInst));
if (upgrade.syncData() && !this.world.isRemote) {
this.sendSyncUpgrades(true, new UpgradeEntry(upgrade, type));
}
return upgInst;
}
use of de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgradeInst in project ClaySoldiersMod by SanAndreasP.
the class EntityClaySoldier method destroyUpgrade.
@Override
public void destroyUpgrade(ISoldierUpgrade upgrade, EnumUpgradeType type, boolean silent) {
UpgradeEntry entry = new UpgradeEntry(upgrade, type);
ISoldierUpgradeInst inst = this.upgradeMap.get(entry);
if (inst != null) {
this.upgradeMap.remove(entry);
this.upgradeSyncList.remove(inst);
this.upgradeFuncMap.forEach((key, val) -> {
if (Arrays.asList(UpgradeRegistry.getFuncCalls(upgrade)).contains(key)) {
val.get(upgrade.getPriority()).remove(inst);
}
});
switch(upgrade.getType(this)) {
case MAIN_HAND:
this.setMainhandUpg(false);
break;
case OFF_HAND:
this.setOffhandUpg(false);
break;
case BEHAVIOR:
this.setBehaviorUpg(false);
break;
}
upgrade.onDestroyed(this, inst);
this.callUpgradeFunc(EnumUpgFunctions.ON_OTHR_DESTROYED, othrInst -> othrInst.getUpgrade().onUpgradeDestroyed(this, othrInst, inst));
if (!this.world.isRemote) {
if (upgrade.syncData()) {
this.sendSyncUpgrades(false, new UpgradeEntry(upgrade, type));
}
}
if (!silent) {
if (this.world.isRemote || !upgrade.syncData()) {
ClaySoldiersMod.proxy.spawnParticle(EnumParticle.ITEM_BREAK, this.world.provider.getDimension(), this.posX, this.posY + this.getEyeHeight(), this.posZ, Item.getIdFromItem(inst.getSavedStack().getItem()));
}
}
}
}
use of de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgradeInst in project ClaySoldiersMod by SanAndreasP.
the class UpgradeQuartz method onDamagedSuccess.
@Override
public void onDamagedSuccess(ISoldier<?> soldier, ISoldierUpgradeInst upgradeInst, Entity attacker, DamageSource dmgSource, float damage) {
int hitsTaken = upgradeInst.getNbtData().getInteger("hitsTaken") + 1;
long lastCooldown = upgradeInst.getNbtData().getLong("cooldownTime");
upgradeInst.getNbtData().setLong("cooldownTime", System.currentTimeMillis());
if (System.currentTimeMillis() - lastCooldown < 2_000) {
if (hitsTaken >= 5) {
EntityCreature john = soldier.getEntity();
hitsTaken = 0;
short uses = (short) (upgradeInst.getNbtData().getShort("uses") - 1);
if (uses < 1) {
soldier.destroyUpgrade(upgradeInst.getUpgrade(), upgradeInst.getUpgradeType(), false);
john.playSound(SoundEvents.ENTITY_ITEM_BREAK, 0.8F, 0.8F + MiscUtils.RNG.randomFloat() * 0.4F);
} else {
upgradeInst.getNbtData().setShort("uses", uses);
}
AxisAlignedBB surroundingBB = john.getEntityBoundingBox().grow(1.0D);
Predicate<EntityCreature> entityChk = entity -> entity instanceof ISoldier && entity != john;
soldier.getEntity().world.getEntitiesWithinAABB(EntityCreature.class, surroundingBB, entityChk::test).forEach(entity -> entity.knockBack(john, 0.5F, john.posX - entity.posX, john.posZ - entity.posZ));
ClaySoldiersMod.proxy.spawnParticle(EnumParticle.SHOCKWAVE, john.world.provider.getDimension(), john.posX, john.posY, john.posZ);
}
upgradeInst.getNbtData().setInteger("hitsTaken", hitsTaken);
}
}
use of de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgradeInst in project ClaySoldiersMod by SanAndreasP.
the class EntityProjectileEmerald method onBlockHit.
@Override
protected void onBlockHit(BlockPos pos) {
EnumDyeColor color = null;
if (this.shooterCache instanceof ISoldier) {
ISoldierUpgradeInst inst = ((ISoldier) this.shooterCache).getUpgradeInstance(Upgrades.MC_CONCRETEPOWDER, EnumUpgradeType.MISC);
if (inst != null) {
color = EnumDyeColor.byMetadata(inst.getNbtData().getInteger("color"));
}
}
ClaySoldiersMod.proxy.setRenderLightningAt(pos.getX() + 0.5D, pos.getY() + 1.0D, pos.getZ() + 0.5D, color);
}
Aggregations