mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Restore thaumcraft integration. Closes #74
This commit is contained in:
1 parent
b8e06a3d36
commit
65fe04af3a
6 files changed
+6
-194
No files matched your search
@@ -71,7 +71,7 @@ public class TileMod extends TileEntity implements ITickable {
|
||||
else {
|
||||
try {
|
||||
updateEntity();
|
||||
} catch (Exception e) { // todo 1.8 remove this abhorration after I figure out what's going on.
|
||||
} catch (NullPointerException e) { // todo 1.8 remove this abhorration after I figure out what's going on.
|
||||
e.printStackTrace();
|
||||
FMLLog.severe("[Botania]: CLIENT TICK FAILED");
|
||||
FMLLog.severe("[Botania]: World: %s, Pos: %s, TE: %s", worldObj, pos, this);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ModBrews {
|
||||
|
||||
public static void initTC() {
|
||||
Potion warpWardPotion = Potion.getPotionFromResourceLocation("minecraft:warp_ward");
|
||||
// TODO thaumcraft 5 is currently registering its potions under the Minecraft namespace
|
||||
// thaumcraft 5 is registering its potions under the Minecraft namespace
|
||||
|
||||
if(warpWardPotion != null)
|
||||
warpWard = new BrewMod(LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new PotionEffect(warpWardPotion.id, 12000, 0)).setNotBloodPendantInfusable();
|
||||
|
||||
@@ -1,187 +0,0 @@
|
||||
/**
|
||||
* 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 @ [Apr 14, 2014, 4:30:40 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.core.handler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityBeacon;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
// This is legacy code and is no longer used. Check out TileTerraPlate instead.
|
||||
public final class TerrasteelCraftingHandler {
|
||||
|
||||
private static final String TAG_TIME = "Botania-CraftingTime";
|
||||
private static final int TIME = 100;
|
||||
private static final int MANA_PER_TICK = (int) (TilePool.MAX_MANA / 2 / TIME * 0.9);
|
||||
|
||||
public static void onEntityUpdate(EntityItem item) {
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if(stack != null && stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 0) {
|
||||
int time = validateCraftingItem(item);
|
||||
|
||||
if(time != -1) {
|
||||
doParticles(item, time);
|
||||
if(time == TIME)
|
||||
item.worldObj.playSoundAtEntity(item, "botania:terrasteelCraft", 1F, 1F);
|
||||
|
||||
getManaFromPools : {
|
||||
BlockPos pos = new BlockPos(item);
|
||||
int range = 12;
|
||||
|
||||
for(int i = -range; i < range + 1; i++)
|
||||
for(int j = -range; j < range + 1; j++)
|
||||
for(int k = - range; k < range + 1; k++) {
|
||||
BlockPos pos_ = pos.add(i, j, k);
|
||||
TileEntity tile = item.worldObj.getTileEntity(pos_);
|
||||
|
||||
if(tile instanceof IManaPool) {
|
||||
IManaPool pool = (IManaPool) tile;
|
||||
|
||||
if(!item.worldObj.isRemote && pool.getCurrentMana() >= MANA_PER_TICK) {
|
||||
pool.recieveMana(-MANA_PER_TICK);
|
||||
item.worldObj.markBlockForUpdate(tile.getPos());
|
||||
incrementCraftingTime(item, time);
|
||||
break getManaFromPools;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int validateCraftingItem(EntityItem item) {
|
||||
ItemStack estack = item.getEntityItem();
|
||||
if(estack.stackSize != 1)
|
||||
return -1;
|
||||
|
||||
BlockPos pos = new BlockPos(item);
|
||||
|
||||
if(item.worldObj.getBlockState(pos.down()).getBlock() != Blocks.beacon)
|
||||
return -1;
|
||||
|
||||
TileEntityBeacon beacon = (TileEntityBeacon) item.worldObj.getTileEntity(pos.down());
|
||||
if(beacon.getField(0) <= 0) // Field 0 -> levels
|
||||
return -1;
|
||||
|
||||
List<EntityItem> items = item.worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
|
||||
|
||||
EntityItem diamond = null;
|
||||
EntityItem pearl = null;
|
||||
|
||||
for(EntityItem otherItem : items) {
|
||||
if(otherItem == item)
|
||||
continue;
|
||||
|
||||
ItemStack stack = otherItem.getEntityItem();
|
||||
if(stack.getItem() == ModItems.manaResource && stack.stackSize == 1) {
|
||||
int meta = stack.getItemDamage();
|
||||
if(meta == 1) {
|
||||
if(pearl == null) {
|
||||
pearl = otherItem;
|
||||
continue;
|
||||
} else return -1;
|
||||
} else if(meta == 2) {
|
||||
if(diamond == null) {
|
||||
diamond = otherItem;
|
||||
continue;
|
||||
} else return -1;
|
||||
} else return -1;
|
||||
} else return -1;
|
||||
}
|
||||
|
||||
if(diamond != null && pearl != null) {
|
||||
int time = getTimeInCrafting(item);
|
||||
if(time > 0) {
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, diamond, 1, LibObfuscation.PICKUP_DELAY);
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, diamond, 0, LibObfuscation.AGE);
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, pearl, 1, LibObfuscation.PICKUP_DELAY);
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, pearl, 0, LibObfuscation.AGE);
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, item, 1, LibObfuscation.PICKUP_DELAY);
|
||||
ObfuscationReflectionHelper.setPrivateValue(EntityItem.class, item, 0, LibObfuscation.AGE);
|
||||
}
|
||||
|
||||
return time;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int getTimeInCrafting(EntityItem item) {
|
||||
ItemStack stack = item.getEntityItem();
|
||||
return ItemNBTHelper.getInt(stack, TAG_TIME, 0);
|
||||
}
|
||||
|
||||
static void doParticles(EntityItem item, int ticks) {
|
||||
if(item.worldObj.isRemote) {
|
||||
int totalSpiritCount = 3;
|
||||
double tickIncrement = 360D / totalSpiritCount;
|
||||
|
||||
int speed = 5;
|
||||
double wticks = ticks * speed - tickIncrement;
|
||||
|
||||
double r = Math.sin((ticks - TIME) / 10D) * 2;
|
||||
double g = Math.sin(wticks * Math.PI / 180 * 0.55);
|
||||
|
||||
for(int i = 0; i < totalSpiritCount; i++) {
|
||||
double x = (int) item.posX + Math.sin(wticks * Math.PI / 180) * r + 0.5;
|
||||
double y = (int) item.posY + 0.25;
|
||||
double z = (int) item.posZ + Math.cos(wticks * Math.PI / 180) * r + 0.5;
|
||||
|
||||
wticks += tickIncrement;
|
||||
float[] colorsfx = new float[] {
|
||||
0F, (float) ticks / (float) TIME, 1F - (float) ticks / (float) TIME
|
||||
};
|
||||
Botania.proxy.wispFX(item.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F, (float)g * 0.05F, 0.25F);
|
||||
Botania.proxy.wispFX(item.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], (float) Math.random() * 0.1F + 0.1F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, 0.9F);
|
||||
|
||||
if(ticks == TIME)
|
||||
for(int j = 0; j < 15; j++)
|
||||
Botania.proxy.wispFX(item.worldObj, item.posX, item.posY, item.posZ, colorsfx[0], colorsfx[1], colorsfx[2], (float) Math.random() * 0.15F + 0.15F, (float) (Math.random() - 0.5F) * 0.125F, (float) (Math.random() - 0.5F) * 0.125F, (float) (Math.random() - 0.5F) * 0.125F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void incrementCraftingTime(EntityItem item, int time) {
|
||||
if(time >= TIME)
|
||||
finalizeCraftingRecipe(item);
|
||||
|
||||
else {
|
||||
ItemStack stack = item.getEntityItem();
|
||||
ItemNBTHelper.setInt(stack, TAG_TIME, time + 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void finalizeCraftingRecipe(EntityItem item) {
|
||||
int x = MathHelper.floor_double(item.posX);
|
||||
int y = MathHelper.floor_double(item.posY);
|
||||
int z = MathHelper.floor_double(item.posZ);
|
||||
|
||||
List<EntityItem> items = item.worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1));
|
||||
for(EntityItem otherItem : items)
|
||||
if(otherItem != item)
|
||||
otherItem.setDead();
|
||||
else item.setEntityItemStack(new ItemStack(ModItems.manaResource, 1, 4));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class ModBrewRecipes {
|
||||
Item resource = Item.itemRegistry.getObject(new ResourceLocation("thaumcraft", "salis_mundus"));
|
||||
Item bathSalts = Item.itemRegistry.getObject(new ResourceLocation("thaumcraft", "bath_salts"));
|
||||
|
||||
// todo 1.8 see LexiconData: warpWardBrew = BotaniaAPI.registerBrewRecipe(ModBrews.warpWard, new ItemStack(Items.nether_wart), new ItemStack(resource, 1, 14), new ItemStack(bathSalts), new ItemStack(resource, 1, 6));
|
||||
warpWardBrew = BotaniaAPI.registerBrewRecipe(ModBrews.warpWard, new ItemStack(Items.nether_wart), new ItemStack(resource, 1, 14), new ItemStack(bathSalts), new ItemStack(resource, 1, 6));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1106,10 +1106,9 @@ public final class LexiconData {
|
||||
if(Botania.thaumcraftLoaded) {
|
||||
tcIntegration = new CLexiconEntry(LibLexicon.MISC_TC_INTEGRATION, BotaniaAPI.categoryMisc, "Thaumcraft");
|
||||
|
||||
// todo 1.8: we removed our after thaumcraft dep, but it turns out we actually need it. Stub out warp ward brew from rendering for now until discussion w/ Azanor
|
||||
if(ConfigHandler.enableThaumcraftStablizers)
|
||||
tcIntegration.setLexiconPages(new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), new PageText("3"), new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe), new PageText("5")/*, new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b")*/).setIcon(new ItemStack(ModItems.manaInkwell));
|
||||
else tcIntegration.setLexiconPages(new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), new PageText("3"), new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe)/*, new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b")*/).setIcon(new ItemStack(ModItems.manaInkwell));
|
||||
tcIntegration.setLexiconPages(new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), new PageText("3"), new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe), new PageText("5"), new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b")).setIcon(new ItemStack(ModItems.manaInkwell));
|
||||
else tcIntegration.setLexiconPages(new PageText("0"), new PageText("1"), new PageCraftingRecipe("2", ModCraftingRecipes.recipeHelmetOfRevealing), new PageText("3"), new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaInkwellRecipe), new PageBrew(ModBrewRecipes.warpWardBrew, "6a", "6b")).setIcon(new ItemStack(ModItems.manaInkwell));
|
||||
}
|
||||
|
||||
if(Botania.etFuturumLoaded) {
|
||||
|
||||
@@ -19,7 +19,7 @@ public final class LibMisc {
|
||||
public static final String MOD_NAME = MOD_ID;
|
||||
public static final String BUILD = "GRADLE:BUILD";
|
||||
public static final String VERSION = "GRADLE:VERSION-" + BUILD;
|
||||
public static final String DEPENDENCIES = "required-after:Baubles";
|
||||
public static final String DEPENDENCIES = "required-after:Baubles;after:Thaumcraft";
|
||||
public static final String MC_VERSIONS = "[1.8.8,1.8.9]";
|
||||
|
||||
// Network Contants
|
||||
|
||||
Reference in new issue
Block a user