mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-23 21:49:50 +00:00
Implemented the Redstone Root.
This commit is contained in:
1 parent
78f55319dd
commit
371e515200
8 files changed
+131
-75
No files matched your search
@@ -21,6 +21,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.server.ForgeTimeTracker;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.IManaNetwork;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
@@ -37,7 +39,9 @@ public class SubTileFunctional extends SubTileEntity {
|
||||
private static final String TAG_POOL_Z = "poolZ";
|
||||
|
||||
public int mana;
|
||||
|
||||
|
||||
public int redstoneSignal = 0;
|
||||
|
||||
int sizeLastCheck = -1;
|
||||
TileEntity linkedPool = null;
|
||||
public int knownMana = -1;
|
||||
@@ -48,6 +52,13 @@ public class SubTileFunctional extends SubTileEntity {
|
||||
public boolean canUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If set to true, redstoneSignal will be updated every tick.
|
||||
*/
|
||||
public boolean acceptsRedstone() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
@@ -63,6 +74,14 @@ public class SubTileFunctional extends SubTileEntity {
|
||||
pool.recieveMana(-manaToRemove);
|
||||
addMana(manaToRemove);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -38,6 +38,9 @@ public class SubTileBellethorn extends SubTileFunctional {
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(redstoneSignal > 0)
|
||||
return;
|
||||
|
||||
final int range = 6;
|
||||
final int manaToUse = getManaCost();
|
||||
@@ -59,6 +62,11 @@ public class SubTileBellethorn extends SubTileFunctional {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsRedstone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getManaCost() {
|
||||
return 24;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,9 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(redstoneSignal > 0)
|
||||
return;
|
||||
|
||||
boolean pulledAny = false;
|
||||
int range = mana > 0 ? 6 : 3;
|
||||
|
||||
@@ -163,6 +166,11 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsRedstone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onWanded(EntityPlayer player, ItemStack wand) {
|
||||
if(player.isSneaking()) {
|
||||
|
||||
@@ -27,6 +27,9 @@ public class SubTileHyacidus extends SubTileFunctional {
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(redstoneSignal > 0)
|
||||
return;
|
||||
|
||||
final int range = 6;
|
||||
final int cost = 20;
|
||||
@@ -40,6 +43,11 @@ public class SubTileHyacidus extends SubTileFunctional {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsRedstone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 0x8B438F;
|
||||
|
||||
@@ -21,18 +21,15 @@ import vazkii.botania.common.lexicon.LexiconData;
|
||||
public class SubTileJadedAmaranthus extends SubTileFunctional {
|
||||
|
||||
private static final int COST = 100;
|
||||
int cooldown = 0;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(cooldown > 0) {
|
||||
cooldown--;
|
||||
if(redstoneSignal > 0)
|
||||
return;
|
||||
}
|
||||
|
||||
if(mana >= COST && !supertile.getWorldObj().isRemote) {
|
||||
if(mana >= COST && !supertile.getWorldObj().isRemote && supertile.getWorldObj().getTotalWorldTime() % 30 == 0) {
|
||||
int range = 4;
|
||||
int x = supertile.xCoord - range + supertile.getWorldObj().rand.nextInt(range * 2 + 1);
|
||||
int y = supertile.yCoord + range;
|
||||
@@ -50,7 +47,6 @@ public class SubTileJadedAmaranthus extends SubTileFunctional {
|
||||
mana -= COST;
|
||||
sync();
|
||||
|
||||
cooldown = 30;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -58,6 +54,11 @@ public class SubTileJadedAmaranthus extends SubTileFunctional {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsRedstone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
|
||||
@@ -37,78 +37,76 @@ import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
|
||||
int cooldown = 0;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
if(cooldown > 0) {
|
||||
cooldown--;
|
||||
|
||||
if(redstoneSignal > 0)
|
||||
return;
|
||||
}
|
||||
|
||||
BlockData filter = getUnderlyingBlock();
|
||||
if(supertile.getWorldObj().getTotalWorldTime() % 10 == 0) {
|
||||
BlockData filter = getUnderlyingBlock();
|
||||
|
||||
boolean scanned = false;
|
||||
List<ChunkCoordinates> validPositions = new ArrayList();
|
||||
boolean scanned = false;
|
||||
List<ChunkCoordinates> validPositions = new ArrayList();
|
||||
|
||||
int range = 2;
|
||||
int rangePlace = mana > 0 ? 8 : 6;
|
||||
int rangePlaceY = 6;
|
||||
int range = 2;
|
||||
int rangePlace = mana > 0 ? 8 : 6;
|
||||
int rangePlaceY = 6;
|
||||
|
||||
int x = supertile.xCoord;
|
||||
int y = supertile.yCoord;
|
||||
int z = supertile.zCoord;
|
||||
int x = supertile.xCoord;
|
||||
int y = supertile.yCoord;
|
||||
int z = supertile.zCoord;
|
||||
|
||||
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - range, y - 3, z - range, x + range + 1, y + 3, z + range + 1));
|
||||
for(EntityItem item : items) {
|
||||
if(item.age < 60 || item.isDead)
|
||||
continue;
|
||||
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - range, y - 3, z - range, x + range + 1, y + 3, z + range + 1));
|
||||
for(EntityItem item : items) {
|
||||
if(item.age < 60 || item.isDead)
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getEntityItem();
|
||||
Item stackItem = stack.getItem();
|
||||
if(stackItem instanceof ItemBlock || stackItem instanceof ItemReed) {
|
||||
if(!scanned) {
|
||||
for(int i = -rangePlace; i < rangePlace; i++)
|
||||
for(int j = -rangePlaceY; j < rangePlaceY; j++)
|
||||
for(int l = -rangePlace; l < rangePlace; l++) {
|
||||
int xp = x + i;
|
||||
int yp = y + j;
|
||||
int zp = z + l;
|
||||
Block blockAbove = supertile.getWorldObj().getBlock(xp, yp + 1, zp);
|
||||
ItemStack stack = item.getEntityItem();
|
||||
Item stackItem = stack.getItem();
|
||||
if(stackItem instanceof ItemBlock || stackItem instanceof ItemReed) {
|
||||
if(!scanned) {
|
||||
for(int i = -rangePlace; i < rangePlace; i++)
|
||||
for(int j = -rangePlaceY; j < rangePlaceY; j++)
|
||||
for(int l = -rangePlace; l < rangePlace; l++) {
|
||||
int xp = x + i;
|
||||
int yp = y + j;
|
||||
int zp = z + l;
|
||||
Block blockAbove = supertile.getWorldObj().getBlock(xp, yp + 1, zp);
|
||||
|
||||
if(filter.equals(supertile.getWorldObj(), xp, yp, zp) && (blockAbove.isAir(supertile.getWorldObj(), xp, yp + 1, zp) || blockAbove.isReplaceable(supertile.getWorldObj(), xp, yp + 1, zp)))
|
||||
validPositions.add(new ChunkCoordinates(xp, yp + 1, zp));
|
||||
if(filter.equals(supertile.getWorldObj(), xp, yp, zp) && (blockAbove.isAir(supertile.getWorldObj(), xp, yp + 1, zp) || blockAbove.isReplaceable(supertile.getWorldObj(), xp, yp + 1, zp)))
|
||||
validPositions.add(new ChunkCoordinates(xp, yp + 1, zp));
|
||||
}
|
||||
|
||||
scanned = true;
|
||||
}
|
||||
|
||||
|
||||
if(!validPositions.isEmpty() && !supertile.getWorldObj().isRemote) {
|
||||
Block blockToPlace = null;
|
||||
if(stackItem instanceof ItemBlock)
|
||||
blockToPlace = ((ItemBlock) stackItem).field_150939_a;
|
||||
else if(stackItem instanceof ItemReed)
|
||||
blockToPlace = ReflectionHelper.getPrivateValue(ItemReed.class, (ItemReed) stackItem, LibObfuscation.REED_ITEM);
|
||||
|
||||
if(blockToPlace != null) {
|
||||
ChunkCoordinates coords = validPositions.get(supertile.getWorldObj().rand.nextInt(validPositions.size()));
|
||||
if(blockToPlace.canPlaceBlockAt(supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ)) {
|
||||
supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, blockToPlace, stack.getItemDamage(), 1 | 2);
|
||||
supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(blockToPlace) + (stack.getItemDamage() << 12));
|
||||
validPositions.remove(coords);
|
||||
|
||||
if(!supertile.getWorldObj().isRemote) {
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize == 0)
|
||||
item.setDead();
|
||||
}
|
||||
|
||||
if(mana > 1)
|
||||
mana--;
|
||||
return;
|
||||
}
|
||||
|
||||
scanned = true;
|
||||
}
|
||||
|
||||
|
||||
if(!validPositions.isEmpty() && !supertile.getWorldObj().isRemote) {
|
||||
Block blockToPlace = null;
|
||||
if(stackItem instanceof ItemBlock)
|
||||
blockToPlace = ((ItemBlock) stackItem).field_150939_a;
|
||||
else if(stackItem instanceof ItemReed)
|
||||
blockToPlace = ReflectionHelper.getPrivateValue(ItemReed.class, (ItemReed) stackItem, LibObfuscation.REED_ITEM);
|
||||
|
||||
if(blockToPlace != null) {
|
||||
ChunkCoordinates coords = validPositions.get(supertile.getWorldObj().rand.nextInt(validPositions.size()));
|
||||
if(blockToPlace.canPlaceBlockAt(supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ)) {
|
||||
supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, blockToPlace, stack.getItemDamage(), 1 | 2);
|
||||
supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(blockToPlace) + (stack.getItemDamage() << 12));
|
||||
validPositions.remove(coords);
|
||||
|
||||
if(!supertile.getWorldObj().isRemote) {
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize == 0)
|
||||
item.setDead();
|
||||
}
|
||||
|
||||
cooldown = 10;
|
||||
if(mana > 1)
|
||||
mana--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,6 +118,11 @@ public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
return new BlockData(supertile.getWorldObj(), supertile.xCoord, supertile.yCoord - 2, supertile.zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsRedstone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res) {
|
||||
super.renderHUD(mc, res);
|
||||
|
||||
@@ -33,6 +33,9 @@ public class SubtileOrechid extends SubTileFunctional {
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if(redstoneSignal > 0)
|
||||
return;
|
||||
|
||||
if(!supertile.getWorldObj().isRemote && mana >= COST && supertile.getWorldObj().getTotalWorldTime() % 100 == 0) {
|
||||
ChunkCoordinates coords = getCoordsToPut();
|
||||
@@ -85,6 +88,11 @@ public class SubtileOrechid extends SubTileFunctional {
|
||||
return null;
|
||||
return possibleCoords.get(supertile.getWorldObj().rand.nextInt(possibleCoords.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsRedstone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
|
||||
@@ -22,7 +22,8 @@ public final class ModPetalRecipes {
|
||||
public static final String white = LibOreDict.PETAL[0], orange = LibOreDict.PETAL[1], magenta = LibOreDict.PETAL[2], lightBlue = LibOreDict.PETAL[3], yellow = LibOreDict.PETAL[4], lime = LibOreDict.PETAL[5], pink = LibOreDict.PETAL[6], gray = LibOreDict.PETAL[7], lightGray = LibOreDict.PETAL[8], cyan = LibOreDict.PETAL[9], purple = LibOreDict.PETAL[10], blue = LibOreDict.PETAL[11], brown = LibOreDict.PETAL[12], green = LibOreDict.PETAL[13], red = LibOreDict.PETAL[14], black = LibOreDict.PETAL[15];
|
||||
public static final String whiteMana = LibOreDict.MANA_PETAL[0], orangeMana = LibOreDict.MANA_PETAL[1], magentaMana = LibOreDict.MANA_PETAL[2], lightBlueMana = LibOreDict.MANA_PETAL[3], yellowMana = LibOreDict.MANA_PETAL[4], limeMana = LibOreDict.MANA_PETAL[5], pinkMana = LibOreDict.MANA_PETAL[6], grayMana = LibOreDict.MANA_PETAL[7], lightGrayMana = LibOreDict.MANA_PETAL[8], cyanMana = LibOreDict.MANA_PETAL[9], purpleMana = LibOreDict.MANA_PETAL[10], blueMana = LibOreDict.MANA_PETAL[11], brownMana = LibOreDict.MANA_PETAL[12], greenMana = LibOreDict.MANA_PETAL[13], redMana = LibOreDict.MANA_PETAL[14], blackMana = LibOreDict.MANA_PETAL[15];
|
||||
public static final String runeWater = LibOreDict.RUNE[0], runeFire = LibOreDict.RUNE[1], runeEarth = LibOreDict.RUNE[2], runeAir = LibOreDict.RUNE[3], runeSpring = LibOreDict.RUNE[4], runeSummer = LibOreDict.RUNE[5], runeAutumn = LibOreDict.RUNE[6], runeWinter = LibOreDict.RUNE[7], runeMana = LibOreDict.RUNE[8], runeLust = LibOreDict.RUNE[9], runeGluttony = LibOreDict.RUNE[10], runeGreed = LibOreDict.RUNE[11], runeSloth = LibOreDict.RUNE[12], runeWrath = LibOreDict.RUNE[13], runeEnvy = LibOreDict.RUNE[14], runePride = LibOreDict.RUNE[15];
|
||||
|
||||
public static final String redstoneRoot = LibOreDict.REDSTONE_ROOT;
|
||||
|
||||
public static RecipePetals pureDaisyRecipe;
|
||||
|
||||
public static RecipePetals daybloomRecipe;
|
||||
@@ -57,19 +58,19 @@ public final class ModPetalRecipes {
|
||||
thermalilyRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_THERMALILY), red, orangeMana, orange, runeEarth, runeFire);
|
||||
arcaneRoseRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ARCANE_ROSE), pink, pinkMana, pinkMana, lime, purple, purpleMana, runeMana);
|
||||
|
||||
jadedAmaranthusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_JADED_AMARANTHUS), purpleMana, purpleMana, lime, purple, green, runeSpring);
|
||||
bellethorneRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BELLETHORN), redMana, redMana, cyan, cyan, red);
|
||||
dreadthorneRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DREADTHORN), blackMana, purpleMana, cyan, cyan, black, purple);
|
||||
jadedAmaranthusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_JADED_AMARANTHUS), purpleMana, purpleMana, lime, purple, green, runeSpring, redstoneRoot);
|
||||
bellethorneRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BELLETHORN), redMana, redMana, cyan, cyan, red, redstoneRoot);
|
||||
dreadthorneRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DREADTHORN), blackMana, purpleMana, cyan, cyan, black, purple, redstoneRoot);
|
||||
heiseiDreamRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HEISEI_DREAM), purpleMana, pinkMana, magentaMana, purple, pink, magenta, runeWrath);
|
||||
tigerseyeRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_TIGERSEYE), yellow, brownMana, orangeMana, lime, runeAutumn);
|
||||
orechidRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID), gray, grayMana, lightGray, lightGrayMana, lightBlue, yellow, green, red, runePride, runeSloth);
|
||||
orechidRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID), gray, grayMana, lightGray, lightGrayMana, lightBlue, yellow, green, red, runePride, runeSloth, redstoneRoot);
|
||||
fallenKanadeRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_FALLEN_KANADE), white, whiteMana, whiteMana, yellowMana, orangeMana, brownMana, runeSpring);
|
||||
exoflameRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_EXOFLAME), red, redMana, redMana, gray, lightGray, runeFire, runeSummer);
|
||||
agricarnationRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_AGRICARNATION), redMana, yellow, greenMana, lime, lime, limeMana, runeSpring);
|
||||
hopperhockRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HOPPERHOCK), gray, grayMana, lightGray, lightGrayMana, runeAir);
|
||||
hopperhockRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HOPPERHOCK), gray, grayMana, lightGray, lightGrayMana, runeAir, redstoneRoot);
|
||||
tangleberrieRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_TANGLEBERRIE), grayMana, lightGrayMana, cyanMana, cyan, runeAir, runeEarth);
|
||||
jiyuuliaRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_JIYUULIA), pinkMana, purpleMana, lightGrayMana, pink, runeWater, runeAir);
|
||||
rannuncarpusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_RANNUNCARPUS), orangeMana, orangeMana, orange, yellow, runeEarth, red, redMana);
|
||||
hyacidusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HYACIDUS), purple, purpleMana, magenta, magentaMana, brown, green, greenMana, runeWater, runeAutumn);
|
||||
rannuncarpusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_RANNUNCARPUS), orangeMana, orangeMana, orange, yellow, runeEarth, red, redMana, redstoneRoot);
|
||||
hyacidusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_HYACIDUS), purple, purpleMana, magenta, magentaMana, brown, green, greenMana, runeWater, runeAutumn, redstoneRoot);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user