mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 02:45:13 +00:00
Dandelifeon.
This commit is contained in:
1 parent
dfe14da9db
commit
519d75f3cd
13 files changed
+308
-2
No files matched your search
@@ -41,6 +41,8 @@ public class SubTileGenerating extends SubTileEntity {
|
||||
private static final String TAG_COLLECTOR_Z = "collectorZ";
|
||||
|
||||
protected int mana;
|
||||
|
||||
public int redstoneSignal = 0;
|
||||
|
||||
int sizeLastCheck = -1;
|
||||
protected TileEntity linkedCollector = null;
|
||||
@@ -48,6 +50,13 @@ public class SubTileGenerating extends SubTileEntity {
|
||||
|
||||
ChunkCoordinates cachedCollectorCoordinates = null;
|
||||
|
||||
/**
|
||||
* If set to true, redstoneSignal will be updated every tick.
|
||||
*/
|
||||
public boolean acceptsRedstone() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
@@ -64,6 +73,14 @@ public class SubTileGenerating extends SubTileEntity {
|
||||
}
|
||||
emptyManaIntoCollector();
|
||||
|
||||
if(acceptsRedstone()) {
|
||||
redstoneSignal = 0;
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
int redstoneSide = supertile.getWorldObj().getIndirectPowerLevelTo(supertile.xCoord + dir.offsetX, supertile.yCoord + dir.offsetY, supertile.zCoord + dir.offsetZ, dir.ordinal());
|
||||
redstoneSignal = Math.max(redstoneSignal, redstoneSide);
|
||||
}
|
||||
}
|
||||
|
||||
if(supertile.getWorldObj().isRemote) {
|
||||
double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F;
|
||||
Color color = new Color(getColor());
|
||||
|
||||
@@ -53,7 +53,6 @@ public final class SubTileRadiusRenderHandler {
|
||||
y = coords.posY;
|
||||
z = coords.posZ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TileEntity tile = mc.theWorld.getTileEntity(x, y, z);
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Sep 6, 2015, 4:03:56 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.common.block.tile.TileCell;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockCell extends BlockModContainer {
|
||||
|
||||
public BlockCell() {
|
||||
super(Material.gourd);
|
||||
setBlockName(LibBlockNames.CELL_BLOCK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileCell();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -70,6 +70,7 @@ public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvid
|
||||
LibBlockNames.SUBTILE_GOURMARYLLIS,
|
||||
LibBlockNames.SUBTILE_NARSLIMMUS,
|
||||
LibBlockNames.SUBTILE_SPECTROLUS,
|
||||
LibBlockNames.SUBTILE_DANDELIFEON,
|
||||
|
||||
// Functional
|
||||
LibBlockNames.SUBTILE_JADED_AMARANTHUS,
|
||||
|
||||
@@ -98,6 +98,7 @@ import vazkii.botania.common.block.subtile.functional.SubTileTangleberrie;
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileTigerseye;
|
||||
import vazkii.botania.common.block.subtile.functional.SubTileVinculotus;
|
||||
import vazkii.botania.common.block.subtile.generating.SubTileArcaneRose;
|
||||
import vazkii.botania.common.block.subtile.generating.SubTileDandelifeon;
|
||||
import vazkii.botania.common.block.subtile.generating.SubTileDaybloom;
|
||||
import vazkii.botania.common.block.subtile.generating.SubTileEndoflame;
|
||||
import vazkii.botania.common.block.subtile.generating.SubTileEntropinnyum;
|
||||
@@ -114,6 +115,7 @@ import vazkii.botania.common.block.tile.TileAltar;
|
||||
import vazkii.botania.common.block.tile.TileBifrost;
|
||||
import vazkii.botania.common.block.tile.TileBrewery;
|
||||
import vazkii.botania.common.block.tile.TileCacophonium;
|
||||
import vazkii.botania.common.block.tile.TileCell;
|
||||
import vazkii.botania.common.block.tile.TileCocoon;
|
||||
import vazkii.botania.common.block.tile.TileCraftCrate;
|
||||
import vazkii.botania.common.block.tile.TileEnchanter;
|
||||
@@ -246,6 +248,7 @@ public final class ModBlocks {
|
||||
public static Block cacophonium;
|
||||
public static Block bellows;
|
||||
public static Block bifrostPerm;
|
||||
public static Block cellBlock;
|
||||
|
||||
public static void init() {
|
||||
flower = new BlockModFlower();
|
||||
@@ -329,7 +332,8 @@ public final class ModBlocks {
|
||||
cacophonium = new BlockCacophonium();
|
||||
bellows = new BlockBellows();
|
||||
bifrostPerm = new BlockBifrostPerm();
|
||||
|
||||
cellBlock = new BlockCell();
|
||||
|
||||
ModFluffBlocks.init();
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
@@ -425,6 +429,7 @@ public final class ModBlocks {
|
||||
registerTile(TileLightRelay.class, LibBlockNames.LIGHT_RELAY);
|
||||
registerTile(TileCacophonium.class, LibBlockNames.CACOPHONIUM);
|
||||
registerTile(TileBellows.class, LibBlockNames.BELLOWS);
|
||||
registerTile(TileCell.class, LibBlockNames.CELL_BLOCK);
|
||||
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class);
|
||||
@@ -441,6 +446,7 @@ public final class ModBlocks {
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_GOURMARYLLIS, SubTileGourmaryllis.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_NARSLIMMUS, SubTileNarslimmus.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_SPECTROLUS, SubTileSpectrolus.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DANDELIFEON, SubTileDandelifeon.class);
|
||||
|
||||
registerSubTileWithMini(LibBlockNames.SUBTILE_BELLETHORN, SubTileBellethorn.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DREADTHORN, SubTileDreadthorn.class);
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Sep 6, 2015, 3:46:10 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block.subtile.generating;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.SubTileGenerating;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.TileCell;
|
||||
|
||||
public class SubTileDandelifeon extends SubTileGenerating {
|
||||
|
||||
private static final int RANGE = 12;
|
||||
private static final int SPEED = 10;
|
||||
private static final int MAX_GENERATIONS = 60;
|
||||
private static final int MANA_PER_GEN = 80;
|
||||
|
||||
private static final int[][] ADJACENT_BLOCKS = new int[][] {
|
||||
{ -1, -1 },
|
||||
{ -1, +0 },
|
||||
{ -1, +1 },
|
||||
{ +0, +1 },
|
||||
{ +1, +1 },
|
||||
{ +1, +0 },
|
||||
{ +1, -1 },
|
||||
{ +0, -1 }
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(!supertile.getWorldObj().isRemote && redstoneSignal > 0 && ticksExisted % SPEED == 0)
|
||||
runSimulation();
|
||||
}
|
||||
|
||||
void runSimulation() {
|
||||
int[][] table = getCellTable();
|
||||
List<int[]> changes = new ArrayList();
|
||||
|
||||
for(int i = 0; i < table.length; i++)
|
||||
for(int j = 0; j < table[0].length; j++) {
|
||||
int gen = table[i][j];
|
||||
int adj = getAdjCells(table, i, j);
|
||||
|
||||
int newVal = gen;
|
||||
if(adj < 2 || adj > 3)
|
||||
newVal = -1;
|
||||
else {
|
||||
if(adj == 3 && gen == -1)
|
||||
newVal = getSpawnCellGeneration(table, i, j);
|
||||
else if(gen > -1)
|
||||
newVal = gen + 1;
|
||||
}
|
||||
|
||||
if(Math.abs(i - RANGE) <= 1 && Math.abs(j - RANGE) <= 1 && newVal > -1) {
|
||||
gen = newVal;
|
||||
newVal = -2;
|
||||
}
|
||||
|
||||
if(newVal != gen)
|
||||
changes.add(new int[] { i, j, newVal, gen });
|
||||
}
|
||||
|
||||
int x = supertile.xCoord;
|
||||
int y = supertile.yCoord;
|
||||
int z = supertile.zCoord;
|
||||
|
||||
for(int[] change : changes) {
|
||||
int px = x - RANGE + change[0];
|
||||
int pz = z - RANGE + change[1];
|
||||
int val = change[2];
|
||||
int old = change[3];
|
||||
|
||||
setBlockForGeneration(px, y, pz, val, old);
|
||||
}
|
||||
}
|
||||
|
||||
int[][] getCellTable() {
|
||||
int diam = RANGE * 2 + 1;
|
||||
int[][] table = new int[diam][diam];
|
||||
|
||||
int x = supertile.xCoord;
|
||||
int y = supertile.yCoord;
|
||||
int z = supertile.zCoord;
|
||||
|
||||
for(int i = 0; i < diam; i++)
|
||||
for(int j = 0; j < diam; j++) {
|
||||
int px = x - RANGE + i;
|
||||
int pz = z - RANGE + j;
|
||||
table[i][j] = getCellGeneration(px, y, pz);
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
int getCellGeneration(int x, int y, int z) {
|
||||
TileEntity tile = supertile.getWorldObj().getTileEntity(x, y, z);
|
||||
if(tile instanceof TileCell)
|
||||
return ((TileCell) tile).getGeneration();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int getAdjCells(int[][] table, int x, int z) {
|
||||
int count = 0;
|
||||
for(int[] shift : ADJACENT_BLOCKS) {
|
||||
int xp = x + shift[0];
|
||||
int zp = z + shift[1];
|
||||
if(!isOffBounds(table, xp, zp)) {
|
||||
int gen = table[xp][zp];
|
||||
if(gen >= 0)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int getSpawnCellGeneration(int[][] table, int x, int z) {
|
||||
int max = -1;
|
||||
for(int[] shift : ADJACENT_BLOCKS) {
|
||||
int xp = x + shift[0];
|
||||
int zp = z + shift[1];
|
||||
if(!isOffBounds(table, xp, zp)) {
|
||||
int gen = table[xp][zp];
|
||||
if(gen > max)
|
||||
max = gen;
|
||||
}
|
||||
}
|
||||
|
||||
return max == -1 ? -1 : max + 1;
|
||||
}
|
||||
|
||||
boolean isOffBounds(int[][] table, int x, int z) {
|
||||
return x < 0 || z < 0 || x >= table.length || z >= table[0].length;
|
||||
}
|
||||
|
||||
void setBlockForGeneration(int x, int y, int z, int gen, int prevGen) {
|
||||
World world = supertile.getWorldObj();
|
||||
Block blockAt = world.getBlock(x, y, z);
|
||||
if(gen == -2) {
|
||||
int val = prevGen * MANA_PER_GEN;
|
||||
mana = Math.min(getMaxMana(), mana + val);
|
||||
world.setBlockToAir(x, y, z);
|
||||
} else if(blockAt == ModBlocks.cellBlock) {
|
||||
if(gen < 0 || gen > MAX_GENERATIONS)
|
||||
world.setBlockToAir(x, y, z);
|
||||
else ((TileCell) world.getTileEntity(x, y, z)).setGeneration(gen);
|
||||
} else if(gen >= 0 && blockAt.isAir(supertile.getWorldObj(), x, y, z)) {
|
||||
world.setBlock(x, y, z, ModBlocks.cellBlock);
|
||||
((TileCell) world.getTileEntity(x, y, z)).setGeneration(gen);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsRedstone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RadiusDescriptor getRadius() {
|
||||
return new RadiusDescriptor.Square(toChunkCoordinates(), RANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMana() {
|
||||
return 50000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 0x9c0a7e;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Sep 6, 2015, 4:07:16 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class TileCell extends TileMod {
|
||||
|
||||
private static final String TAG_GENERATION = "generation";
|
||||
|
||||
private int generation;
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setGeneration(int gen) {
|
||||
generation = gen;
|
||||
}
|
||||
|
||||
public int getGeneration() {
|
||||
return generation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound cmp) {
|
||||
cmp.setInteger(TAG_GENERATION, generation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound cmp) {
|
||||
generation = cmp.getInteger(TAG_GENERATION);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -271,6 +271,7 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
addBlock(ModBlocks.corporeaCrystalCube);
|
||||
addBlock(ModBlocks.lightRelay);
|
||||
addBlock(ModBlocks.lightLauncher);
|
||||
addBlock(ModBlocks.cellBlock);
|
||||
|
||||
// FLUFF
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ public final class LibBlockNames {
|
||||
public static final String BELLOWS = "bellows";
|
||||
public static final String BIFROST_PERM = "bifrostPerm";
|
||||
public static final String PAVEMENT = "pavement";
|
||||
public static final String CELL_BLOCK = "cellBlock";
|
||||
|
||||
public static final String SUBTILE_PUREDAISY = "puredaisy";
|
||||
public static final String SUBTILE_MANASTAR = "manastar";
|
||||
@@ -113,6 +114,7 @@ public final class LibBlockNames {
|
||||
public static final String SUBTILE_GOURMARYLLIS = "gourmaryllis";
|
||||
public static final String SUBTILE_NARSLIMMUS = "narslimmus";
|
||||
public static final String SUBTILE_SPECTROLUS = "spectrolus";
|
||||
public static final String SUBTILE_DANDELIFEON = "dandelifeon";
|
||||
|
||||
public static final String SUBTILE_BELLETHORN = "bellethorn";
|
||||
public static final String SUBTILE_DREADTHORN = "dreadthorn";
|
||||
|
||||
Reference in new issue
Block a user