aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/multitileentity/MultiTileEntityBlock.java
blob: 5ea106919343f58e097a9287fe698fb33940565b (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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
package gregtech.api.multitileentity;

import static gregtech.api.enums.GT_Values.OFFX;
import static gregtech.api.enums.GT_Values.OFFY;
import static gregtech.api.enums.GT_Values.OFFZ;
import static gregtech.api.util.GT_Util.LAST_BROKEN_TILEENTITY;
import static gregtech.api.util.GT_Util.getTileEntity;
import static gregtech.api.util.GT_Util.setTileEntity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;

import com.cricketcraft.chisel.api.IFacade;

import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.IDebugableBlock;
import gregtech.api.interfaces.tileentity.IDebugableTileEntity;
import gregtech.api.metatileentity.BaseTileEntity;
import gregtech.api.metatileentity.CoverableTileEntity;
import gregtech.api.multitileentity.interfaces.IMultiTileEntity;
import gregtech.api.multitileentity.interfaces.IMultiTileEntity.IMTE_BreakBlock;
import gregtech.api.multitileentity.interfaces.IMultiTileEntity.IMTE_GetBlockHardness;
import gregtech.api.multitileentity.interfaces.IMultiTileEntity.IMTE_GetComparatorInputOverride;
import gregtech.api.multitileentity.interfaces.IMultiTileEntity.IMTE_GetWeakChanges;
import gregtech.api.multitileentity.interfaces.IMultiTileEntity.IMTE_HasMultiBlockMachineRelevantData;
import gregtech.api.multitileentity.interfaces.IMultiTileEntity.IMTE_IsProvidingStrongPower;
import gregtech.api.multitileentity.interfaces.IMultiTileEntity.IMTE_IsProvidingWeakPower;
import gregtech.api.multitileentity.interfaces.IMultiTileEntity.IMTE_OnNeighborBlockChange;
import gregtech.api.multitileentity.interfaces.IMultiTileEntity.IMTE_ShouldCheckWeakPower;
import gregtech.api.objects.XSTR;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Util;
import gregtech.common.covers.CoverInfo;
import gregtech.common.render.GT_MultiTile_Renderer;

/*
 * MultiTileEntityBlock ported from GT6
 */
@Optional.Interface(iface = "com.cricketcraft.chisel.api.IFacade", modid = "ChiselAPI")
public class MultiTileEntityBlock extends Block implements IDebugableBlock, ITileEntityProvider, IFacade {

    protected static final Map<String, MultiTileEntityBlock> MULTI_BLOCK_MAP = new HashMap<>();
    private static boolean LOCK = false;

    protected final String mNameInternal, mTool;
    protected final int mHarvestLevelOffset, mHarvestLevelMinimum, mHarvestLevelMaximum;
    protected final boolean mOpaque, mNormalCube;

    public static String getName(String aMaterialName, SoundType aSoundType, String aTool, int aHarvestLevelOffset,
        int aHarvestLevelMinimum, int aHarvestLevelMaximum, boolean aOpaque, boolean aNormalCube) {
        return "gt.block.multiblock." + aMaterialName
            + "."
            + aSoundType.soundName
            + "."
            + aTool
            + "."
            + aHarvestLevelOffset
            + "."
            + aHarvestLevelMinimum
            + "."
            + aHarvestLevelMaximum
            + "."
            + aOpaque
            + "."
            + aNormalCube;
    }

    /**
     * @param aMaterialName        the Name of the vanilla Material Field. In case this is not a vanilla Material,
     *                             insert the Name you want to give your own Material instead.
     * @param aMaterial            the Material used to determine the Block.
     * @param aSoundType           the Sound Type of the Block.
     * @param aTool                the Tool used to harvest this Block.
     * @param aHarvestLevelOffset  obvious
     * @param aHarvestLevelMinimum obvious
     * @param aHarvestLevelMaximum obvious
     * @param aOpaque              if this Block is Opaque.
     * @param aNormalCube          if this Block is a normal Cube (for Redstone Stuff).
     */
    public static MultiTileEntityBlock getOrCreate(String aModID, String aMaterialName, Material aMaterial,
        SoundType aSoundType, String aTool, int aHarvestLevelOffset, int aHarvestLevelMinimum, int aHarvestLevelMaximum,
        boolean aOpaque, boolean aNormalCube) {
        final MultiTileEntityBlock rBlock = MULTI_BLOCK_MAP.get(
            aModID + ":"
                + getName(
                    aMaterialName,
                    aSoundType,
                    aTool = aTool.toLowerCase(),
                    aHarvestLevelOffset,
                    aHarvestLevelMinimum,
                    aHarvestLevelMaximum,
                    aOpaque,
                    aNormalCube));
        return rBlock == null
            ? new MultiTileEntityBlock(
                aModID,
                aMaterialName,
                aMaterial,
                aSoundType,
                aTool,
                aHarvestLevelOffset,
                aHarvestLevelMinimum,
                aHarvestLevelMaximum,
                aOpaque,
                aNormalCube)
            : rBlock;
    }

    protected MultiTileEntityBlock(String aModID, String aMaterialName, Material aMaterial, SoundType aSoundType,
        String aTool, int aHarvestLevelOffset, int aHarvestLevelMinimum, int aHarvestLevelMaximum, boolean aOpaque,
        boolean aNormalCube) {
        super(aMaterial);
        if (GregTech_API.sPreloadFinished)
            throw new IllegalStateException("Blocks can only be initialized within preInit!");

        mNameInternal = getName(
            aMaterialName,
            aSoundType,
            aTool,
            aHarvestLevelOffset,
            aHarvestLevelMinimum,
            aHarvestLevelMaximum,
            aOpaque,
            aNormalCube);
        GameRegistry.registerBlock(this, ItemBlock.class, mNameInternal);

        MULTI_BLOCK_MAP.put(aModID + ":" + mNameInternal, this);

        setStepSound(aSoundType);
        mOpaque = aOpaque;
        mNormalCube = aNormalCube;

        mTool = aTool.toLowerCase();
        mHarvestLevelOffset = aHarvestLevelOffset;
        mHarvestLevelMinimum = Math.max(0, aHarvestLevelMinimum);
        mHarvestLevelMaximum = Math.max(aHarvestLevelMinimum, aHarvestLevelMaximum);

        opaque = isOpaqueCube();
        lightOpacity = isOpaqueCube() ? 255 : 0;
    }

    @Override
    public final void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) {
        final TileEntity aTileEntity = getTileEntity(aWorld, aX, aY, aZ, true);
        if (aTileEntity != null) LAST_BROKEN_TILEENTITY.set(aTileEntity);
        if (aTileEntity == null || !aTileEntity.shouldRefresh(this, aBlock, aMetaData, aMetaData, aWorld, aX, aY, aZ))
            return;
        if (aTileEntity instanceof IMTE_BreakBlock && ((IMTE_BreakBlock) aTileEntity).breakBlock()) return;
        if (aTileEntity instanceof IMTE_HasMultiBlockMachineRelevantData
            && ((IMTE_HasMultiBlockMachineRelevantData) aTileEntity).hasMultiBlockMachineRelevantData())
            GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);

        aWorld.removeTileEntity(aX, aY, aZ);
    }

    @Override
    public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, int aLogLevel) {
        final TileEntity aTileEntity = aPlayer.worldObj.getTileEntity(aX, aY, aZ);
        if (aTileEntity instanceof IDebugableTileEntity mte) {
            return mte.getDebugInfo(aPlayer, aLogLevel);
        }
        return new ArrayList<>();
    }

    @Override
    public final boolean func_149730_j /* isFullBlock */() {
        return mOpaque;
    }

    @Override
    public final boolean isNormalCube() {
        return mNormalCube;
    }

    @Override
    public final boolean renderAsNormalBlock() {
        return mOpaque || mNormalCube;
    }

    @Override
    public int getRenderType() {
        return GT_MultiTile_Renderer.INSTANCE == null ? super.getRenderType()
            : GT_MultiTile_Renderer.INSTANCE.getRenderId();
    }

    @Override
    public final float getBlockHardness(World aWorld, int aX, int aY, int aZ) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMTE_GetBlockHardness ? ((IMTE_GetBlockHardness) aTileEntity).getBlockHardness()
            : 1.0F;
    }

    @SideOnly(Side.CLIENT)
    @Override
    public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int ordinalSide) {
        return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon();
    }

    @SideOnly(Side.CLIENT)
    @Override
    public IIcon getIcon(int ordinalSide, int aMeta) {
        return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon();
    }

    @Override
    @SuppressWarnings("unchecked")
    public final void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB aAABB,
        List<AxisAlignedBB> aList, Entity aEntity) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        if (aTileEntity instanceof IMultiTileEntity)
            ((IMultiTileEntity) aTileEntity).addCollisionBoxesToList(aAABB, aList, aEntity);
        else super.addCollisionBoxesToList(aWorld, aX, aY, aZ, aAABB, aList, aEntity);
    }

    @Override
    public final AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMultiTileEntity mte ? mte.getCollisionBoundingBoxFromPool()
            : aTileEntity == null ? null : super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
    }

    @Override
    public final AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMultiTileEntity mte ? mte.getSelectedBoundingBoxFromPool()
            : super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ);
    }

    @Override
    public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) {
        final TileEntity aTileEntity = blockAccess.getTileEntity(aX, aY, aZ);
        if (aTileEntity instanceof IMultiTileEntity mte) {
            mte.setBlockBoundsBasedOnState(this);
            return;
        }
        super.setBlockBoundsBasedOnState(blockAccess, aX, aY, aZ);
    }

    @Override
    public final boolean isOpaqueCube() {
        return mOpaque;
    }

    @Override
    public final void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY,
        int aTileZ) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        if (!LOCK) {
            LOCK = true;
            if (aTileEntity instanceof BaseTileEntity)
                ((BaseTileEntity) aTileEntity).onAdjacentBlockChange(aTileX, aTileY, aTileZ);
            LOCK = false;
        }
    }

    @Override
    public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        if (!LOCK) {
            LOCK = true;
            if (aTileEntity instanceof BaseTileEntity bte) bte.onAdjacentBlockChange(aX, aY, aZ);
            LOCK = false;
        }
        if (aTileEntity instanceof IMTE_OnNeighborBlockChange change) change.onNeighborBlockChange(aWorld, aBlock);
        if (aTileEntity == null) aWorld.setBlockToAir(aX, aY, aZ);
    }

    @Override
    public final void onBlockAdded(World aWorld, int aX, int aY, int aZ) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        if (aTileEntity instanceof IMultiTileEntity mte) mte.onBlockAdded();
    }

    @Override
    public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMultiTileEntity mte && mte.privateAccess()
            && !((IMultiTileEntity) aTileEntity).playerOwnsThis(aPlayer, true) ? -1.0F
                : super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ);
    }

    @Override
    public final void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        if (aTileEntity instanceof IMultiTileEntity mte) mte.onLeftClick(aPlayer);
        else super.onBlockClicked(aWorld, aX, aY, aZ, aPlayer);
    }

    @Override
    public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int ordinalSide,
        float aHitX, float aHitY, float aHitZ) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        if (aPlayer != null && ItemList.TC_Thaumometer.isStackEqual(aPlayer.getHeldItem(), true, true)) return false;
        return aTileEntity instanceof IMultiTileEntity mte
            && mte.onBlockActivated(aPlayer, ForgeDirection.getOrientation(ordinalSide), aHitX, aHitY, aHitZ);
    }

    @Override
    public final int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMTE_IsProvidingWeakPower power
            ? power.isProvidingWeakPower(ForgeDirection.getOrientation(ordinalSide))
            : super.isProvidingWeakPower(aWorld, aX, aY, aZ, ordinalSide);
    }

    @Override
    public final int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMTE_IsProvidingStrongPower power
            ? power.isProvidingStrongPower(ForgeDirection.getOrientation(ordinalSide))
            : super.isProvidingStrongPower(aWorld, aX, aY, aZ, ordinalSide);
    }

    @Override
    public final boolean shouldCheckWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMTE_ShouldCheckWeakPower power
            ? power.shouldCheckWeakPower(ForgeDirection.getOrientation(ordinalSide))
            : isNormalCube(aWorld, aX, aY, aZ);
    }

    @Override
    public final boolean getWeakChanges(IBlockAccess aWorld, int aX, int aY, int aZ) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMTE_GetWeakChanges changes ? changes.getWeakChanges()
            : super.getWeakChanges(aWorld, aX, aY, aZ);
    }

    @Override
    public final void harvestBlock(World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ, int aMeta) {
        if (aPlayer == null) aPlayer = harvesters.get();
        aPlayer.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
        aPlayer.addExhaustion(0.025F);
        final boolean aSilkTouch = EnchantmentHelper.getSilkTouchModifier(aPlayer);
        final int aFortune = EnchantmentHelper.getFortuneModifier(aPlayer);
        float aChance = 1.0F;
        final TileEntity aTileEntity = getTileEntity(aWorld, aX, aY, aZ, true);

        if (!(aTileEntity instanceof IMultiTileEntity mte)) {
            return;
        }

        final ArrayList<ItemStack> tList = mte.getDrops(aFortune, aSilkTouch);
        aChance = ForgeEventFactory
            .fireBlockHarvesting(tList, aWorld, this, aX, aY, aZ, aMeta, aFortune, aChance, aSilkTouch, aPlayer);
        for (final ItemStack tStack : tList)
            if (XSTR.XSTR_INSTANCE.nextFloat() <= aChance) dropBlockAsItem(aWorld, aX, aY, aZ, tStack);

    }

    @Override
    public final boolean shouldSideBeRendered(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) {
        final TileEntity aTileEntity = aWorld
            .getTileEntity(aX - OFFX[ordinalSide], aY - OFFY[ordinalSide], aZ - OFFZ[ordinalSide]);
        return aTileEntity instanceof IMultiTileEntity mte
            ? mte.shouldSideBeRendered(ForgeDirection.getOrientation(ordinalSide))
            : super.shouldSideBeRendered(aWorld, aX, aY, aZ, ordinalSide);
    }

    @Override
    public Block getFacade(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) {
        final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        if (tTileEntity instanceof CoverableTileEntity tile) {
            final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide);
            if (ordinalSide != -1) {
                final Block facadeBlock = tile.getCoverInfoAtSide(side)
                    .getFacadeBlock();
                if (facadeBlock != null) return facadeBlock;
            } else {
                // we do not allow more than one type of facade per block, so no need to check every side
                // see comment in gregtech.common.covers.GT_Cover_FacadeBase.isCoverPlaceable
                for (final ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) {
                    final Block facadeBlock = tile.getCoverInfoAtSide(tSide)
                        .getFacadeBlock();
                    if (facadeBlock != null) {
                        return facadeBlock;
                    }
                }
            }
        }
        return Blocks.air;
    }

    @Override
    public int getFacadeMetadata(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) {
        final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        if (tTileEntity instanceof CoverableTileEntity tile) {
            final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide);
            if (ordinalSide != -1) {
                final CoverInfo coverInfo = tile.getCoverInfoAtSide(side);
                final Block facadeBlock = coverInfo.getFacadeBlock();
                if (facadeBlock != null) return coverInfo.getFacadeMeta();
            } else {
                // we do not allow more than one type of facade per block, so no need to check every side
                // see comment in gregtech.common.covers.GT_Cover_FacadeBase.isCoverPlaceable
                for (final ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) {
                    final CoverInfo coverInfo = tile.getCoverInfoAtSide(tSide);
                    final Block facadeBlock = coverInfo.getFacadeBlock();
                    if (facadeBlock != null) {
                        return coverInfo.getFacadeMeta();
                    }
                }
            }
        }
        return 0;
    }

    @Override
    protected boolean canSilkHarvest() {
        return false;
    }

    @Override
    public final boolean canProvidePower() {
        return !mNormalCube;
    }

    @Override
    public final String getLocalizedName() {
        return StatCollector.translateToLocal(mNameInternal + ".name");
    }

    @Override
    public final String getUnlocalizedName() {
        return mNameInternal;
    }

    @Override
    public final boolean onBlockEventReceived(World aWorld, int aX, int aY, int aZ, int aID, int aData) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity == null || aTileEntity.receiveClientEvent(aID, aData);
    }

    @Override
    public final void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, List<ItemStack> aList) {
        /**/
    }

    @Override
    public boolean hasComparatorInputOverride() {
        return true;
    }

    @Override
    public final int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int ordinalSide) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        if (aTileEntity instanceof IMTE_GetComparatorInputOverride override) {
            return override.getComparatorInputOverride(ForgeDirection.getOrientation(ordinalSide));
        }

        if (aTileEntity instanceof IMTE_IsProvidingWeakPower power) {
            return power.isProvidingWeakPower(
                ForgeDirection.getOrientation(ordinalSide)
                    .getOpposite());
        }

        return super.getComparatorInputOverride(aWorld, aX, aY, aZ, ordinalSide);
    }

    @Override
    public final void registerBlockIcons(IIconRegister aIconRegister) {
        /**/
    }

    @Override
    public final boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) {
        return mNormalCube;
    }

    @Override
    public final boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection side) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMultiTileEntity mte ? mte.isSideSolid(side) : mOpaque;
    }

    @Override
    public boolean removedByPlayer(World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ, boolean aWillHarvest) {
        final TileEntity aTileEntity = GT_Util.getTileEntity(aWorld, aX, aY, aZ, true);
        if (aTileEntity != null) LAST_BROKEN_TILEENTITY.set(aTileEntity);
        return super.removedByPlayer(aWorld, aPlayer, aX, aY, aZ, aWillHarvest);
    }

    @Override
    public int getFlammability(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) {
        return 0;
    }

    @Override
    public int getFireSpreadSpeed(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) {
        return GregTech_API.sMachineFlammable && (aWorld.getBlockMetadata(aX, aY, aZ) == 0) ? 100 : 0;
    }

    @Override
    public boolean hasTileEntity(int aMeta) {
        return true;
    }

    @Override
    public final ArrayList<ItemStack> getDrops(World aWorld, int aX, int aY, int aZ, int aUnusableMetaData,
        int aFortune) {
        final TileEntity aTileEntity = getTileEntity(aWorld, aX, aY, aZ, true);
        if (aTileEntity instanceof IMultiTileEntity mte) return mte.getDrops(aFortune, false);
        return new ArrayList<>();
    }

    @Override
    public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int aX, int aY, int aZ) {
        return false;
    }

    @Override
    public final float getExplosionResistance(Entity aExploder, World aWorld, int aX, int aY, int aZ,
        double aExplosionX, double aExplosionY, double aExplosionZ) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMultiTileEntity mte
            ? mte.getExplosionResistance(aExploder, aExplosionX, aExplosionY, aExplosionZ)
            : 1.0F;
    }

    @Override
    public final void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) {
        if (aWorld.isRemote) return;
        final TileEntity aTileEntity = getTileEntity(aWorld, aX, aY, aZ, true);
        if (aTileEntity != null) LAST_BROKEN_TILEENTITY.set(aTileEntity);
        if (aTileEntity instanceof IMultiTileEntity mte) {
            GT_Log.exp.printf(
                "Explosion at : %d | %d | %d DIMID: %s due to near explosion!%n",
                aX,
                aY,
                aZ,
                aWorld.provider.dimensionId);
            mte.onExploded(aExplosion);
        } else aWorld.setBlockToAir(aX, aY, aZ);
    }

    @Override
    public final boolean canConnectRedstone(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) {
        return true;
    }

    @Override
    public final boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection side, int aColor) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMultiTileEntity mte && mte.recolourBlock(side, (byte) aColor);
    }

    @Override
    public final String getHarvestTool(int aMeta) {
        return mTool;
    }

    @Override
    public final int getHarvestLevel(int aMeta) {
        return Math.max(mHarvestLevelMinimum, Math.min(mHarvestLevelMaximum, mHarvestLevelOffset + aMeta));
    }

    @Override
    public final boolean isToolEffective(String aType, int aMeta) {
        return getHarvestTool(aMeta).equals(aType);
    }

    @Override
    public final ItemStack getPickBlock(MovingObjectPosition aTarget, World aWorld, int aX, int aY, int aZ,
        EntityPlayer aPlayer) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMultiTileEntity mte ? mte.getPickBlock(aTarget) : null;
    }

    @Override
    public final ItemStack getPickBlock(MovingObjectPosition aTarget, World aWorld, int aX, int aY, int aZ) {
        final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);
        return aTileEntity instanceof IMultiTileEntity mte ? mte.getPickBlock(aTarget) : null;
    }

    public final IMultiTileEntity receiveMultiTileEntityData(IBlockAccess aWorld, int aX, short aY, int aZ, short aRID,
        short aID) {
        if (!(aWorld instanceof World)) return null;
        TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ);

        if (!(aTileEntity instanceof IMultiTileEntity mte) || mte.getMultiTileEntityRegistryID() != aRID
            || mte.getMultiTileEntityID() != aID) {
            final MultiTileEntityRegistry tRegistry = MultiTileEntityRegistry.getRegistry(aRID);
            if (tRegistry == null) return null;

            aTileEntity = tRegistry.getNewTileEntity((World) aWorld, aX, aY, aZ, aID);
            if (!(aTileEntity instanceof IMultiTileEntity)) return null;

            setTileEntity((World) aWorld, aX, aY, aZ, aTileEntity, false);
        }
        return (IMultiTileEntity) aTileEntity;
    }

    public void receiveCoverData(IMultiTileEntity mte, int aCover0, int aCover1, int aCover2, int aCover3, int aCover4,
        int aCover5) {
        boolean updated;
        updated = mte.setCoverIDAtSideNoUpdate(ForgeDirection.DOWN, aCover0);
        updated |= mte.setCoverIDAtSideNoUpdate(ForgeDirection.UP, aCover1);
        updated |= mte.setCoverIDAtSideNoUpdate(ForgeDirection.NORTH, aCover2);
        updated |= mte.setCoverIDAtSideNoUpdate(ForgeDirection.SOUTH, aCover3);
        updated |= mte.setCoverIDAtSideNoUpdate(ForgeDirection.WEST, aCover4);
        updated |= mte.setCoverIDAtSideNoUpdate(ForgeDirection.EAST, aCover5);

        if (updated) {
            mte.issueBlockUpdate();
        }
    }

    @Override
    public final TileEntity createTileEntity(World aWorld, int aMeta) {
        return null;
    }

    @Override
    public TileEntity createNewTileEntity(World world, int i) {
        return null;
    }
}