mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Implemented the effect of the Pure Daisy.
This commit is contained in:
1 parent
f1ae5fba04
commit
45bd85b950
1 file changed
+71
-2
@@ -11,18 +11,87 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.subtile;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.subtile.SubTileEntity;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
public class SubTilePureDaisy extends SubTileEntity {
|
||||
|
||||
private static final String TAG_POSITION = "position";
|
||||
private static final String TAG_TICKS_REMAINING = "ticksRemaining";
|
||||
|
||||
private static final int[][] POSITIONS = new int[][] {
|
||||
{ -1, 0, -1 },
|
||||
{ -1, 0, 0 },
|
||||
{ -1, 0, 1 },
|
||||
{ 0, 0, 1 },
|
||||
{ 1, 0, 1 },
|
||||
{ 1, 0, 0 },
|
||||
{ 1, 0, -1 },
|
||||
{ 0, 0, -1 },
|
||||
};
|
||||
|
||||
int positionAt = 0;
|
||||
int[] ticksRemaining = new int[] { 200, 200, 200, 200, 200, 200, 200, 200 };
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
// TODO
|
||||
positionAt++;
|
||||
if(positionAt == POSITIONS.length)
|
||||
positionAt = 0;
|
||||
|
||||
int[] acoords = POSITIONS[positionAt];
|
||||
ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord + acoords[0], supertile.yCoord + acoords[1], supertile.zCoord + acoords[2]);
|
||||
Block block = Block.blocksList[supertile.worldObj.getBlockId(coords.posX, coords.posY, coords.posZ)];
|
||||
if(block != null) {
|
||||
String oredict = OreDictionary.getOreName(OreDictionary.getOreID(new ItemStack(block, 1, supertile.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ))));
|
||||
int output = oredict.equals("stone") ? ModBlocks.livingrock.blockID : oredict.endsWith("logWood") ? ModBlocks.livingwood.blockID : 0;
|
||||
if(output != 0) {
|
||||
ticksRemaining[positionAt] = ticksRemaining[positionAt] - 1;
|
||||
|
||||
Botania.proxy.sparkleFX(supertile.worldObj, coords.posX + Math.random(), coords.posY + Math.random(), coords.posZ + Math.random(), 1F, 1F, 1F, (float) Math.random(), 5);
|
||||
|
||||
if(ticksRemaining[positionAt] <= 0) {
|
||||
supertile.worldObj.setBlock(coords.posX, coords.posY, coords.posZ, output);
|
||||
ticksRemaining[positionAt] = 200;
|
||||
|
||||
for(int i = 0; i < 25; i++) {
|
||||
double x = coords.posX + Math.random();
|
||||
double y = coords.posY + Math.random() + 0.5;
|
||||
double z = coords.posZ + Math.random();
|
||||
|
||||
Botania.proxy.wispFX(supertile.worldObj, x, y, z, 1F, 1F, 1F, (float) Math.random() / 2F);
|
||||
}
|
||||
}
|
||||
} else ticksRemaining[positionAt] = 200;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromPacketNBT(NBTTagCompound cmp) {
|
||||
positionAt = cmp.getInteger(TAG_POSITION);
|
||||
|
||||
if(!supertile.worldObj.isRemote)
|
||||
for(int i = 0; i < ticksRemaining.length; i++)
|
||||
ticksRemaining[i] = cmp.getInteger(TAG_TICKS_REMAINING + i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToPacketNBT(NBTTagCompound cmp) {
|
||||
cmp.setInteger(TAG_POSITION, positionAt);
|
||||
for(int i = 0; i < ticksRemaining.length; i++)
|
||||
cmp.setInteger(TAG_TICKS_REMAINING + i, ticksRemaining[i]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user