mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 19:05:16 +00:00
Added a flower slowdown/delay system.
This commit is contained in:
1 parent
74862b3438
commit
59533fee9b
17 files changed
+108
-16
No files matched your search
@@ -1,4 +1,4 @@
|
||||
@API(owner = "Botania", apiVersion = "74", provides = "BotaniaAPI")
|
||||
@API(owner = "Botania", apiVersion = "75", provides = "BotaniaAPI")
|
||||
package vazkii.botania.api;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 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 @ [29/12/2015, 23:00:06 (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.subtile;
|
||||
|
||||
/**
|
||||
* An extension of ISubTileContainer that allows for the SubTile to be "slowed down".
|
||||
* Slowing down is the action that happens when a flower is planted in Podzol or Mycellium.
|
||||
* Any flowers that pick up items from the ground should have a delay on the time the item
|
||||
* needs to be on the floor equal to the value of getSlowDownFactor().
|
||||
*/
|
||||
public interface ISubTileSlowableContainer extends ISubTileContainer {
|
||||
|
||||
public static final int SLOWDOWN_FACTOR_PODZOL = 5;
|
||||
public static final int SLOWDOWN_FACTOR_MYCEL = 10;
|
||||
|
||||
public int getSlowdownFactor();
|
||||
|
||||
}
|
||||
@@ -225,6 +225,19 @@ public class SubTileEntity {
|
||||
public boolean isOvergrowthAffected() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ths slowdown factor of this SubTile.
|
||||
* @see ISubTileSlowableContainer
|
||||
*/
|
||||
public int getSlowdownFactor() {
|
||||
if(supertile instanceof ISubTileSlowableContainer) {
|
||||
ISubTileSlowableContainer slowable = (ISubTileSlowableContainer) supertile;
|
||||
return slowable.getSlowdownFactor();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -192,7 +193,7 @@ public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvid
|
||||
|
||||
@Override
|
||||
protected boolean canPlaceBlockOn(Block block) {
|
||||
return super.canPlaceBlockOn(block) || block == ModBlocks.redStringRelay;
|
||||
return super.canPlaceBlockOn(block) || block == ModBlocks.redStringRelay || block == Blocks.mycelium;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,11 +50,13 @@ public class SubTileDaffomill extends SubTileFunctional {
|
||||
|
||||
if(axis != null) {
|
||||
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, axis);
|
||||
for(EntityItem item : items) {
|
||||
item.motionX += dir.offsetX * 0.05;
|
||||
item.motionY += dir.offsetY * 0.05;
|
||||
item.motionZ += dir.offsetZ * 0.05;
|
||||
}
|
||||
int slowdown = getSlowdownFactor();
|
||||
for(EntityItem item : items)
|
||||
if(!item.isDead && item.age >= slowdown) {
|
||||
item.motionX += dir.offsetX * 0.05;
|
||||
item.motionY += dir.offsetY * 0.05;
|
||||
item.motionZ += dir.offsetZ * 0.05;
|
||||
}
|
||||
}
|
||||
|
||||
windTicks--;
|
||||
|
||||
@@ -70,8 +70,10 @@ public class SubTileHopperhock extends SubTileFunctional {
|
||||
int z = supertile.zCoord;
|
||||
|
||||
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range + 1, y + range + 1, z + range + 1));
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
for(EntityItem item : items) {
|
||||
if(item.age < 60 || item.age >= 105 && item.age < 110 || item.isDead)
|
||||
if(item.age < (60 + slowdown) || item.age >= 105 && item.age < 110 || item.isDead)
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getEntityItem();
|
||||
|
||||
+3
-1
@@ -36,6 +36,8 @@ public class SubTilePollidisiac extends SubTileFunctional {
|
||||
|
||||
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord, supertile.zCoord - RANGE, supertile.xCoord + 1 + RANGE, supertile.yCoord + 1, supertile.zCoord + 1 +RANGE));
|
||||
List<EntityAnimal> animals = supertile.getWorldObj().getEntitiesWithinAABB(EntityAnimal.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord, supertile.zCoord - RANGE, supertile.xCoord + 1 +RANGE, supertile.yCoord + 1, supertile.zCoord + 1 +RANGE));
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
for(EntityAnimal animal : animals) {
|
||||
if(mana < manaCost)
|
||||
break;
|
||||
@@ -43,7 +45,7 @@ public class SubTilePollidisiac extends SubTileFunctional {
|
||||
int love = ReflectionHelper.getPrivateValue(EntityAnimal.class, animal, LibObfuscation.IN_LOVE);
|
||||
if(animal.getGrowingAge() == 0 && love <= 0) {
|
||||
for(EntityItem item : items) {
|
||||
if(item.age < 60 || item.isDead)
|
||||
if(item.age < (60 + slowdown) || item.isDead)
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getEntityItem();
|
||||
|
||||
+2
-1
@@ -78,8 +78,9 @@ public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
int z = supertile.zCoord;
|
||||
|
||||
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - RANGE, y - RANGE_Y, z - RANGE, x + RANGE + 1, y + RANGE_Y, z + RANGE + 1));
|
||||
int slowdown = getSlowdownFactor();
|
||||
for(EntityItem item : items) {
|
||||
if(item.age < 60 || item.isDead)
|
||||
if(item.age < (60 + slowdown) || item.isDead)
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getEntityItem();
|
||||
|
||||
+3
-1
@@ -54,8 +54,10 @@ public class SubTileSpectranthemum extends SubTileFunctional {
|
||||
|
||||
boolean did = false;
|
||||
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - RANGE, y - RANGE, z - RANGE, x + RANGE + 1, y + RANGE, z + RANGE + 1));
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
for(EntityItem item : items) {
|
||||
if(item.age < 60 || item.isDead || item.getEntityData().getBoolean(TAG_TELEPORTED))
|
||||
if(item.age < (60 + slowdown) || item.isDead || item.getEntityData().getBoolean(TAG_TELEPORTED))
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getEntityItem();
|
||||
|
||||
@@ -42,9 +42,11 @@ public class SubTileEndoflame extends SubTileGenerating {
|
||||
if(mana < getMaxMana()) {
|
||||
boolean didSomething = false;
|
||||
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.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(EntityItem item : items) {
|
||||
if(item.age >= 59 && !item.isDead) {
|
||||
if(item.age >= (59 + slowdown) && !item.isDead) {
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if(stack.getItem().hasContainerItem(stack))
|
||||
continue;
|
||||
|
||||
+3
-1
@@ -43,11 +43,13 @@ public class SubTileGourmaryllis extends SubTileGenerating {
|
||||
sync();
|
||||
}
|
||||
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
boolean remote = supertile.getWorldObj().isRemote;
|
||||
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.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(EntityItem item : items) {
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if(stack != null && stack.getItem() instanceof ItemFood && !item.isDead) {
|
||||
if(stack != null && stack.getItem() instanceof ItemFood && !item.isDead && item.age >= slowdown) {
|
||||
if(cooldown == 0) {
|
||||
if(!remote) {
|
||||
int val = ((ItemFood) stack.getItem()).func_150905_g(stack);
|
||||
|
||||
@@ -46,9 +46,11 @@ public class SubTileSpectrolus extends SubTileGenerating {
|
||||
boolean remote = supertile.getWorldObj().isRemote;
|
||||
Item wool = Item.getItemFromBlock(Blocks.wool);
|
||||
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1));
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
for(EntityItem item : items) {
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if(stack != null && stack.getItem() == wool) {
|
||||
if(stack != null && stack.getItem() == wool && !item.isDead && item.age >= slowdown) {
|
||||
int meta = stack.getItemDamage();
|
||||
if(meta == nextColor) {
|
||||
if(!remote) {
|
||||
|
||||
@@ -52,4 +52,13 @@ public class TileFloatingSpecialFlower extends TileSpecialFlower implements IFlo
|
||||
type = IslandType.ofType(cmp.getString(TAG_ISLAND_TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlowdownFactor() {
|
||||
switch(getIslandType()) {
|
||||
case MYCEL: return SLOWDOWN_FACTOR_MYCEL;
|
||||
case PODZOL: return SLOWDOWN_FACTOR_PODZOL;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.common.block.tile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -25,13 +26,13 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.subtile.ISubTileContainer;
|
||||
import vazkii.botania.api.subtile.ISubTileSlowableContainer;
|
||||
import vazkii.botania.api.subtile.SubTileEntity;
|
||||
import vazkii.botania.api.wand.IWandBindable;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.string.TileRedStringRelay;
|
||||
|
||||
public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTileContainer {
|
||||
public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTileSlowableContainer {
|
||||
|
||||
private static final String TAG_SUBTILE_NAME = "subTileName";
|
||||
private static final String TAG_SUBTILE_CMP = "subTileCmp";
|
||||
@@ -219,4 +220,19 @@ public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTil
|
||||
return 0;
|
||||
return subTile.getPowerLevel(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlowdownFactor() {
|
||||
Block below = worldObj.getBlock(xCoord, yCoord - 1, zCoord);
|
||||
if(below == Blocks.mycelium)
|
||||
return SLOWDOWN_FACTOR_MYCEL;
|
||||
|
||||
if(below == Blocks.dirt) {
|
||||
int meta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord);
|
||||
if(meta == 2)
|
||||
return SLOWDOWN_FACTOR_PODZOL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,7 @@ public final class LexiconData {
|
||||
|
||||
public static LexiconEntry functionalIntro;
|
||||
public static LexiconEntry flowerShrinking;
|
||||
public static LexiconEntry flowerSpeed;
|
||||
public static LexiconEntry jadedAmaranthus;
|
||||
public static LexiconEntry bellethorne;
|
||||
public static LexiconEntry dreadthorne;
|
||||
@@ -451,6 +452,10 @@ public final class LexiconData {
|
||||
flowerShrinking = new BLexiconEntry(LibLexicon.FFLOWER_SHRINKING, categoryFunctionalFlowers);
|
||||
flowerShrinking.setPriority().setLexiconPages(new PageText("0"), new PageManaInfusionRecipe("1", BotaniaAPI.miniFlowerRecipes)).setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BELLETHORN + "Chibi"));
|
||||
|
||||
flowerSpeed = new BLexiconEntry(LibLexicon.FFLOWER_SPEED, categoryFunctionalFlowers);
|
||||
flowerSpeed.setPriority().setLexiconPages(new PageText("0"), new PageText("1"));
|
||||
flowerSpeed.setIcon(new ItemStack(Blocks.dirt, 1, 2));
|
||||
|
||||
jadedAmaranthus = new BLexiconEntry(LibLexicon.FFLOWER_JADED_AMARANTHUS, categoryFunctionalFlowers);
|
||||
jadedAmaranthus.setLexiconPages(new PageText("0"), new PagePetalRecipe("1", ModPetalRecipes.jadedAmaranthusRecipe), new PageText("2"));
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ public final class LibLexicon {
|
||||
|
||||
public static final String FFLOWER_INTRO = "fIntro";
|
||||
public static final String FFLOWER_SHRINKING = "flowerShrinking";
|
||||
public static final String FFLOWER_SPEED = "flowerSpeed";
|
||||
public static final String FFLOWER_JADED_AMARANTHUS = "jadedAmaranthus";
|
||||
public static final String FFLOWER_BELLETHORNE = "bellethorne";
|
||||
public static final String FFLOWER_DREADTHORNE = "dreadthorne";
|
||||
|
||||
Reference in new issue
Block a user