Add the Corporea Index. It looks cool but doesn't do anything, guess that's good progress?

This commit is contained in:
Lizbeth Rika committed 2015-02-15 02:07:15 +00:00
1 parent 885efe6a9f
commit 941bdeed9f
20 files changed
+387 -10

No files matched your search

@@ -18,6 +18,8 @@ import java.util.WeakHashMap;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public final class CorporeaHelper {
@@ -163,6 +165,23 @@ public final class CorporeaHelper {
return retStack;
}
/**
* Gets the spark attached to the block in the coords passed in. Note that the coords passed
* in are for the block that the spark will be on, not the coords of the spark itself.
*/
public static ICorporeaSpark getSparkForBlock(World world, int x, int y, int z) {
List<ICorporeaSpark> sparks = world.getEntitiesWithinAABB(ICorporeaSpark.class, AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 2, z + 1));
return sparks.isEmpty() ? null : sparks.get(0);
}
/**
* Gets if the block in the coords passed in has a spark attached. Note that the coords passed
* in are for the block that the spark will be on, not the coords of the spark itself.
*/
public static boolean doesBlockHaveSpark(World world, int x, int y, int z) {
return getSparkForBlock(world, x, y, z) != null;
}
/**
* Gets if the slot passed in can be extracted from by a spark.
*/
@@ -161,7 +161,6 @@ public final class RenderHelper {
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDepthMask(false);
GL11.glTranslatef(0F, -1F, -2F);
GL11.glScalef(xScale, yScale, zScale);
for (int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) {
@@ -52,6 +52,7 @@ import vazkii.botania.client.integration.nei.NEIGuiHooks;
import vazkii.botania.client.lib.LibRenderIDs;
import vazkii.botania.client.render.block.RenderAltar;
import vazkii.botania.client.render.block.RenderBrewery;
import vazkii.botania.client.render.block.RenderCorporeaIndex;
import vazkii.botania.client.render.block.RenderFloatingFlower;
import vazkii.botania.client.render.block.RenderPool;
import vazkii.botania.client.render.block.RenderPylon;
@@ -70,6 +71,7 @@ import vazkii.botania.client.render.item.RenderTransparentItem;
import vazkii.botania.client.render.tile.RenderTileAlfPortal;
import vazkii.botania.client.render.tile.RenderTileAltar;
import vazkii.botania.client.render.tile.RenderTileBrewery;
import vazkii.botania.client.render.tile.RenderTileCorporeaIndex;
import vazkii.botania.client.render.tile.RenderTileEnchanter;
import vazkii.botania.client.render.tile.RenderTileFloatingFlower;
import vazkii.botania.client.render.tile.RenderTilePool;
@@ -96,6 +98,7 @@ import vazkii.botania.common.block.tile.TileSpawnerClaw;
import vazkii.botania.common.block.tile.TileStarfield;
import vazkii.botania.common.block.tile.TileTerraPlate;
import vazkii.botania.common.block.tile.TileTinyPotato;
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
import vazkii.botania.common.block.tile.mana.TilePool;
import vazkii.botania.common.block.tile.mana.TilePrism;
import vazkii.botania.common.block.tile.mana.TileSpreader;
@@ -161,6 +164,7 @@ public class ClientProxy extends CommonProxy {
LibRenderIDs.idTinyPotato = RenderingRegistry.getNextAvailableRenderId();
LibRenderIDs.idSpawnerClaw = RenderingRegistry.getNextAvailableRenderId();
LibRenderIDs.idBrewery = RenderingRegistry.getNextAvailableRenderId();
LibRenderIDs.idCorporeaIndex = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new RenderAltar());
RenderingRegistry.registerBlockHandler(new RenderSpecialFlower(LibRenderIDs.idSpecialFlower));
@@ -171,6 +175,7 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerBlockHandler(new RenderTinyPotato());
RenderingRegistry.registerBlockHandler(new RenderSpawnerClaw());
RenderingRegistry.registerBlockHandler(new RenderBrewery());
RenderingRegistry.registerBlockHandler(new RenderCorporeaIndex());
RenderTransparentItem renderTransparentItem = new RenderTransparentItem();
RenderFloatingFlowerItem renderFloatingFlower = new RenderFloatingFlowerItem();
@@ -200,6 +205,7 @@ public class ClientProxy extends CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileTerraPlate.class, new RenderTileTerraPlate());
ClientRegistry.bindTileEntitySpecialRenderer(TileRedString.class, new RenderTileRedString());
ClientRegistry.bindTileEntitySpecialRenderer(TilePrism.class, new RenderTilePrism());
ClientRegistry.bindTileEntitySpecialRenderer(TileCorporeaIndex.class, new RenderTileCorporeaIndex());
if(Loader.instance().getMCVersionString().equals("Minecraft 1.7.10"))
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySkull.class, new RenderTileSkullOverride());
@@ -21,5 +21,6 @@ public final class LibRenderIDs {
public static int idTinyPotato = -1;
public static int idSpawnerClaw = -1;
public static int idBrewery = -1;
public static int idCorporeaIndex = -1;
}
@@ -100,6 +100,7 @@ public final class LibResources {
public static final String MODEL_KNOCKBACK_BELT = PREFIX_MODEL + "knockbackBelt.png";
public static final String MODEL_HOLY_CLOAK = PREFIX_MODEL + "holyCloak.png";
public static final String MODEL_UNHOLY_CLOAK = PREFIX_MODEL + "unholyCloak.png";
public static final String MODEL_CORPOREA_INDEX = PREFIX_MODEL + "corporeaIndex.png";
public static final String MODEL_CAPE = "/assets/botania/textures/model/cape.png";
@@ -0,0 +1,54 @@
/**
* 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 @ [Feb 15, 2015, 1:57:50 AM (GMT)]
*/
package vazkii.botania.client.render.block;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.lib.LibRenderIDs;
import vazkii.botania.client.render.tile.RenderTileBrewery;
import vazkii.botania.client.render.tile.RenderTileCorporeaIndex;
import vazkii.botania.common.block.tile.TileBrewery;
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class RenderCorporeaIndex implements ISimpleBlockRenderingHandler {
@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.3F, -0.5F);
GL11.glScalef(1.4F, 1.4F, 1.4F);
RenderTileCorporeaIndex.move = false;
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCorporeaIndex(), 0.0D, 0.0D, 0.0D, 0.0F);
RenderTileCorporeaIndex.move = true;
GL11.glPopMatrix();
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return false;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public int getRenderId() {
return LibRenderIDs.idCorporeaIndex;
}
}
@@ -0,0 +1,73 @@
/**
* 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 @ [Feb 15, 2015, 12:54:49 AM (GMT)]
*/
package vazkii.botania.client.render.tile;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelEnderCrystal;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
public class RenderTileCorporeaIndex extends TileEntitySpecialRenderer {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_CORPOREA_INDEX);
ModelEnderCrystal crystal = new ModelEnderCrystal(0F, false);
public static boolean move = true;
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partticks) {
TileCorporeaIndex index = (TileCorporeaIndex) tile;
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y, z + 0.5);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
float translation = move ? (float) ((Math.cos((float) index.ticksWithCloseby / 10F) * 0.5 + 0.5) * 0.25) : 0F;
float rotation = move ? (index.ticks * 2 + partticks) : 0F;
float scale = 0.6F;
GL11.glScalef(scale, scale, scale);
crystal.render(null, 0F, rotation, translation, 0F, 0F, 1F / 16F);
GL11.glScalef(1F / scale, 1F / scale, 1F / scale);
if(index.closeby > 0F) {
float starScale = 0.02F;
float starRadius = (float) TileCorporeaIndex.RADIUS * index.closeby + (index.closeby == 1F ? 0F : index.hasCloseby ? partticks : -partticks) * 0.2F;
double rads = (index.ticksWithCloseby * 2 + partticks) * Math.PI / 180;
double starX = Math.cos(rads) * starRadius;
double starZ = Math.sin(rads) * starRadius;
int color = 0xFF00FF;
int seed = index.xCoord ^ index.yCoord ^ index.zCoord;
GL11.glTranslated(starX, 0.3, starZ);
RenderHelper.renderStar(color, starScale, starScale, starScale, seed);
GL11.glTranslated(-starX * 2, 0, -starZ * 2);
RenderHelper.renderStar(color, starScale, starScale, starScale, seed);
GL11.glTranslated(starX, 0, starZ);
rads = -rads;
starX = Math.cos(rads) * starRadius;
starZ = Math.sin(rads) * starRadius;
GL11.glTranslated(starX, 0, starZ);
RenderHelper.renderStar(color, starScale, starScale, starScale, seed);
GL11.glTranslated(-starX * 2, 0, -starZ * 2);
RenderHelper.renderStar(color, starScale, starScale, starScale, seed);
GL11.glTranslated(starX, 0, starZ);
}
GL11.glPopMatrix();
}
}
@@ -112,7 +112,7 @@ public class RenderTileRuneAltar extends TileEntitySpecialRenderer {
cubes.renderSpinningCubes(2, repeat, repeat);
GL11.glPopMatrix();
GL11.glTranslatef(0F, 1.2F, 2F);
GL11.glTranslatef(0F, 0.2F, 0F);
float scale = altar.getTargetMana() == 0 ? 0 : (float) altar.getCurrentMana() / (float) altar.getTargetMana() / 75F;
if(scale != 0) {
@@ -19,6 +19,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.oredict.OreDictionary;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.block.corporea.BlockCorporeaIndex;
import vazkii.botania.common.block.decor.BlockBuriedPetals;
import vazkii.botania.common.block.decor.BlockCustomBrick;
import vazkii.botania.common.block.decor.BlockDirtPath;
@@ -117,6 +118,7 @@ import vazkii.botania.common.block.tile.TileStarfield;
import vazkii.botania.common.block.tile.TileTerraPlate;
import vazkii.botania.common.block.tile.TileTinyPlanet;
import vazkii.botania.common.block.tile.TileTinyPotato;
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
import vazkii.botania.common.block.tile.mana.TileDistributor;
import vazkii.botania.common.block.tile.mana.TileManaDetector;
import vazkii.botania.common.block.tile.mana.TileManaVoid;
@@ -194,6 +196,7 @@ public final class ModBlocks {
public static Block dirtPath;
public static Block enchantedSoil;
public static Block petalBlock;
public static Block corporeaIndex;
public static void init() {
flower = new BlockModFlower();
@@ -253,6 +256,7 @@ public final class ModBlocks {
dirtPath = new BlockDirtPath();
enchantedSoil = new BlockEnchantedSoil();
petalBlock = new BlockPetalBlock();
corporeaIndex = new BlockCorporeaIndex();
ModFluffBlocks.init();
@@ -319,6 +323,7 @@ public final class ModBlocks {
registerTile(TileFloatingSpecialFlower.class, LibBlockNames.FLOATING_SPECIAL_FLOWER);
registerTile(TileManaFlame.class, LibBlockNames.MANA_FLAME);
registerTile(TilePrism.class, LibBlockNames.PRISM);
registerTile(TileCorporeaIndex.class, LibBlockNames.CORPOREA_INDEX);
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class);
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class);
@@ -0,0 +1,74 @@
/**
* 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 @ [Feb 15, 2015, 12:23:33 AM (GMT)]
*/
package vazkii.botania.common.block.corporea;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import vazkii.botania.common.block.BlockModContainer;
import vazkii.botania.common.block.tile.TileSimpleInventory;
import vazkii.botania.common.block.tile.corporea.TileCorporeaBase;
public abstract class BlockCorporea extends BlockModContainer<TileCorporeaBase> {
Random random;
public BlockCorporea(Material material, String name) {
super(material);
setBlockName(name);
random = new Random();
}
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4);
if (inv != null) {
for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) {
ItemStack itemstack = inv.getStackInSlot(j1);
if (itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
int k1 = random.nextInt(21) + 10;
if (k1 > itemstack.stackSize)
k1 = itemstack.stackSize;
itemstack.stackSize -= k1;
entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float)random.nextGaussian() * f3;
entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float)random.nextGaussian() * f3;
if (itemstack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
}
}
par1World.func_147453_f(par2, par3, par4, par5);
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
}
@@ -0,0 +1,55 @@
/**
* 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 @ [Feb 15, 2015, 12:49:58 AM (GMT)]
*/
package vazkii.botania.common.block.corporea;
import vazkii.botania.client.lib.LibRenderIDs;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.corporea.TileCorporeaBase;
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
import vazkii.botania.common.lib.LibBlockNames;
import net.minecraft.block.material.Material;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockCorporeaIndex extends BlockCorporea {
public BlockCorporeaIndex() {
super(Material.iron, LibBlockNames.CORPOREA_INDEX);
setHardness(5.5F);
setStepSound(soundTypeMetal);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public IIcon getIcon(int side, int meta) {
return ModBlocks.storage.getIcon(0, 2);
}
@Override
public int getRenderType() {
return LibRenderIDs.idCorporeaIndex;
}
@Override
public TileCorporeaBase createNewTileEntity(World world, int meta) {
return new TileCorporeaIndex();
}
}
@@ -0,0 +1,28 @@
/**
* 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 @ [Feb 15, 2015, 12:25:19 AM (GMT)]
*/
package vazkii.botania.common.block.tile.corporea;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import vazkii.botania.api.corporea.CorporeaHelper;
import vazkii.botania.api.corporea.ICorporeaSpark;
import vazkii.botania.common.block.tile.TileSimpleInventory;
public abstract class TileCorporeaBase extends TileSimpleInventory {
public ICorporeaSpark getSpark() {
return CorporeaHelper.getSparkForBlock(worldObj, xCoord, yCoord, zCoord);
}
}
@@ -0,0 +1,64 @@
/**
* 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 @ [Feb 15, 2015, 12:42:29 AM (GMT)]
*/
package vazkii.botania.common.block.tile.corporea;
import java.util.List;
import vazkii.botania.common.core.helper.MathHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
public class TileCorporeaIndex extends TileCorporeaBase {
public static final double RADIUS = 2.5;
public int ticks = 0;
public int ticksWithCloseby = 0;
public float closeby = 0F;
public boolean hasCloseby;
@Override
public void updateEntity() {
super.updateEntity();
double x = xCoord + 0.5;
double y = yCoord + 0.5;
double z = zCoord + 0.5;
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - RADIUS, y - RADIUS, z - RADIUS, x + RADIUS, y + RADIUS, z + RADIUS));
hasCloseby = false;
for(EntityPlayer player : players)
if(MathHelper.pointDistanceSpace(x, y, z, player.posX, player.posY, player.posZ) < RADIUS) {
hasCloseby = true;
break;
}
float step = 0.2F;
ticks++;
if(hasCloseby) {
ticksWithCloseby++;
if(closeby < 1F)
closeby += step;
} else if(closeby > 0F)
closeby -= step;
}
@Override
public int getSizeInventory() {
return 1;
}
@Override
public String getInventoryName() {
return null;
}
}
@@ -291,6 +291,7 @@ public final class BotaniaCreativeTab extends CreativeTabs {
addItem(ModItems.lens);
addItem(ModItems.corporeaSpark);
addBlock(ModBlocks.corporeaIndex);
}
private void addItem(Item item) {
@@ -73,13 +73,8 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
return;
}
if(isMaster()) {
if(isMaster())
master = this;
System.out.println(CorporeaHelper.getCountInNetwork(new ItemStack(Items.apple), this, false));
ItemStack request = CorporeaHelper.requestItem(new ItemStack(Items.apple), this, false, true);
if(request != null)
InventoryHelper.insertItemIntoInventory(getInventory(), request);
}
if(firstUpdate) {
if(isMaster())
@@ -21,6 +21,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.api.corporea.CorporeaHelper;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.entity.EntityCorporeaSpark;
import vazkii.botania.common.lib.LibItemNames;
@@ -43,7 +44,7 @@ public class ItemCorporeaSpark extends ItemMod {
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xv, float yv, float zv) {
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof IInventory) { // TODO Check for spark in position already
if(tile instanceof IInventory && !CorporeaHelper.doesBlockHaveSpark(world, x, y, z)) {
stack.stackSize--;
if(!world.isRemote) {
EntityCorporeaSpark spark = new EntityCorporeaSpark(world);
@@ -110,7 +110,6 @@ public class PageEntity extends LexiconPage{
try {
dummyEntity = (Entity) entityConstructor.newInstance(new Object[] {Minecraft.getMinecraft().theWorld});
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@@ -72,6 +72,7 @@ public final class LibBlockNames {
public static final String BIOME_STONE_A = "biomeStoneA";
public static final String BIOME_STONE_B = "biomeStoneB";
public static final String PETAL_BLOCK = "petalBlock";
public static final String CORPOREA_INDEX = "corporeaIndex";
public static final String SUBTILE_PUREDAISY = "puredaisy";
public static final String SUBTILE_MANASTAR = "manastar";