Added the Tigerseye.

This commit is contained in:
Vasco Lavos committed 2014-02-16 15:51:50 +00:00
1 parent 2ff76f9cb2
commit 4b04809882
6 files changed
+112

No files matched your search

@@ -60,6 +60,7 @@ public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvid
// Functional
LibBlockNames.SUBTILE_BELLETHORN,
LibBlockNames.SUBTILE_HEISEI_DREAM,
LibBlockNames.SUBTILE_TIGERSEYE,
};
protected BlockSpecialFlower() {
@@ -18,6 +18,7 @@ import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.common.block.subtile.SubTilePureDaisy;
import vazkii.botania.common.block.subtile.functional.SubTileBellethorn;
import vazkii.botania.common.block.subtile.functional.SubTileHeiseiDream;
import vazkii.botania.common.block.subtile.functional.SubTileTigerseye;
import vazkii.botania.common.block.subtile.generating.SubTileDaybloom;
import vazkii.botania.common.block.subtile.generating.SubTileEndoflame;
import vazkii.botania.common.block.tile.TileAltar;
@@ -75,5 +76,6 @@ public final class ModBlocks {
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_BELLETHORN, SubTileBellethorn.class);
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_HEISEI_DREAM, SubTileHeiseiDream.class);
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_TIGERSEYE, SubTileTigerseye.class);
}
}
@@ -0,0 +1,101 @@
/**
* 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Feb 16, 2014, 3:36:26 PM (GMT)]
*/
package vazkii.botania.common.block.subtile.functional;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.ai.EntityAIAvoidEntity;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAITaskEntry;
import net.minecraft.entity.item.EntityEnderCrystal;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import vazkii.botania.common.block.subtile.SubTileFunctional;
import vazkii.botania.common.lib.LibObfuscation;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class SubTileTigerseye extends SubTileFunctional {
@Override
public void onUpdate() {
super.onUpdate();
final int range = 10;
final int rangeY = 4;
final int cost = 70;
boolean shouldAfffect = mana >= cost;
List<EntityLiving> entities = supertile.worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - range, supertile.yCoord - rangeY, supertile.zCoord - range, supertile.xCoord + range, supertile.yCoord + rangeY, supertile.zCoord + range));
for(EntityLiving entity : entities) {
List<EntityAITaskEntry> entries = new ArrayList(entity.tasks.taskEntries);
entries.addAll(new ArrayList(entity.targetTasks.taskEntries));
boolean avoidsOcelots = false;
if(shouldAfffect)
for(EntityAITaskEntry entry : entries) {
if(entry.action instanceof EntityAIAvoidEntity)
avoidsOcelots = messWithRunAwayAI((EntityAIAvoidEntity) entry.action) || avoidsOcelots;
if(entry.action instanceof EntityAINearestAttackableTarget)
messWithGetTargetAI((EntityAINearestAttackableTarget) entry.action);
}
if(entity instanceof EntityCreeper) {
ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper) entity, 2, LibObfuscation.TIME_SINCE_IGNITED);
entity.setAttackTarget(null);
}
if(avoidsOcelots) {
mana -= cost;
System.out.println("do");
PacketDispatcher.sendPacketToAllInDimension(supertile.getDescriptionPacket(), supertile.worldObj.provider.dimensionId);
shouldAfffect = false;
}
}
}
private boolean messWithRunAwayAI(EntityAIAvoidEntity aiEntry) {
if(ReflectionHelper.getPrivateValue(EntityAIAvoidEntity.class, aiEntry, LibObfuscation.TARGET_ENTITY_CLASS) == EntityOcelot.class) {
ReflectionHelper.setPrivateValue(EntityAIAvoidEntity.class, aiEntry, EntityPlayer.class, LibObfuscation.TARGET_ENTITY_CLASS);
return true;
}
return false;
}
private void messWithGetTargetAI(EntityAINearestAttackableTarget aiEntry) {
if(ReflectionHelper.getPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, LibObfuscation.TARGET_CLASS) == EntityPlayer.class)
ReflectionHelper.setPrivateValue(EntityAINearestAttackableTarget.class, aiEntry, EntityEnderCrystal.class, LibObfuscation.TARGET_CLASS); // Something random that won't be around
}
@Override
public int getColor() {
return 0xB1A618;
}
@Override
public int getMaxMana() {
return 1000;
}
// @Override
// public LexiconEntry getEntry() {
// return LexiconData.heiseiDream;
// }
}
@@ -34,5 +34,6 @@ public final class LibBlockNames {
public static final String SUBTILE_BELLETHORN = "bellethorn";
public static final String SUBTILE_HEISEI_DREAM = "heiseiDream";
public static final String SUBTILE_TIGERSEYE = "tigerseye";
}
@@ -21,4 +21,10 @@ public final class LibObfuscation {
// EntityAIAttackOnCollide
public static final String[] CLASS_TARGET = new String[] { "classTarget", "field_75444_h", "g" };
// EntityAIAvoidEntity
public static final String[] TARGET_ENTITY_CLASS = new String[] { "targetEntityClass", "field_75381_h", "i" };
// EntityCreeper
public static final String[] TIME_SINCE_IGNITED = new String[] { "timeSinceIgnited", "field_70833_d", "bq" };
}
+1
View File
@@ -80,6 +80,7 @@ tile.botania:flower.endoflame.name=Endoflame
# - FUNCTIONAL
tile.botania:flower.bellethorn.name=Bellethorne
tile.botania:flower.heiseiDream.name=Heisei Dream
tile.botania:flower.tigerseye.name=Tigerseye
# ITEM NAMES
item.botania:lexicon.name=Lexica Botania