gregtech.api.metatileentity.MetaTileEntity Java Examples
The following examples show how to use
gregtech.api.metatileentity.MetaTileEntity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetaTileEntityRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void renderItem(ItemStack rawStack, TransformType transformType) { ItemStack stack = ModCompatibility.getRealItemStack(rawStack); if (!(stack.getItem() instanceof MachineItemBlock)) { return; } MetaTileEntity metaTileEntity = MachineItemBlock.getMetaTileEntity(stack); if (metaTileEntity == null) { return; } GlStateManager.enableBlend(); CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM); metaTileEntity.setRenderContextStack(stack); metaTileEntity.renderMetaTileEntity(renderState, new Matrix4(), new IVertexOperation[0]); if(metaTileEntity instanceof IFastRenderMetaTileEntity) { ((IFastRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityFast(renderState, new Matrix4(), 0.0f); } metaTileEntity.setRenderContextStack(null); renderState.draw(); if(metaTileEntity instanceof IRenderMetaTileEntity) { ((IRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityDynamic(0.0, 0.0, 0.0, 0.0f); } GlStateManager.disableBlend(); }
Example #2
Source File: MetaTileEntityTank.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
private MetaTileEntityTank getControllerEntity() { if (controllerPos == null) { return null; } MetaTileEntityTank cachedController = controllerCache.get(); if (cachedController != null) { if (cachedController.isValid()) { return cachedController; } else { controllerCache.clear(); } } MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(getWorld(), controllerPos); if (metaTileEntity instanceof MetaTileEntityTank) { this.controllerCache = new WeakReference<>((MetaTileEntityTank) metaTileEntity); return (MetaTileEntityTank) metaTileEntity; } return null; }
Example #3
Source File: MetaTileEntityRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) { MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos); ArrayList<IndexedCuboid6> boundingBox = new ArrayList<>(); if (metaTileEntity != null) { metaTileEntity.addCollisionBoundingBox(boundingBox); metaTileEntity.addCoverCollisionBoundingBox(boundingBox); } CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite)); for (Cuboid6 cuboid : boundingBox) { BlockRenderer.renderCuboid(renderState, cuboid, 0); } }
Example #4
Source File: AbstractRecipeLogic.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
protected void completeRecipe() { MetaTileEntity.addItemsToItemHandler(getOutputInventory(), false, itemOutputs); MetaTileEntity.addFluidsToFluidHandler(getOutputTank(), false, fluidOutputs); this.progressTime = 0; setMaxProgress(0); this.recipeEUt = 0; this.fluidOutputs = null; this.itemOutputs = null; this.hasNotEnoughEnergy = false; this.wasActiveAndNeedsUpdate = true; //force recipe recheck because inputs could have changed since last time //we checked them before starting our recipe, especially if recipe took long time this.forceRecipeRecheck = true; }
Example #5
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos); if (metaTileEntity == null) return state; return ((IExtendedBlockState) state) .withProperty(HARVEST_TOOL, metaTileEntity.getHarvestTool()) .withProperty(HARVEST_LEVEL, metaTileEntity.getHarvestLevel()); }
Example #6
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) { MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos); if (metaTileEntity == null || !metaTileEntity.isValidFrontFacing(axis) || metaTileEntity.getFrontFacing() == axis || !metaTileEntity.hasFrontFacing()) return false; metaTileEntity.setFrontFacing(axis); return true; }
Example #7
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
private List<IndexedCuboid6> getCollisionBox(IBlockAccess blockAccess, BlockPos pos) { MetaTileEntity metaTileEntity = getMetaTileEntity(blockAccess, pos); if (metaTileEntity == null) return EMPTY_COLLISION_BOX; ArrayList<IndexedCuboid6> collisionList = new ArrayList<>(); metaTileEntity.addCollisionBoundingBox(collisionList); metaTileEntity.addCoverCollisionBoundingBox(collisionList); return collisionList; }
Example #8
Source File: MetaTileEntityTESR.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void renderTileEntityFast(MetaTileEntityHolder te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer) { MetaTileEntity metaTileEntity = te.getMetaTileEntity(); if (metaTileEntity instanceof IFastRenderMetaTileEntity) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setBrightness(te.getWorld(), te.getPos()); Matrix4 translation = new Matrix4().translate(x, y, z); ((IFastRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityFast(renderState, translation, partialTicks); } }
Example #9
Source File: CoverConveyor.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onRemoved() { NonNullList<ItemStack> drops = NonNullList.create(); MetaTileEntity.clearInventory(drops, itemFilterContainer.getFilterInventory()); for (ItemStack itemStack : drops) { Block.spawnAsEntity(coverHolder.getWorld(), coverHolder.getPos(), itemStack); } }
Example #10
Source File: MetaTileEntityTESR.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void render(MetaTileEntityHolder te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { if(te instanceof IFastRenderMetaTileEntity) { renderTileEntityFastPart(te, x, y, z, partialTicks, destroyStage); } if(te instanceof IRenderMetaTileEntity) { MetaTileEntity metaTileEntity = te.getMetaTileEntity(); if (metaTileEntity instanceof IRenderMetaTileEntity) { ((IRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityDynamic(x, y, z, partialTicks); } } }
Example #11
Source File: DebugPipeNetInfoProvider.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) { if (mode == ProbeMode.DEBUG && ConfigHolder.debug) { TileEntity tileEntity = world.getTileEntity(data.getPos()); if (tileEntity instanceof MetaTileEntityHolder) { MetaTileEntity metaTileEntity = ((MetaTileEntityHolder) tileEntity).getMetaTileEntity(); if (metaTileEntity != null) { ArrayList<String> arrayList = new ArrayList<>(); arrayList.add("MetaTileEntity Id: " + metaTileEntity.metaTileEntityId); metaTileEntity.addDebugInfo(arrayList); arrayList.forEach(probeInfo::text); } } if (tileEntity instanceof TileEntityPipeBase) { IPipeTile<?, ?> pipeTile = (IPipeTile<?, ?>) tileEntity; BlockPipe<?, ?, ?> blockPipe = pipeTile.getPipeBlock(); PipeNet<?> pipeNet = blockPipe.getWorldPipeNet(world).getNetFromPos(data.getPos()); if (pipeNet != null) { probeInfo.text("Net: " + pipeNet.hashCode()); probeInfo.text("Node Info: "); StringBuilder builder = new StringBuilder(); Map<BlockPos, ? extends Node<?>> nodeMap = pipeNet.getAllNodes(); Node<?> node = nodeMap.get(data.getPos()); builder.append("{").append("active: ").append(node.isActive) .append(", mark: ").append(node.mark) .append(", blocked: ").append(node.blockedConnections).append("}"); probeInfo.text(builder.toString()); } probeInfo.text("tile blocked: " + pipeTile.getBlockedConnections()); if (blockPipe instanceof BlockFluidPipe) { if (pipeTile instanceof TileEntityFluidPipeTickable) { probeInfo.text("tile active: " + ((TileEntityFluidPipeTickable) pipeTile).isActive()); } } } } }
Example #12
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { MetaTileEntityHolder holder = (MetaTileEntityHolder) worldIn.getTileEntity(pos); MetaTileEntity sampleMetaTileEntity = GregTechAPI.META_TILE_ENTITY_REGISTRY.getObjectById(stack.getItemDamage()); if (holder != null && sampleMetaTileEntity != null) { MetaTileEntity metaTileEntity = holder.setMetaTileEntity(sampleMetaTileEntity); if (stack.hasTagCompound()) { metaTileEntity.initFromItemStackData(stack.getTagCompound()); } EnumFacing placeFacing = placer.getHorizontalFacing().getOpposite(); if (metaTileEntity.isValidFrontFacing(placeFacing)) { metaTileEntity.setFrontFacing(placeFacing); } } }
Example #13
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos); if (metaTileEntity != null) { NonNullList<ItemStack> inventoryContents = NonNullList.create(); metaTileEntity.clearMachineInventory(inventoryContents); for (ItemStack itemStack : inventoryContents) { Block.spawnAsEntity(worldIn, pos, itemStack); } metaTileEntity.dropAllCovers(); metaTileEntity.onRemoval(); } super.breakBlock(worldIn, pos, state); }
Example #14
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@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.hasNoTags()) itemStack.setTagCompound(tagCompound); drops.add(itemStack); metaTileEntity.getDrops(drops, harvesters.get()); }
Example #15
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos); CuboidRayTraceResult rayTraceResult = (CuboidRayTraceResult) RayTracer.retraceBlock(worldIn, playerIn, pos); ItemStack itemStack = playerIn.getHeldItem(hand); if (metaTileEntity == null || rayTraceResult == null) { return false; } if (itemStack.hasCapability(GregtechCapabilities.CAPABILITY_SCREWDRIVER, null)) { IScrewdriverItem screwdriver = itemStack.getCapability(GregtechCapabilities.CAPABILITY_SCREWDRIVER, null); if (screwdriver.damageItem(DamageValues.DAMAGE_FOR_SCREWDRIVER, true) && metaTileEntity.onCoverScrewdriverClick(playerIn, hand, rayTraceResult)) { screwdriver.damageItem(DamageValues.DAMAGE_FOR_SCREWDRIVER, false); return true; } return false; } if (itemStack.hasCapability(GregtechCapabilities.CAPABILITY_WRENCH, null)) { IWrenchItem wrenchItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_WRENCH, null); EnumFacing wrenchDirection = ICoverable.determineGridSideHit(rayTraceResult); if (wrenchItem.damageItem(DamageValues.DAMAGE_FOR_WRENCH, true) && metaTileEntity.onWrenchClick(playerIn, hand, wrenchDirection, rayTraceResult)) { wrenchItem.damageItem(DamageValues.DAMAGE_FOR_SCREWDRIVER, false); return true; } return false; } return metaTileEntity.onCoverRightClick(playerIn, hand, rayTraceResult); }
Example #16
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) { MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos); if (metaTileEntity == null) return; CuboidRayTraceResult rayTraceResult = (CuboidRayTraceResult) RayTracer.retraceBlock(worldIn, playerIn, pos); if (rayTraceResult != null) { metaTileEntity.onCoverLeftClick(playerIn, rayTraceResult); } }
Example #17
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Nonnull @Override public IBlockState getFacade(@Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nullable EnumFacing side, BlockPos otherPos) { MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos); if (metaTileEntity != null && side != null) { CoverBehavior coverBehavior = metaTileEntity.getCoverAtSide(side); if (coverBehavior instanceof IFacadeCover) { return ((IFacadeCover) coverBehavior).getVisualState(); } } return world.getBlockState(pos); }
Example #18
Source File: MetaTileEntityTank.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
private MetaTileEntityTank getTankTile(BlockPos blockPos) { MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(getWorld(), blockPos); if (!(metaTileEntity instanceof MetaTileEntityTank)) { return null; } MetaTileEntityTank metaTileEntityTank = (MetaTileEntityTank) metaTileEntity; if (metaTileEntityTank.isRemoved || metaTileEntityTank.material != material || metaTileEntityTank.tankSize != tankSize || !isTankFluidEqual(metaTileEntityTank, this)) { return null; } return metaTileEntityTank; }
Example #19
Source File: MetaTileEntityPrimitiveBlastFurnace.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
private void finishCurrentRecipe() { this.maxProgressDuration = 0; this.currentProgress = 0; MetaTileEntity.addItemsToItemHandler(exportItems, false, outputsList); this.outputsList = null; markDirty(); }
Example #20
Source File: MultiblockControllerBase.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
protected void checkStructurePattern() { EnumFacing facing = getFrontFacing().getOpposite(); PatternMatchContext context = structurePattern.checkPatternAt(getWorld(), getPos(), facing); if (context != null && !structureFormed) { Set<IMultiblockPart> rawPartsSet = context.getOrCreate("MultiblockParts", HashSet::new); ArrayList<IMultiblockPart> parts = new ArrayList<>(rawPartsSet); parts.sort(Comparator.comparing(it -> ((MetaTileEntity) it).getPos().hashCode())); for (IMultiblockPart part : parts) { if (part.isAttachedToMultiBlock()) { //disallow sharing of multiblock parts //if part is already attached to another multiblock, //stop here without attempting to register abilities return; } } Map<MultiblockAbility<Object>, List<Object>> abilities = new HashMap<>(); for (IMultiblockPart multiblockPart : parts) { if (multiblockPart instanceof IMultiblockAbilityPart) { IMultiblockAbilityPart<Object> abilityPart = (IMultiblockAbilityPart<Object>) multiblockPart; List<Object> abilityInstancesList = abilities.computeIfAbsent(abilityPart.getAbility(), k -> new ArrayList<>()); abilityPart.registerAbilities(abilityInstancesList); } } if (checkStructureComponents(parts, abilities)) { parts.forEach(part -> part.addToMultiBlock(this)); this.multiblockParts.addAll(parts); this.multiblockAbilities.putAll(abilities); this.structureFormed = true; writeCustomData(400, buf -> buf.writeBoolean(true)); formStructure(context); } } else if (context == null && structureFormed) { invalidateStructure(); } }
Example #21
Source File: GTUtility.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static List<EntityPlayerMP> findPlayersUsing(MetaTileEntity metaTileEntity, double radius) { ArrayList<EntityPlayerMP> result = new ArrayList<>(); AxisAlignedBB box = new AxisAlignedBB(metaTileEntity.getPos()).expand(radius, radius, radius); List<EntityPlayerMP> entities = metaTileEntity.getWorld().getEntitiesWithinAABB(EntityPlayerMP.class, box); for (EntityPlayerMP player : entities) { if (player.openContainer instanceof ModularUIContainer) { ModularUI modularUI = ((ModularUIContainer) player.openContainer).getModularUI(); if (modularUI.holder instanceof MetaTileEntityHolder && ((MetaTileEntityHolder) modularUI.holder).getMetaTileEntity() == metaTileEntity) { result.add(player); } } } return result; }
Example #22
Source File: GTUtility.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static void doOvervoltageExplosion(MetaTileEntity metaTileEntity, long voltage) { BlockPos pos = metaTileEntity.getPos(); metaTileEntity.getWorld().setBlockToAir(pos); if (!metaTileEntity.getWorld().isRemote) { double posX = pos.getX() + 0.5; double posY = pos.getY() + 0.5; double posZ = pos.getZ() + 0.5; ((WorldServer) metaTileEntity.getWorld()).spawnParticle(EnumParticleTypes.SMOKE_LARGE, posX, posY, posZ, 10, 0.2, 0.2, 0.2, 0.0); metaTileEntity.getWorld().createExplosion(null, posX, posY, posZ, getTierByVoltage(voltage), ConfigHolder.doExplosions); } }
Example #23
Source File: FuelRecipeLogic.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public FuelRecipeLogic(MetaTileEntity metaTileEntity, FuelRecipeMap recipeMap, Supplier<IEnergyContainer> energyContainer, Supplier<IMultipleTankHandler> fluidTank, long maxVoltage) { super(metaTileEntity); this.recipeMap = recipeMap; this.energyContainer = energyContainer; this.fluidTank = fluidTank; this.maxVoltage = maxVoltage; }
Example #24
Source File: EnergyContainerHandler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public EnergyContainerHandler(MetaTileEntity tileEntity, long maxCapacity, long maxInputVoltage, long maxInputAmperage, long maxOutputVoltage, long maxOutputAmperage) { super(tileEntity); this.maxCapacity = maxCapacity; this.maxInputVoltage = maxInputVoltage; this.maxInputAmperage = maxInputAmperage; this.maxOutputVoltage = maxOutputVoltage; this.maxOutputAmperage = maxOutputAmperage; }
Example #25
Source File: CoverPump.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onRemoved() { NonNullList<ItemStack> drops = NonNullList.create(); MetaTileEntity.clearInventory(drops, fluidFilter.getFilterInventory()); for (ItemStack itemStack : drops) { Block.spawnAsEntity(coverHolder.getWorld(), coverHolder.getPos(), itemStack); } }
Example #26
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos); if(metaTileEntity != null) { metaTileEntity.updateInputRedstoneSignals(); metaTileEntity.onNeighborChanged(); } }
Example #27
Source File: MetaTileEntityMacerator.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) { return new MetaTileEntityMacerator(metaTileEntityId, workable.recipeMap, outputAmount, renderer, getTier()); }
Example #28
Source File: SteamSolarBoiler.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) { return new SteamSolarBoiler(metaTileEntityId, isHighPressure); }
Example #29
Source File: MetaTileEntityCrackingUnit.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) { return new MetaTileEntityCrackingUnit(metaTileEntityId); }
Example #30
Source File: MetaTileEntityMagicEnergyAbsorber.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) { return new MetaTileEntityMagicEnergyAbsorber(metaTileEntityId); }