Search in sources :

Example 11 with MetaTileEntity

use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.

the class BlockMachine method getDrops.

@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
    MetaTileEntity metaTileEntity = tileEntities.get() == null ? getMetaTileEntity(world, pos) : tileEntities.get();
    if (metaTileEntity == null)
        return;
    if (!metaTileEntity.shouldDropWhenDestroyed())
        return;
    ItemStack itemStack = metaTileEntity.getStackForm();
    NBTTagCompound tagCompound = new NBTTagCompound();
    metaTileEntity.writeItemStackData(tagCompound);
    // only set item tag if it's not empty, so newly created items will stack with dismantled
    if (!tagCompound.isEmpty())
        itemStack.setTagCompound(tagCompound);
    drops.add(itemStack);
    metaTileEntity.getDrops(drops, harvesters.get());
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) ItemStack(net.minecraft.item.ItemStack)

Example 12 with MetaTileEntity

use of gregtech.api.metatileentity.MetaTileEntity in project TecTech by Technus.

the class GT_MetaTileEntity_MultiblockBase_EM method explodeMultiblock.

@Override
public final void explodeMultiblock() {
    if (explodedThisTick) {
        return;
    }
    explodedThisTick = true;
    if (!TecTech.ModConfig.BOOM_ENABLE) {
        TecTech.proxy.broadcast("Multi Explode BOOM! " + getBaseMetaTileEntity().getXCoord() + ' ' + getBaseMetaTileEntity().getYCoord() + ' ' + getBaseMetaTileEntity().getZCoord());
        StackTraceElement[] ste = Thread.currentThread().getStackTrace();
        TecTech.proxy.broadcast("Multi Explode BOOM! " + ste[2].toString());
        return;
    }
    extraExplosions_EM();
    GT_Pollution.addPollution(getBaseMetaTileEntity(), 600000);
    mInventory[1] = null;
    for (MetaTileEntity tTileEntity : mInputBusses) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]);
    }
    for (MetaTileEntity tTileEntity : mOutputBusses) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]);
    }
    for (MetaTileEntity tTileEntity : mInputHatches) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]);
    }
    for (MetaTileEntity tTileEntity : mOutputHatches) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]);
    }
    for (MetaTileEntity tTileEntity : mDynamoHatches) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]);
    }
    for (MetaTileEntity tTileEntity : mMufflerHatches) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]);
    }
    for (MetaTileEntity tTileEntity : mEnergyHatches) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]);
    }
    for (MetaTileEntity tTileEntity : mMaintenanceHatches) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]);
    }
    for (MetaTileEntity tTileEntity : eParamHatches) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]);
    }
    for (MetaTileEntity tTileEntity : eInputHatches) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]);
    }
    for (MetaTileEntity tTileEntity : eOutputHatches) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]);
    }
    for (MetaTileEntity tTileEntity : eMufflerHatches) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]);
    }
    for (MetaTileEntity tTileEntity : eEnergyMulti) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]);
    }
    for (MetaTileEntity tTileEntity : eUncertainHatches) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]);
    }
    for (MetaTileEntity tTileEntity : eDynamoMulti) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]);
    }
    for (MetaTileEntity tTileEntity : eInputData) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]);
    }
    for (MetaTileEntity tTileEntity : eOutputData) {
        tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]);
    }
    getBaseMetaTileEntity().doExplosion(V[15]);
}
Also used : IMetaTileEntity(gregtech.api.interfaces.metatileentity.IMetaTileEntity) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity)

Example 13 with MetaTileEntity

use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.

the class MachineSubtypeHandler method apply.

@Override
public String apply(ItemStack itemStack) {
    String additionalData = "";
    MetaTileEntity metaTileEntity = MachineItemBlock.getMetaTileEntity(itemStack);
    if (metaTileEntity != null) {
        additionalData = metaTileEntity.getItemSubTypeId(itemStack);
    }
    return String.format("%d;%s", itemStack.getMetadata(), additionalData);
}
Also used : MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity)

Example 14 with MetaTileEntity

use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.

the class GTJeiPlugin method register.

@Override
public void register(IModRegistry registry) {
    IJeiHelpers jeiHelpers = registry.getJeiHelpers();
    registry.addRecipes(IntCircuitRecipeWrapper.create(), IntCircuitCategory.UID);
    MultiblockInfoCategory.registerRecipes(registry);
    registry.handleRecipes(CustomItemReturnShapedOreRecipeRecipe.class, recipe -> new CustomItemReturnRecipeWrapper(jeiHelpers, recipe), VanillaRecipeCategoryUid.CRAFTING);
    registry.addRecipeRegistryPlugin(new FacadeRegistryPlugin());
    ModularUIGuiHandler modularUIGuiHandler = new ModularUIGuiHandler(jeiHelpers.recipeTransferHandlerHelper());
    registry.addAdvancedGuiHandlers(modularUIGuiHandler);
    registry.addGhostIngredientHandler(modularUIGuiHandler.getGuiContainerClass(), modularUIGuiHandler);
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(modularUIGuiHandler, VanillaRecipeCategoryUid.CRAFTING);
    for (RecipeMap<?> recipeMap : RecipeMap.getRecipeMaps()) {
        List<GTRecipeWrapper> recipesList = recipeMap.getRecipeList().stream().filter(recipe -> !recipe.isHidden() && recipe.hasValidInputsForDisplay()).map(GTRecipeWrapper::new).collect(Collectors.toList());
        registry.addRecipes(recipesList, GTValues.MODID + ":" + recipeMap.unlocalizedName);
    }
    for (FuelRecipeMap fuelRecipeMap : FuelRecipeMap.getRecipeMaps()) {
        List<GTFuelRecipeWrapper> recipeList = fuelRecipeMap.getRecipeList().stream().map(GTFuelRecipeWrapper::new).collect(Collectors.toList());
        registry.addRecipes(recipeList, GTValues.MODID + ":" + fuelRecipeMap.unlocalizedName);
    }
    for (ResourceLocation metaTileEntityId : GregTechAPI.META_TILE_ENTITY_REGISTRY.getKeys()) {
        MetaTileEntity metaTileEntity = GregTechAPI.META_TILE_ENTITY_REGISTRY.getObject(metaTileEntityId);
        assert metaTileEntity != null;
        if (metaTileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_CONTROLLABLE, null) != null) {
            IControllable workableCapability = metaTileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_CONTROLLABLE, null);
            if (workableCapability instanceof AbstractRecipeLogic) {
                RecipeMap<?> recipeMap = ((AbstractRecipeLogic) workableCapability).recipeMap;
                registry.addRecipeCatalyst(metaTileEntity.getStackForm(), GTValues.MODID + ":" + recipeMap.unlocalizedName);
                if (recipeMap instanceof RecipeMapFurnace) {
                    registry.addRecipeCatalyst(metaTileEntity.getStackForm(), VanillaRecipeCategoryUid.SMELTING);
                }
            } else if (workableCapability instanceof FuelRecipeLogic) {
                FuelRecipeMap recipeMap = ((FuelRecipeLogic) workableCapability).recipeMap;
                registry.addRecipeCatalyst(metaTileEntity.getStackForm(), GTValues.MODID + ":" + recipeMap.unlocalizedName);
            }
        }
    }
    for (MetaTileEntity breweryTile : MetaTileEntities.BREWERY) {
        registry.addRecipeCatalyst(breweryTile.getStackForm(), VanillaRecipeCategoryUid.BREWING);
    }
    String semiFluidMapId = GTValues.MODID + ":" + RecipeMaps.SEMI_FLUID_GENERATOR_FUELS.getUnlocalizedName();
    registry.addRecipeCatalyst(MetaTileEntities.LARGE_BRONZE_BOILER.getStackForm(), semiFluidMapId);
    registry.addRecipeCatalyst(MetaTileEntities.LARGE_STEEL_BOILER.getStackForm(), semiFluidMapId);
    registry.addRecipeCatalyst(MetaTileEntities.LARGE_TITANIUM_BOILER.getStackForm(), semiFluidMapId);
    registry.addRecipeCatalyst(MetaTileEntities.LARGE_TUNGSTENSTEEL_BOILER.getStackForm(), semiFluidMapId);
    registry.addIngredientInfo(Objects.requireNonNull(Materials.Air.getFluid(1000)), VanillaTypes.FLUID, I18n.format("gregtech.machine.air_collector.jei_description"));
    String primitiveBlastId = GTValues.MODID + ":" + "primitive_blast_furnace";
    registry.addRecipes(RecipeMaps.PRIMITIVE_BLAST_FURNACE_RECIPES.stream().map(PrimitiveBlastRecipeWrapper::new).collect(Collectors.toList()), primitiveBlastId);
    registry.addRecipeCatalyst(MetaTileEntities.PRIMITIVE_BLAST_FURNACE.getStackForm(), primitiveBlastId);
    String cokeOvenId = GTValues.MODID + ":" + "coke_oven";
    registry.addRecipes(RecipeMaps.COKE_OVEN_RECIPES.stream().map(CokeOvenRecipeWrapper::new).collect(Collectors.toList()), cokeOvenId);
    registry.addRecipeCatalyst(MetaTileEntities.COKE_OVEN.getStackForm(), cokeOvenId);
    List<OreByProduct> oreByproductList = new CopyOnWriteArrayList<>();
    for (Material material : Material.MATERIAL_REGISTRY) {
        if (material instanceof DustMaterial && OreDictUnifier.get(OrePrefix.ore, material) != ItemStack.EMPTY) {
            final OreByProduct oreByProduct = new OreByProduct((DustMaterial) material);
            if (oreByProduct.hasByProducts())
                oreByproductList.add(oreByProduct);
        }
    }
    String oreByProductId = GTValues.MODID + ":" + "ore_by_product";
    registry.addRecipes(oreByproductList, oreByProductId);
    for (MetaTileEntity machine : MetaTileEntities.MACERATOR) registry.addRecipeCatalyst(machine.getStackForm(), oreByProductId);
    for (MetaTileEntity machine : MetaTileEntities.ORE_WASHER) registry.addRecipeCatalyst(machine.getStackForm(), oreByProductId);
    for (MetaTileEntity machine : MetaTileEntities.CENTRIFUGE) registry.addRecipeCatalyst(machine.getStackForm(), oreByProductId);
    for (MetaTileEntity machine : MetaTileEntities.THERMAL_CENTRIFUGE) registry.addRecipeCatalyst(machine.getStackForm(), oreByProductId);
    for (MetaTileEntity machine : MetaTileEntities.CHEMICAL_BATH) registry.addRecipeCatalyst(machine.getStackForm(), oreByProductId);
    // Ore Veins
    List<OreDepositDefinition> oreVeins = WorldGenRegistry.getOreDeposits();
    List<GTOreInfo> oreInfoList = new CopyOnWriteArrayList<>();
    for (OreDepositDefinition vein : oreVeins) {
        oreInfoList.add(new GTOreInfo(vein));
    }
    String oreSpawnID = GTValues.MODID + ":" + "ore_spawn_location";
    registry.addRecipes(oreInfoList, oreSpawnID);
    registry.addRecipeCatalyst(MetaItems.SCANNER.getStackForm(), oreSpawnID);
    // Ore Veins End
    ingredientRegistry = registry.getIngredientRegistry();
    for (int i = 0; i <= IntCircuitIngredient.CIRCUIT_MAX; i++) {
        registry.addIngredientInfo(IntCircuitIngredient.getIntegratedCircuit(i), VanillaTypes.ITEM, "metaitem.circuit.integrated.jei_description");
    }
    registry.addRecipeCatalyst(MetaTileEntities.WORKBENCH.getStackForm(), VanillaRecipeCategoryUid.CRAFTING);
    for (MetaTileEntity machine : MetaTileEntities.FLUID_CANNER) {
        registry.addIngredientInfo(machine.getStackForm(), VanillaTypes.ITEM, "gregtech.machine.fluid_canner.jei_description");
    }
    // Multiblock info page registration
    MultiblockInfoCategory.multiblockRecipes.values().forEach(v -> {
        MultiblockInfoPage infoPage = v.getInfoPage();
        registry.addIngredientInfo(infoPage.getController().getStackForm(), VanillaTypes.ITEM, infoPage.getDescription());
    });
}
Also used : OreDepositDefinition(gregtech.api.worldgen.config.OreDepositDefinition) ResourceLocation(net.minecraft.util.ResourceLocation) CustomItemReturnRecipeWrapper(gregtech.integration.jei.utils.CustomItemReturnRecipeWrapper) ModularUIGuiHandler(gregtech.api.gui.impl.ModularUIGuiHandler) AbstractRecipeLogic(gregtech.api.capability.impl.AbstractRecipeLogic) IControllable(gregtech.api.capability.IControllable) Material(gregtech.api.unification.material.type.Material) DustMaterial(gregtech.api.unification.material.type.DustMaterial) FuelRecipeMap(gregtech.api.recipes.machines.FuelRecipeMap) GTFuelRecipeWrapper(gregtech.integration.jei.recipe.fuel.GTFuelRecipeWrapper) RecipeMapFurnace(gregtech.api.recipes.machines.RecipeMapFurnace) MultiblockInfoPage(gregtech.integration.jei.multiblock.MultiblockInfoPage) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) FuelRecipeLogic(gregtech.api.capability.impl.FuelRecipeLogic) DustMaterial(gregtech.api.unification.material.type.DustMaterial) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 15 with MetaTileEntity

use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.

the class TransformerInfoProvider method addProbeInfo.

@Override
protected void addProbeInfo(IEnergyContainer capability, IProbeInfo probeInfo, TileEntity tileEntity, EnumFacing sideHit) {
    if (tileEntity instanceof MetaTileEntityHolder) {
        MetaTileEntity metaTileEntity = ((MetaTileEntityHolder) tileEntity).getMetaTileEntity();
        if (metaTileEntity instanceof MetaTileEntityTransformer) {
            MetaTileEntityTransformer mteTransformer = (MetaTileEntityTransformer) metaTileEntity;
            String inputVoltageN = GTValues.VN[GTUtility.getTierByVoltage(capability.getInputVoltage())];
            String outputVoltageN = GTValues.VN[GTUtility.getTierByVoltage(capability.getOutputVoltage())];
            long inputAmperage = capability.getInputAmperage();
            long outputAmperage = capability.getOutputAmperage();
            IProbeInfo horizontalPane = probeInfo.vertical(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER));
            String transformInfo;
            // Step Up/Step Down line
            if (mteTransformer.isInverted()) {
                transformInfo = "{*gregtech.top.transform_up*} ";
            } else {
                transformInfo = "{*gregtech.top.transform_down*} ";
            }
            transformInfo += inputVoltageN + " (" + inputAmperage + "A) -> " + outputVoltageN + " (" + outputAmperage + "A)";
            horizontalPane.text(TextStyleClass.INFO + transformInfo);
            // Input/Output side line
            horizontalPane = probeInfo.vertical(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER));
            if (capability.inputsEnergy(sideHit)) {
                transformInfo = "{*gregtech.top.transform_input*} " + inputVoltageN + " (" + inputAmperage + "A)";
                horizontalPane.text(TextStyleClass.INFO + transformInfo);
            } else if (capability.outputsEnergy(sideHit)) {
                transformInfo = "{*gregtech.top.transform_output*} " + outputVoltageN + " (" + outputAmperage + "A)";
                horizontalPane.text(TextStyleClass.INFO + transformInfo);
            }
        }
    }
}
Also used : MetaTileEntityHolder(gregtech.api.metatileentity.MetaTileEntityHolder) MetaTileEntityTransformer(gregtech.common.metatileentities.electric.MetaTileEntityTransformer) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) IProbeInfo(mcjty.theoneprobe.api.IProbeInfo)

Aggregations

MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)25 IFastRenderMetaTileEntity (gregtech.api.metatileentity.IFastRenderMetaTileEntity)6 CCRenderState (codechicken.lib.render.CCRenderState)5 ItemStack (net.minecraft.item.ItemStack)5 Matrix4 (codechicken.lib.vec.Matrix4)4 IRenderMetaTileEntity (gregtech.api.metatileentity.IRenderMetaTileEntity)4 MetaTileEntityHolder (gregtech.api.metatileentity.MetaTileEntityHolder)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 ArrayList (java.util.ArrayList)3 CuboidRayTraceResult (codechicken.lib.raytracer.CuboidRayTraceResult)2 IndexedCuboid6 (codechicken.lib.raytracer.IndexedCuboid6)2 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)2 IMetaTileEntity (gregtech.api.interfaces.metatileentity.IMetaTileEntity)2 ITieredMetaTileEntity (gregtech.api.metatileentity.ITieredMetaTileEntity)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EnumFacing (net.minecraft.util.EnumFacing)2 ColourMultiplier (codechicken.lib.render.pipeline.ColourMultiplier)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Vector3 (codechicken.lib.vec.Vector3)1