Search in sources :

Example 1 with IConstructable

use of com.github.technus.tectech.thing.metaTileEntity.IConstructable in project TecTech by Technus.

the class ConstructableTriggerItem method onItemUseFirst.

@Override
public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) {
    TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
    if (tTileEntity == null || aPlayer instanceof FakePlayer) {
        return aPlayer instanceof EntityPlayerMP;
    }
    if (aPlayer instanceof EntityPlayerMP) {
        // struct gen
        if (aPlayer.isSneaking() && aPlayer.capabilities.isCreativeMode) {
            if (tTileEntity instanceof IGregTechTileEntity) {
                IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();
                if (metaTE instanceof IConstructable) {
                    ((IConstructable) metaTE).construct(aStack.stackSize, false);
                } else if (multiblockMap.containsKey(metaTE.getClass().getCanonicalName())) {
                    multiblockMap.get(metaTE.getClass().getCanonicalName()).construct(aStack.stackSize, false, tTileEntity, ((IGregTechTileEntity) tTileEntity).getFrontFacing());
                }
            } else if (tTileEntity instanceof IConstructable) {
                ((IConstructable) tTileEntity).construct(aStack.stackSize, false);
            } else if (multiblockMap.containsKey(tTileEntity.getClass().getCanonicalName())) {
                multiblockMap.get(tTileEntity.getClass().getCanonicalName()).construct(aStack.stackSize, false, tTileEntity, aSide);
            }
        }
        return true;
    } else if (aPlayer instanceof EntityClientPlayerMP) {
        // if ((!aPlayer.isSneaking() || !aPlayer.capabilities.isCreativeMode)) {
        if (tTileEntity instanceof IGregTechTileEntity) {
            IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();
            if (metaTE instanceof IConstructable) {
                ((IConstructable) metaTE).construct(aStack.stackSize, true);
                TecTech.proxy.printInchat(((IConstructable) metaTE).getStructureDescription(aStack.stackSize));
                return false;
            } else if (multiblockMap.containsKey(metaTE.getClass().getCanonicalName())) {
                multiblockMap.get(metaTE.getClass().getCanonicalName()).construct(aStack.stackSize, true, tTileEntity, ((IGregTechTileEntity) tTileEntity).getFrontFacing());
                TecTech.proxy.printInchat(multiblockMap.get(metaTE.getClass().getCanonicalName()).getDescription(aStack.stackSize));
                return false;
            }
        } else if (tTileEntity instanceof IConstructable) {
            ((IConstructable) tTileEntity).construct(aStack.stackSize, true);
            TecTech.proxy.printInchat(((IConstructable) tTileEntity).getStructureDescription(aStack.stackSize));
            return false;
        } else if (multiblockMap.containsKey(tTileEntity.getClass().getCanonicalName())) {
            multiblockMap.get(tTileEntity.getClass().getCanonicalName()).construct(aStack.stackSize, true, tTileEntity, aSide);
            TecTech.proxy.printInchat(multiblockMap.get(tTileEntity.getClass().getCanonicalName()).getDescription(aStack.stackSize));
            return false;
        }
    // } else {
    // if(tTileEntity instanceof IGregTechTileEntity) {
    // IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();
    // if (metaTE instanceof IConstructable) {
    // TecTech.proxy.printInchat(((IConstructable) metaTE).getStructureDescription(aStack.stackSize));
    // return false;
    // } else if(multiblockMap.containsKey(metaTE.getClass().getCanonicalName())){
    // TecTech.proxy.printInchat(multiblockMap.get(metaTE.getClass().getCanonicalName()).getDescription(aStack.stackSize));
    // return false;
    // }
    // } else if(tTileEntity instanceof IConstructable){
    // TecTech.proxy.printInchat(((IConstructable) tTileEntity).getStructureDescription(aStack.stackSize));
    // return false;
    // } else if(multiblockMap.containsKey(tTileEntity.getClass().getCanonicalName())){
    // TecTech.proxy.printInchat(multiblockMap.get(tTileEntity.getClass().getCanonicalName()).getDescription(aStack.stackSize));
    // return false;
    // }
    // }
    }
    return false;
}
Also used : IGregTechTileEntity(gregtech.api.interfaces.tileentity.IGregTechTileEntity) IMetaTileEntity(gregtech.api.interfaces.metatileentity.IMetaTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) IGregTechTileEntity(gregtech.api.interfaces.tileentity.IGregTechTileEntity) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IConstructable(com.github.technus.tectech.thing.metaTileEntity.IConstructable) FakePlayer(net.minecraftforge.common.util.FakePlayer) IMetaTileEntity(gregtech.api.interfaces.metatileentity.IMetaTileEntity)

Aggregations

IConstructable (com.github.technus.tectech.thing.metaTileEntity.IConstructable)1 IMetaTileEntity (gregtech.api.interfaces.metatileentity.IMetaTileEntity)1 IGregTechTileEntity (gregtech.api.interfaces.tileentity.IGregTechTileEntity)1 EntityClientPlayerMP (net.minecraft.client.entity.EntityClientPlayerMP)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 TileEntity (net.minecraft.tileentity.TileEntity)1 FakePlayer (net.minecraftforge.common.util.FakePlayer)1