Search in sources :

Example 1 with ISoldierUpgradeInst

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();
}
Also used : ISoldierUpgradeInst(de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgradeInst)

Example 2 with ISoldierUpgradeInst

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;
}
Also used : ISoldierUpgradeInst(de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgradeInst) ISoldierUpgrade(de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgrade) UpgradeEntry(de.sanandrew.mods.claysoldiers.registry.upgrade.UpgradeEntry)

Example 3 with ISoldierUpgradeInst

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()));
            }
        }
    }
}
Also used : ISoldierUpgradeInst(de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgradeInst) UpgradeEntry(de.sanandrew.mods.claysoldiers.registry.upgrade.UpgradeEntry)

Example 4 with ISoldierUpgradeInst

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);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) SoundEvents(net.minecraft.init.SoundEvents) Items(net.minecraft.init.Items) Predicate(java.util.function.Predicate) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumUpgFunctions(de.sanandrew.mods.claysoldiers.api.soldier.upgrade.EnumUpgFunctions) UpgradeFunctions(de.sanandrew.mods.claysoldiers.api.soldier.upgrade.UpgradeFunctions) DamageSource(net.minecraft.util.DamageSource) MiscUtils(de.sanandrew.mods.sanlib.lib.util.MiscUtils) ItemStack(net.minecraft.item.ItemStack) ISoldier(de.sanandrew.mods.claysoldiers.api.soldier.ISoldier) ISoldierUpgradeInst(de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgradeInst) EnumUpgradeType(de.sanandrew.mods.claysoldiers.api.soldier.upgrade.EnumUpgradeType) CsmConstants(de.sanandrew.mods.claysoldiers.api.CsmConstants) ClaySoldiersMod(de.sanandrew.mods.claysoldiers.util.ClaySoldiersMod) ISoldierUpgrade(de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgrade) EntityCreature(net.minecraft.entity.EntityCreature) NonNullList(net.minecraft.util.NonNullList) EnumParticle(de.sanandrew.mods.claysoldiers.util.EnumParticle) Nonnull(javax.annotation.Nonnull) ISoldier(de.sanandrew.mods.claysoldiers.api.soldier.ISoldier) EntityCreature(net.minecraft.entity.EntityCreature)

Example 5 with ISoldierUpgradeInst

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);
}
Also used : ISoldierUpgradeInst(de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgradeInst) ISoldier(de.sanandrew.mods.claysoldiers.api.soldier.ISoldier) EnumDyeColor(net.minecraft.item.EnumDyeColor)

Aggregations

ISoldierUpgradeInst (de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgradeInst)14 ISoldier (de.sanandrew.mods.claysoldiers.api.soldier.ISoldier)7 ISoldierUpgrade (de.sanandrew.mods.claysoldiers.api.soldier.upgrade.ISoldierUpgrade)5 ItemStack (net.minecraft.item.ItemStack)4 UpgradeEntry (de.sanandrew.mods.claysoldiers.registry.upgrade.UpgradeEntry)3 EnumDyeColor (net.minecraft.item.EnumDyeColor)3 EnumUpgradeType (de.sanandrew.mods.claysoldiers.api.soldier.upgrade.EnumUpgradeType)2 EntityCreature (net.minecraft.entity.EntityCreature)2 CsmConstants (de.sanandrew.mods.claysoldiers.api.CsmConstants)1 ISoldierRender (de.sanandrew.mods.claysoldiers.api.client.soldier.ISoldierRender)1 ISoldierEffect (de.sanandrew.mods.claysoldiers.api.soldier.effect.ISoldierEffect)1 ISoldierEffectInst (de.sanandrew.mods.claysoldiers.api.soldier.effect.ISoldierEffectInst)1 EnumUpgFunctions (de.sanandrew.mods.claysoldiers.api.soldier.upgrade.EnumUpgFunctions)1 UpgradeFunctions (de.sanandrew.mods.claysoldiers.api.soldier.upgrade.UpgradeFunctions)1 ModelGoggleBand (de.sanandrew.mods.claysoldiers.client.model.accessory.ModelGoggleBand)1 Upgrades (de.sanandrew.mods.claysoldiers.registry.upgrade.Upgrades)1 ClaySoldiersMod (de.sanandrew.mods.claysoldiers.util.ClaySoldiersMod)1 EnumParticle (de.sanandrew.mods.claysoldiers.util.EnumParticle)1 ColorObj (de.sanandrew.mods.sanlib.lib.ColorObj)1 RenderUtils (de.sanandrew.mods.sanlib.lib.client.util.RenderUtils)1