aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/openmodularturrets/tileentity/turret/TileTurretHeadEM.java
blob: 277d692f479d6a6fcfb86c4a68d5176d225d0a03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package openmodularturrets.tileentity.turret;

import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackMap;
import com.github.technus.tectech.thing.item.DebugContainer_EM;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import openmodularturrets.entity.projectiles.TurretProjectile;
import openmodularturrets.entity.projectiles.projectileEM;
import openmodularturrets.handler.ConfigHandler;
import openmodularturrets.tileentity.turretbase.TileTurretBaseEM;
import openmodularturrets.tileentity.turrets.TurretHead;
import openmodularturrets.util.TurretHeadUtil;

/**
 * Created by Bass on 27/07/2017.
 */
public class TileTurretHeadEM extends TurretHead{
    private cElementalInstanceStackMap hatchContentPointer;

    public TileTurretHeadEM() {
    }

    public int getTurretRange() {
        return ConfigHandler.getLaserTurretSettings().getRange()<<1;
    }

    public int getTurretPowerUsage() {
        return ConfigHandler.getLaserTurretSettings().getPowerUsage()<<4;
    }

    public int getTurretFireRate() {
        return (int)Math.ceil(ConfigHandler.getLaserTurretSettings().getFireRate()/2f);
    }

    public double getTurretAccuracy() {
        return (int)Math.ceil(ConfigHandler.getLaserTurretSettings().getAccuracy() / 10.0F);
    }

    @Override
    public void updateEntity() {
        if(!worldObj.isRemote && base instanceof TileTurretBaseEM)
            hatchContentPointer =((TileTurretBaseEM) base).getContainerHandler();
        super.updateEntity();
    }

    public boolean requiresAmmo() {
        return hatchContentPointer == null || !hatchContentPointer.hasStacks();
    }

    public boolean requiresSpecificAmmo() {
        return true;//to enable failure in shooting when there is no EM to use
    }

    public Item getAmmo() {
        return DebugContainer_EM.INSTANCE;//Placeholder item that cannot be achieved, yet still usable for debug
    }

    public final TurretProjectile createProjectile(World world, Entity target, ItemStack ammo) {
        return new projectileEM(world, TurretHeadUtil.getTurretBase(worldObj, xCoord, yCoord, zCoord), hatchContentPointer);
    }

    public String getLaunchSoundEffect() {
        return "laser";
    }
}