|
1 | 1 | package com.mcgoodtime.productionline.tiles; |
2 | 2 |
|
| 3 | + |
| 4 | +import com.mcgoodtime.productionline.core.ProductionLine; |
| 5 | +import net.minecraft.tileentity.TileEntity; |
| 6 | +import net.minecraft.util.math.BlockPos; |
| 7 | +import vazkii.botania.api.subtile.SubTileEntity; |
3 | 8 | import vazkii.botania.api.subtile.SubTileFunctional; |
| 9 | +import vazkii.botania.api.subtile.SubTileGenerating; |
| 10 | +import vazkii.botania.common.block.BlockSpecialFlower; |
| 11 | +import vazkii.botania.common.block.tile.TileSpecialFlower; |
| 12 | + |
| 13 | +public class SubTileFlowerOfOsiris extends SubTileFunctional{ |
| 14 | + private int consume; |
| 15 | + private int growthLevel = 10; |
| 16 | + |
| 17 | + private int range = 3; |
| 18 | + |
| 19 | + @Override |
| 20 | + public void onUpdate() { |
| 21 | + if(!supertile.getWorld().isRemote){ |
| 22 | + return; |
| 23 | + } |
| 24 | + for(BlockPos pos:BlockPos.getAllInBox(getPos().add(-range,0,-range),getPos().add(range,0,range))){ |
| 25 | + SubTileGenerating tile = getManaGenerator(pos); |
| 26 | + if(tile!=null){ |
| 27 | + enhance(tile); |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + } |
| 32 | + |
| 33 | + private SubTileGenerating getManaGenerator(BlockPos pos) { |
| 34 | + if(supertile.getWorld().getBlockState(pos).getBlock() instanceof BlockSpecialFlower){ |
| 35 | + TileEntity tile = supertile.getWorld().getTileEntity(pos); |
| 36 | + SubTileEntity subTile= ((TileSpecialFlower) tile).getSubTile(); |
| 37 | + if(subTile instanceof SubTileGenerating){ |
| 38 | + return (SubTileGenerating)subTile; |
| 39 | + } |
| 40 | + } |
| 41 | + return null; |
| 42 | + } |
4 | 43 |
|
5 | | -public class SubTileFlowerOfOsiris extends SubTileFunctional { |
| 44 | + private void enhance(SubTileGenerating stg){ |
| 45 | + for(int i=0;i<growthData(growthLevel);i++){ |
| 46 | + stg.onUpdate(); |
| 47 | + } |
| 48 | + } |
6 | 49 |
|
| 50 | + private int growthData(int growthLevel){ |
| 51 | + return (int)Math.ceil((Math.log((5*(growthLevel-0.5)))*1.4)); |
| 52 | + } |
7 | 53 |
|
8 | 54 | } |
0 commit comments