diff --git a/gradle/gradle-daemon-jvm.properties b/gradle/gradle-daemon-jvm.properties index b30b550740..0e9e9a4131 100644 --- a/gradle/gradle-daemon-jvm.properties +++ b/gradle/gradle-daemon-jvm.properties @@ -1,12 +1,12 @@ #This file is generated by updateDaemonJvm -toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect -toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect -toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect -toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect -toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/46949723aaa20c7b64d7ecfed7207034/redirect -toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d6690dfd71c4c91e08577437b5b2beb0/redirect -toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect -toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect -toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3cd7045fca9a72cd9bc7d14a385e594c/redirect -toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/552c7bffe0370c66410a51c55985b511/redirect +toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect +toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/5ee463876563a46fff651cce1bc53a4c/redirect +toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect +toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/5ee463876563a46fff651cce1bc53a4c/redirect +toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/d4fd992c9557644e637ebe98263e0ae7/redirect +toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/59a9771cad43219260d9aac9a8ec4d6a/redirect +toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect +toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/5ee463876563a46fff651cce1bc53a4c/redirect +toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3689d0bcdd77ac01674ba3c9dbbe94d0/redirect +toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/8e1d9ee5d0f13e442218f6884a306da1/redirect toolchainVersion=25 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f8e1ee3125..d997cfc60f 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradlew b/gradlew index adff685a03..0262dcbd52 100755 --- a/gradlew +++ b/gradlew @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/settings.gradle b/settings.gradle index 035355de67..407aea2219 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,7 +17,7 @@ pluginManagement { } plugins { - id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.23' + id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.24' } diff --git a/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java b/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java index 02f7a23afc..668a5c5e7c 100644 --- a/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java +++ b/src/main/java/vazkii/botania/api/subtile/SubTileGenerating.java @@ -69,58 +69,96 @@ public void onUpdate() { linkCollector(); - if(canGeneratePassively()) { + if (canGeneratePassively()) { int delay = getDelayBetweenPassiveGeneration(); - if(delay > 0 && ticksExisted % delay == 0 && !supertile.getWorldObj().isRemote) { - if(shouldSyncPassiveGeneration()) + if (delay > 0 && ticksExisted % delay == 0 && !supertile.getWorldObj().isRemote) { + if (shouldSyncPassiveGeneration()) sync(); addMana(getValueForPassiveGeneration()); } } emptyManaIntoCollector(); - if(acceptsRedstone()) { + 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()); + 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) { + if (supertile.getWorldObj().isRemote) { double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F; - Color color = new Color(getColor()); - if(Math.random() > particleChance) - BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5); + if (Math.random() > particleChance){ + Color color = new Color(getColor()); + BotaniaAPI.internalHandler.sparkleFX( + supertile.getWorldObj(), + supertile.xCoord + 0.3 + Math.random() * 0.5, + supertile.yCoord + 0.5 + Math.random() * 0.5, + supertile.zCoord + 0.3 + Math.random() * 0.5, + color.getRed() / 255F, + color.getGreen() / 255F, + color.getBlue() / 255F, + (float) Math.random(), 5); + } } boolean passive = isPassiveFlower(); - if(!supertile.getWorldObj().isRemote) { + if (!supertile.getWorldObj().isRemote) { int muhBalance = BotaniaAPI.internalHandler.getPassiveFlowerDecay(); - if(passive && muhBalance > 0 && passiveDecayTicks > muhBalance) { - supertile.getWorldObj().playAuxSFX(2001, supertile.xCoord, supertile.yCoord, supertile.zCoord, Block.getIdFromBlock(supertile.getBlockType())); - if(supertile.getWorldObj().getBlock(supertile.xCoord, supertile.yCoord - 1, supertile.zCoord).isSideSolid(supertile.getWorldObj(), supertile.xCoord, supertile.yCoord - 1, supertile.zCoord, ForgeDirection.UP)) - supertile.getWorldObj().setBlock(supertile.xCoord, supertile.yCoord, supertile.zCoord, Blocks.deadbush); + if (passive && muhBalance > 0 && passiveDecayTicks > muhBalance) { + supertile.getWorldObj().playAuxSFX( + 2001, + supertile.xCoord, + supertile.yCoord, + supertile.zCoord, + Block.getIdFromBlock(supertile.getBlockType())); + if ( + supertile.getWorldObj().getBlock( + supertile.xCoord, + supertile.yCoord - 1, + supertile.zCoord).isSideSolid(supertile.getWorldObj(), + supertile.xCoord, + supertile.yCoord - 1, + supertile.zCoord, + ForgeDirection.UP) + ) + supertile.getWorldObj().setBlock( + supertile.xCoord, + supertile.yCoord, + supertile.zCoord, + Blocks.deadbush); else supertile.getWorldObj().setBlockToAir(supertile.xCoord, supertile.yCoord, supertile.zCoord); } } - if(!overgrowth && passive) + if (!overgrowth && passive) passiveDecayTicks++; } public void linkCollector() { boolean needsNew = false; - if(linkedCollector == null) { + if (linkedCollector == null) { needsNew = true; - if(cachedCollectorCoordinates != null) { + if (cachedCollectorCoordinates != null) { needsNew = false; - if(supertile.getWorldObj().blockExists(cachedCollectorCoordinates.posX, cachedCollectorCoordinates.posY, cachedCollectorCoordinates.posZ)) { + if (supertile.getWorldObj().blockExists( + cachedCollectorCoordinates.posX, + cachedCollectorCoordinates.posY, + cachedCollectorCoordinates.posZ) + ) { needsNew = true; - TileEntity tileAt = supertile.getWorldObj().getTileEntity(cachedCollectorCoordinates.posX, cachedCollectorCoordinates.posY, cachedCollectorCoordinates.posZ); - if(tileAt != null && tileAt instanceof IManaCollector && !tileAt.isInvalid()) { + TileEntity tileAt = supertile.getWorldObj().getTileEntity( + cachedCollectorCoordinates.posX, + cachedCollectorCoordinates.posY, + cachedCollectorCoordinates.posZ); + if (tileAt != null && tileAt instanceof IManaCollector && !tileAt.isInvalid()) { linkedCollector = tileAt; needsNew = false; } @@ -129,14 +167,14 @@ public void linkCollector() { } } else { TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord); - if(tileAt != null && tileAt instanceof IManaCollector) + if (tileAt != null && tileAt instanceof IManaCollector) linkedCollector = tileAt; } - if(needsNew && ticksExisted == 1) { // New flowers only + if (needsNew && ticksExisted == 1) { // New flowers only IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); int size = network.getAllCollectorsInWorld(supertile.getWorldObj()).size(); - if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { + if (BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord); linkedCollector = network.getClosestCollector(coords, supertile.getWorldObj(), RANGE); sizeLastCheck = size; @@ -153,9 +191,9 @@ public void addMana(int mana) { } public void emptyManaIntoCollector() { - if(linkedCollector != null && isValidBinding()) { + if (linkedCollector != null && isValidBinding()) { IManaCollector collector = (IManaCollector) linkedCollector; - if(!collector.isFull() && mana > 0) { + if (!collector.isFull() && mana > 0) { int manaval = Math.min(mana, collector.getMaxMana() - collector.getCurrentMana()); mana -= manaval; collector.recieveMana(manaval); @@ -191,10 +229,10 @@ public ArrayList getDrops(ArrayList list) { } public void populateDropStackNBTs(List drops) { - if(isPassiveFlower() && ticksExisted > 0 && BotaniaAPI.internalHandler.getPassiveFlowerDecay() > 0) { + if (isPassiveFlower() && ticksExisted > 0 && BotaniaAPI.internalHandler.getPassiveFlowerDecay() > 0) { ItemStack drop = drops.get(0); - if(drop != null) { - if(!drop.hasTagCompound()) + if (drop != null) { + if (!drop.hasTagCompound()) drop.setTagCompound(new NBTTagCompound()); NBTTagCompound cmp = drop.getTagCompound(); cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); @@ -205,7 +243,7 @@ public void populateDropStackNBTs(List drops) { @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { super.onBlockPlacedBy(world, x, y, z, entity, stack); - if(isPassiveFlower()) { + if (isPassiveFlower()) { NBTTagCompound cmp = stack.getTagCompound(); passiveDecayTicks = cmp.getInteger(TAG_PASSIVE_DECAY_TICKS); } @@ -213,10 +251,10 @@ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase e @Override public boolean onWanded(EntityPlayer player, ItemStack wand) { - if(player == null) + if (player == null) return false; - if(!player.worldObj.isRemote) + if (!player.worldObj.isRemote) sync(); knownMana = mana; @@ -251,7 +289,7 @@ public void writeToPacketNBT(NBTTagCompound cmp) { cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted); cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); - if(cachedCollectorCoordinates != null) { + if (cachedCollectorCoordinates != null) { cmp.setInteger(TAG_COLLECTOR_X, cachedCollectorCoordinates.posX); cmp.setInteger(TAG_COLLECTOR_Y, cachedCollectorCoordinates.posY); cmp.setInteger(TAG_COLLECTOR_Z, cachedCollectorCoordinates.posZ); @@ -268,7 +306,7 @@ public void writeToPacketNBT(NBTTagCompound cmp) { @Override public ChunkCoordinates getBinding() { - if(linkedCollector == null) + if (linkedCollector == null) return null; return new ChunkCoordinates(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord); } @@ -284,9 +322,9 @@ public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, range *= range; double dist = (x - supertile.xCoord) * (x - supertile.xCoord) + (y - supertile.yCoord) * (y - supertile.yCoord) + (z - supertile.zCoord) * (z - supertile.zCoord); - if(range >= dist) { + if (range >= dist) { TileEntity tile = player.worldObj.getTileEntity(x, y, z); - if(tile instanceof IManaCollector) { + if (tile instanceof IManaCollector) { linkedCollector = tile; return true; } @@ -297,7 +335,12 @@ public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, public boolean isValidBinding() { - return linkedCollector != null && !linkedCollector.isInvalid() && supertile.getWorldObj().getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord) == linkedCollector; + return linkedCollector != null && + !linkedCollector.isInvalid() && + supertile.getWorldObj().getTileEntity( + linkedCollector.xCoord, + linkedCollector.yCoord, + linkedCollector.zCoord) == linkedCollector; } @Override diff --git a/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java b/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java index 87c1e9e3bd..fff70206d6 100644 --- a/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java @@ -75,6 +75,7 @@ public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvid LibBlockNames.SUBTILE_SPECTROLUS, LibBlockNames.SUBTILE_RAFFLOWSIA, LibBlockNames.SUBTILE_DANDELIFEON, + LibBlockNames.SUBTILE_REIUJIA, // Functional LibBlockNames.SUBTILE_JADED_AMARANTHUS, diff --git a/src/main/java/vazkii/botania/common/block/ModBlocks.java b/src/main/java/vazkii/botania/common/block/ModBlocks.java index a8c3636310..439d6090f8 100644 --- a/src/main/java/vazkii/botania/common/block/ModBlocks.java +++ b/src/main/java/vazkii/botania/common/block/ModBlocks.java @@ -114,6 +114,7 @@ import vazkii.botania.common.block.subtile.generating.SubTileNarslimmus; import vazkii.botania.common.block.subtile.generating.SubTileNightshade; import vazkii.botania.common.block.subtile.generating.SubTileRafflowsia; +import vazkii.botania.common.block.subtile.generating.SubTileReiujia; import vazkii.botania.common.block.subtile.generating.SubTileSpectrolus; import vazkii.botania.common.block.subtile.generating.SubTileThermalily; import vazkii.botania.common.block.tile.TileAlfPortal; @@ -485,6 +486,7 @@ private static void initTileEntities() { BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_SPECTROLUS, SubTileSpectrolus.class); BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DANDELIFEON, SubTileDandelifeon.class); BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_RAFFLOWSIA, SubTileRafflowsia.class); + BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_REIUJIA, SubTileReiujia.class); registerSubTileWithMini(LibBlockNames.SUBTILE_BELLETHORN, SubTileBellethorn.class); BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_DREADTHORN, SubTileDreadthorn.class); diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java index 92a90e24c4..1c5b22a254 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java @@ -26,6 +26,7 @@ import vazkii.botania.api.subtile.SubTileGenerating; import vazkii.botania.common.Botania; import vazkii.botania.common.lexicon.LexiconData; +import ic2.core.block.EntityIC2Explosive; public class SubTileEntropinnyum extends SubTileGenerating { @@ -36,29 +37,79 @@ public SubTileEntropinnyum() { private static final int RANGE = 12; @Override - public void onUpdate() { - super.onUpdate(); - - if(mana == 0) { - List tnts = supertile.getWorldObj().getEntitiesWithinAABB(EntityTNTPrimed.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1)); - for(EntityTNTPrimed tnt : tnts) { - if(tnt.fuse == 1 && !tnt.isDead && !supertile.getWorldObj().getBlock(MathHelper.floor_double(tnt.posX), MathHelper.floor_double(tnt.posY), MathHelper.floor_double(tnt.posZ)).getMaterial().isLiquid()) { - if(!supertile.getWorldObj().isRemote) { - tnt.setDead(); - mana += getMaxMana(); - supertile.getWorldObj().playSoundEffect(tnt.posX, tnt.posY, tnt.posZ, "random.explode", 0.2F, (1F + (supertile.getWorldObj().rand.nextFloat() - supertile.getWorldObj().rand.nextFloat()) * 0.2F) * 0.7F); - sync(); - } - - for(int i = 0; i < 50; i++) - Botania.proxy.sparkleFX(tnt.worldObj, tnt.posX + Math.random() * 4 - 2, tnt.posY + Math.random() * 4 - 2, tnt.posZ + Math.random() * 4 - 2, 1F, (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, (float) (Math.random() * 0.65F + 1.25F), 12); - - supertile.getWorldObj().spawnParticle("hugeexplosion", tnt.posX, tnt.posY, tnt.posZ, 1D, 0D, 0D); - return; - } - } - } - } + public void onUpdate() { + super.onUpdate(); + if(mana == 0) { + AxisAlignedBB box = AxisAlignedBB.getBoundingBox( + supertile.xCoord - RANGE, + supertile.yCoord - RANGE, + supertile.zCoord - RANGE, + supertile.xCoord + RANGE + 1, + supertile.yCoord + RANGE + 1, + supertile.zCoord + RANGE + 1); + if (!processVanillaTNT(box)) processIC2Explosive(box); + } + } + + private boolean processVanillaTNT(AxisAlignedBB box){ + List tntList = supertile.getWorldObj() + .getEntitiesWithinAABB(EntityTNTPrimed.class, box); + for (EntityTNTPrimed tnt : tntList) { + if (tnt.fuse == 1 && !tnt.isDead && validLocation(tnt)) { + handleExplosion(tnt); + return true; + } + } return false; + } + + // can't unify with vanilla because EntityIC2Explosive directly inherits Entity + private boolean processIC2Explosive(AxisAlignedBB box) { + // for iTNT and nukes lul + List tntList = supertile.getWorldObj() + .getEntitiesWithinAABB(EntityIC2Explosive.class, box); + for (EntityIC2Explosive tnt : tntList) { + if (tnt.fuse == 1 && !tnt.isDead && validLocation(tnt)) { + handleExplosion(tnt); + return true; + } + } return false; + } + + private boolean validLocation(Entity tnt) { + return !supertile.getWorldObj().getBlock( + MathHelper.floor_double(tnt.posX), + MathHelper.floor_double(tnt.posY), + MathHelper.floor_double(tnt.posZ)).getMaterial().isLiquid(); + } + + protected void handleExplosion(Entity tnt) { + if (!supertile.getWorldObj().isRemote) { + tnt.setDead(); + mana += getMaxMana(); + supertile.getWorldObj().playSoundEffect( + tnt.posX, tnt.posY, tnt.posZ, + "random.explode", + 0.2F, + (1F + (supertile.getWorldObj().rand.nextFloat() - supertile.getWorldObj().rand.nextFloat()) * 0.2F) * 0.7F); + sync(); + } + for (int i = 0; i < 50; i++) { + Botania.proxy.sparkleFX( + tnt.worldObj, + tnt.posX + Math.random() * 4 - 2, + tnt.posY + Math.random() * 4 - 2, + tnt.posZ + Math.random() * 4 - 2, + 1F, + (float) Math.random() * 0.25F, + (float) Math.random() * 0.25F, + (float) (Math.random() * 0.65F + 1.25F), + 12); + } + supertile.getWorldObj().spawnParticle( + "hugeexplosion", + tnt.posX, tnt.posY, tnt.posZ, + 1D, 0D, 0D); + } @Override public int getColor() { @@ -102,6 +153,9 @@ private boolean processExplosion(World world, Entity explosionSource, double pos return false; } + // ic2 reactor explosion will not be eaten + if (explosionSource == null) return false; + explosionSource.setDead(); mana += getMaxMana(); supertile.getWorldObj().playSoundEffect(posX, posY, posZ, "random.explode", 0.2F, (1F + (supertile.getWorldObj().rand.nextFloat() - supertile.getWorldObj().rand.nextFloat()) * 0.2F) * 0.7F); diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileReiujia.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileReiujia.java new file mode 100644 index 0000000000..10878694a5 --- /dev/null +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileReiujia.java @@ -0,0 +1,211 @@ + +package vazkii.botania.common.block.subtile.generating; + +import java.util.List; + +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.ExplosionEvent; + +import ic2.core.block.EntityIC2Explosive; + +import vazkii.botania.api.lexicon.LexiconEntry; +import vazkii.botania.api.mana.spark.ISparkAttachable; +import vazkii.botania.api.mana.spark.ISparkEntity; +import vazkii.botania.api.subtile.RadiusDescriptor; +import vazkii.botania.api.subtile.SubTileGenerating; +import vazkii.botania.common.Botania; +import vazkii.botania.common.lexicon.LexiconData; + +public class SubTileReiujia extends SubTileEntropinnyum implements ISparkAttachable { + + public SubTileReiujia() { + MinecraftForge.EVENT_BUS.register(new EventHandler()); + } + + private static final int RANGE = 12; + + @Override + protected void handleExplosion(Entity tnt) { + if (!supertile.getWorldObj().isRemote) { + tnt.setDead(); + mana += super.getMaxMana(); + supertile.getWorldObj().playSoundEffect( + tnt.posX, tnt.posY, tnt.posZ, + "random.explode", + 0.2F, + (1F + (supertile.getWorldObj().rand.nextFloat() - supertile.getWorldObj().rand.nextFloat()) * 0.2F) * 0.7F); + sync(); + } + for (int i = 0; i < 50; i++){ + Botania.proxy.sparkleFX( + tnt.worldObj, + tnt.posX + Math.random() * 4 - 2, + tnt.posY + Math.random() * 4 - 2, + tnt.posZ + Math.random() * 4 - 2, + 1F, + (float) Math.random() * 0.25F, + (float) Math.random() * 0.25F, + (float) (Math.random() * 0.65F + 1.25F), + 12); + } + supertile.getWorldObj().spawnParticle( + "hugeexplosion", + tnt.posX, tnt.posY, tnt.posZ, + 1D, 0D, 0D); + } + + @Override + public int getMaxMana() { + return 100*super.getMaxMana(); + } + + public int getCurrentMana() { + return mana; + } + + @Override + public LexiconEntry getEntry() { + return LexiconData.reiujia; + } + + public class EventHandler { + + @SubscribeEvent + public void consumeExplosion(ExplosionEvent.Start event) { + // duplicate code from SubTileEntropinnyum.EventHandler.consumeExplosion + if(processExplosion(event.world, event.explosion.exploder, event.explosion.explosionX, event.explosion.explosionY, event.explosion.explosionZ)) { + event.setCanceled(true); + } + } + + @SubscribeEvent + @Optional.Method(modid = "IC2") + public void consumeExplosionIC2(ic2.api.event.ExplosionEvent event) { + if(processExplosion(event.world, event.entity, event.x, event.y, event.z, event.power)) { + event.setCanceled(true); + } + } + + private boolean processExplosion(World world, Entity explosionSource, double posX, double posY, double posZ) { + return processExplosion(world, explosionSource, posX, posY, posZ, 0); + } + + private boolean processExplosion(World world, Entity explosionSource, double posX, double posY, double posZ, double power) { + /*System.out.println( + world + " " + + explosionSource + " " + + posX + " " + + posY + " " + + posZ + " " + + power);*/ + if (world.isRemote || + mana != 0 || + !( Math.abs(supertile.xCoord - posX) <= RANGE && + Math.abs(supertile.yCoord - posY) <= RANGE && + Math.abs(supertile.zCoord - posZ) <= RANGE) + ) { + return false; + } + + int entropinnyumMaxMana = SubTileReiujia.super.getMaxMana(); + + if (explosionSource != null){ + explosionSource.setDead(); + mana += entropinnyumMaxMana; + } else { + // ic2 reactor meltdowns have no explosionSource entity + // so assume that that's what happened if we're here + // + // regarding power + // per config nuclear explosion power is capped at 100, where a tnt is 4 + // the factor of 0.25 is not here because stronger flower and radiation I guess + mana += entropinnyumMaxMana * (int)power; + } + // load bearing debug print ??? + System.out.println("mana " + mana); + + supertile.getWorldObj().playSoundEffect( + posX, + posY, + posZ, + "random.explode", + 0.2F, + (1F + (supertile.getWorldObj().rand.nextFloat() - supertile.getWorldObj().rand.nextFloat()) * 0.2F) * 0.7F); + sync(); + + for(int i = 0; i < 50; i++) { + Botania.proxy.sparkleFX( + world, + posX + Math.random() * 4 - 2, + posY + Math.random() * 4 - 2, + posZ + Math.random() * 4 - 2, + 1F, + (float) Math.random() * 0.25F, + (float) Math.random() * 0.25F, + (float) (Math.random() * 0.65F + 1.25F), + 12); + } + + supertile.getWorldObj().spawnParticle("hugeexplosion", posX, posY, posZ, 1D, 0D, 0D); + return true; + } + } + + //// ISparkAttachable + + @Override + public boolean canAttachSpark(ItemStack stack) { + return true; + } + + @Override + public void attachSpark(ISparkEntity entity) { + // NO-OP + } + + @Override + public ISparkEntity getAttachedSpark() { + List sparks = supertile.getWorldObj().getEntitiesWithinAABB( + ISparkEntity.class, + AxisAlignedBB.getBoundingBox( + supertile.xCoord, + supertile.yCoord + 1, + supertile.zCoord, + supertile.xCoord + 1, + supertile.yCoord + 2, + supertile.zCoord + 1)); + if(sparks.size() == 1) { + Entity e = (Entity) sparks.get(0); + return (ISparkEntity) e; + } + + return null; + } + + // generating flower should never accept mana + @Override + public int getAvailableSpaceForMana() { return 0; } + @Override + public boolean areIncomingTranfersDone() { return true; } + + //// IManaReceiver + + @Override + public boolean isFull() { return true; } + @Override + public void recieveMana(int mana) { + // NO-OP + } + @Override + public boolean canRecieveManaFromBursts() { return false; } +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/common/entity/EntitySpark.java b/src/main/java/vazkii/botania/common/entity/EntitySpark.java index 68f17a649c..cda96ad999 100644 --- a/src/main/java/vazkii/botania/common/entity/EntitySpark.java +++ b/src/main/java/vazkii/botania/common/entity/EntitySpark.java @@ -33,6 +33,8 @@ import vazkii.botania.api.mana.spark.ISparkAttachable; import vazkii.botania.api.mana.spark.ISparkEntity; import vazkii.botania.api.mana.spark.SparkHelper; +import vazkii.botania.api.subtile.SubTileEntity; +import vazkii.botania.common.block.tile.TileSpecialFlower; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.ModItems; @@ -323,8 +325,13 @@ public ISparkAttachable getAttachedTile() { int y = MathHelper.floor_double(posY) - 1; int z = MathHelper.floor_double(posZ); TileEntity tile = worldObj.getTileEntity(x, y, z); - if(tile != null && tile instanceof ISparkAttachable) - return (ISparkAttachable) tile; + if (tile != null){ + if (tile instanceof ISparkAttachable) return (ISparkAttachable)tile; + else if (tile instanceof TileSpecialFlower){ + SubTileEntity subtile = ((TileSpecialFlower)tile).getSubTile(); + if (subtile instanceof ISparkAttachable) return (ISparkAttachable)subtile; + } + } return null; } diff --git a/src/main/java/vazkii/botania/common/item/ItemSpark.java b/src/main/java/vazkii/botania/common/item/ItemSpark.java index 049dd807fc..1b81fe3b59 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSpark.java +++ b/src/main/java/vazkii/botania/common/item/ItemSpark.java @@ -21,9 +21,11 @@ import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IManaGivingItem; import vazkii.botania.api.mana.spark.ISparkAttachable; +import vazkii.botania.api.subtile.SubTileEntity; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.achievement.ICraftAchievement; import vazkii.botania.common.achievement.ModAchievements; +import vazkii.botania.common.block.tile.TileSpecialFlower; import vazkii.botania.common.entity.EntitySpark; import vazkii.botania.common.lib.LibItemNames; @@ -50,7 +52,23 @@ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int } return true; } - } + } else if (tile instanceof TileSpecialFlower) { + SubTileEntity subtile = ((TileSpecialFlower)tile).getSubTile(); + if(subtile instanceof ISparkAttachable attach) { + if(attach.canAttachSpark(stack) && attach.getAttachedSpark() == null) { + stack.stackSize--; + if(!world.isRemote) { + EntitySpark spark = new EntitySpark(world); + spark.setPosition(x + 0.5, y + 1.5, z + 0.5); + world.spawnEntityInWorld(spark); + attach.attachSpark(spark); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); + } + return true; + } + } + } + System.out.println("false"); return false; } diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index e86c49f457..6fa920e634 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -138,6 +138,7 @@ public final class LexiconData { public static LexiconEntry spectrolus; public static LexiconEntry rafflowsia; public static LexiconEntry dandelifeon; + public static LexiconEntry reiujia; public static LexiconEntry pylon; public static LexiconEntry manaEnchanting; @@ -701,6 +702,9 @@ public static void init() { new PageText("3"), new PageText("4"), new PageText("5"), new PageText("6"), new PageText("10"), new PageText("7"), new PagePetalRecipe<>("8", ModPetalRecipes.dandelifeonRecipe), new PageCraftingRecipe("9", ModCraftingRecipes.recipeCellBlock)); + + reiujia = new BLexiconEntry(LibLexicon.GFLOWER_REIUJIA, categoryGenerationFlowers); + reiujia.setLexiconPages(new PageText("0")); // DEVICES ENTRIES pylon = new BLexiconEntry(LibLexicon.DEVICE_PYLON, categoryDevices); diff --git a/src/main/java/vazkii/botania/common/lib/LibBlockNames.java b/src/main/java/vazkii/botania/common/lib/LibBlockNames.java index 3d0992cb11..e0332d235a 100644 --- a/src/main/java/vazkii/botania/common/lib/LibBlockNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibBlockNames.java @@ -126,6 +126,7 @@ public final class LibBlockNames { public static final String SUBTILE_SPECTROLUS = "spectrolus"; public static final String SUBTILE_DANDELIFEON = "dandelifeon"; public static final String SUBTILE_RAFFLOWSIA = "rafflowsia"; + public static final String SUBTILE_REIUJIA = "reiujia"; public static final String SUBTILE_BELLETHORN = "bellethorn"; public static final String SUBTILE_DREADTHORN = "dreadthorn"; diff --git a/src/main/java/vazkii/botania/common/lib/LibLexicon.java b/src/main/java/vazkii/botania/common/lib/LibLexicon.java index a2c0cee51a..12c69633b1 100644 --- a/src/main/java/vazkii/botania/common/lib/LibLexicon.java +++ b/src/main/java/vazkii/botania/common/lib/LibLexicon.java @@ -109,6 +109,7 @@ public final class LibLexicon { public static final String GFLOWER_SPECTROLUS = "spectrolus"; public static final String GFLOWER_RAFFLOWSIA = "rafflowsia"; public static final String GFLOWER_DANDELIFEON = "dandelifeon"; + public static final String GFLOWER_REIUJIA = "reiujia"; public static final String DEVICE_PYLON = "pylon"; public static final String DEVICE_MANA_ENCHANTING = "manaEnchanting"; diff --git a/src/main/resources/assets/botania/lang/en_US.lang b/src/main/resources/assets/botania/lang/en_US.lang index f7d6279cc1..9d2693d1a9 100644 --- a/src/main/resources/assets/botania/lang/en_US.lang +++ b/src/main/resources/assets/botania/lang/en_US.lang @@ -1277,6 +1277,8 @@ tile.botania:flower.dandelifeon.name=Dandelifeon tile.botania:flower.dandelifeon.reference=C'est la vie tile.botania:flower.rafflowsia.name=Rafflowsia tile.botania:flower.rafflowsia.reference=Trap Hole Nightmare +tile.botania:flower.reiujia.name=Reiujia +tile.botania:flower.reiujia.reference=The culmination of mystic wisdom # - FUNCTIONAL tile.botania:flower.bellethorn.name=Bellethorne @@ -3098,6 +3100,12 @@ botania.page.dandelifeon7=&1Cellular Blocks&0 are crafted with &1Cactus&0, &1Car botania.page.dandelifeon8=&oCellCraft^2&r. botania.page.dandelifeon9=Creating &1Cellular Blocks&0 +# -- REIUJIA +botania.entry.reiujia=Reiujia +botania.tagline.reiujia=If you can't solve a problem with brute force, you're not using enough of it. +botania.page.reiujia0=In order to generate a blast of &4Mana&0, one might in fact, require a blast nearby. Igniting a block of &1TNT&0 in the near an &1Entropinnyum&0, if it doesn't fall in water, will have the latter absorb all the entropy generated by the blast into itself, creating a large amount of &4Mana&0 and nullifying any possible damage. Lastly, to absorb the explosion, the flower must not have any &4Mana&0 stored in it or the process will fail. +botania.page.reiujia0=In principle there is no reason the &1Entropinnyum&0's blast absorption ability couldn't be scaled. The only limiting factor is that flowers are generally not too sturdy. Perhaps some magical reinforcement and attunement to the proper energy type will do the trick. + # - NATURAL APPARATUS # -- MANA PYLON botania.entry.pylon=Mana Pylon diff --git a/src/main/resources/assets/botania/textures/blocks/reiujia.png b/src/main/resources/assets/botania/textures/blocks/reiujia.png new file mode 100644 index 0000000000..6ec8b45f29 Binary files /dev/null and b/src/main/resources/assets/botania/textures/blocks/reiujia.png differ