aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java
blob: cccc594c7677c52f901c24a7d084899c3d5d0219 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package gregtech.api.interfaces.tileentity;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.interfaces.IDescribable;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.modularui.IAddInventorySlots;
import gregtech.api.interfaces.modularui.IGetGUITextureSet;
import gregtech.common.blocks.GT_Block_Machines;

/**
 * A simple compound Interface for all my TileEntities.
 * <p/>
 * Also delivers most of the Information about my TileEntities.
 * <p/>
 * It can cause Problems to include this Interface!
 */
public interface IGregTechTileEntity extends ITexturedTileEntity, IGearEnergyTileEntity, ICoverable, IFluidHandler,
    ITurnable, IGregTechDeviceInformation, IUpgradableMachine, IDigitalChest, IDescribable, IMachineBlockUpdateable,
    IGregtechWailaProvider, IGetGUITextureSet, IAddInventorySlots {

    /**
     * gets the Error displayed on the GUI
     */
    int getErrorDisplayID();

    /**
     * sets the Error displayed on the GUI
     */
    void setErrorDisplayID(int aErrorID);

    /**
     * @return the MetaID of the Block or the MetaTileEntity ID.
     */
    int getMetaTileID();

    /**
     * Internal Usage only!
     */
    int setMetaTileID(short aID);

    /**
     * @return the MetaTileEntity which is belonging to this, or null if it doesnt has one.
     */
    IMetaTileEntity getMetaTileEntity();

    /**
     * Sets the MetaTileEntity. Even though this uses the Universal Interface, certain BaseMetaTileEntities only accept
     * one kind of MetaTileEntity so only use this if you are sure its the correct one or you will get a Class cast
     * Error.
     *
     * @param aMetaTileEntity a MetaTileEntity
     */
    void setMetaTileEntity(IMetaTileEntity aMetaTileEntity);

    /**
     * Causes a general Texture update.
     * <p/>
     * Only used Client Side to mark Blocks dirty.
     */
    void issueTextureUpdate();

    /**
     * Causes the Machine to send its initial Data, like Covers and its ID.
     */
    void issueClientUpdate();

    /**
     * causes Explosion. Strength in Overload-EU
     */
    void doExplosion(long aExplosionEU);

    /**
     * Sets the Block on Fire in all 6 Directions
     */
    void setOnFire();

    /**
     * Sets the Block to Fire
     */
    void setToFire();

    /**
     * Sets the Owner of the Machine. Returns the set Name.
     */
    String setOwnerName(String aName);

    /**
     * gets the Name of the Machines Owner or "Player" if not set.
     */
    String getOwnerName();

    /**
     * Gets the UniqueID of the Machines Owner.
     */
    UUID getOwnerUuid();

    /**
     * Sets the UniqueID of the Machines Owner.
     */
    void setOwnerUuid(UUID uuid);

    /**
     * Sets initial Values from NBT
     *
     * @param aNBT is the NBTTag of readFromNBT
     * @param aID  is the MetaTileEntityID
     */
    void setInitialValuesAsNBT(NBTTagCompound aNBT, short aID);

    /**
     * Called when leftclicking the TileEntity
     */
    void onLeftclick(EntityPlayer aPlayer);

    /**
     * Called when rightclicking the TileEntity
     */
    boolean onRightclick(EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ);

    float getBlastResistance(ForgeDirection side);

    default void onBlockDestroyed() {}

    ArrayList<ItemStack> getDrops();

    /**
     * Check if the item at the specific index should be dropped or not
     *
     * @param index Index that will be checked
     * @return True if it should drop, else false
     */
    boolean shouldDropItemAt(int index);

    /**
     * 255 = 100%
     */
    int getLightOpacity();

    void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB,
        List<AxisAlignedBB> outputAABB, Entity collider);

    AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ);

    void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider);

    /**
     * Checks validity of meta tile and delegates to it
     */
    @Override
    default void onMachineBlockUpdate() {
        if (!isDead() && getMetaTileEntity() != null && getMetaTileEntity().getBaseMetaTileEntity() == this) {
            getMetaTileEntity().onMachineBlockUpdate();
        }
    }

    /**
     * Checks validity of meta tile and delegates to it
     */
    @Override
    default boolean isMachineBlockUpdateRecursive() {
        return !isDead() && getMetaTileEntity() != null
            && getMetaTileEntity().getBaseMetaTileEntity() == this
            && getMetaTileEntity().isMachineBlockUpdateRecursive();
    }

    default void setShutdownStatus(boolean newStatus) {}

    /**
     * A randomly called display update to be able to add particles or other items for display The event is proxied by
     * the {@link GT_Block_Machines#randomDisplayTick}
     */
    @SideOnly(Side.CLIENT)
    default void onRandomDisplayTick() {
        if (getMetaTileEntity() != null && getMetaTileEntity().getBaseMetaTileEntity() == this) {
            getMetaTileEntity().onRandomDisplayTick(this);
        }
    }
}