mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-12 16:27:37 +00:00
Finishing off the Corporea Crystal Cube
This commit is contained in:
1 parent
0b58cf8c2a
commit
dd1322b932
9 files changed
+247
-21
No files matched your search
@@ -159,6 +159,7 @@ public final class CorporeaHelper {
|
||||
* Requests list of ItemStacks of the type passed in from the network, or tries to, checking NBT or not.
|
||||
* This will remove the items from the adequate inventories unless the "doit" parameter is false.
|
||||
* Returns a new list of ItemStacks of the items acquired or an empty list if none was found.
|
||||
* Case itemCount is -1 it'll find EVERY item it can.
|
||||
* <br><br>
|
||||
* The "matcher" parameter has to be an ItemStack or a String, if the first it'll check if the
|
||||
* two stacks are similar using the "checkNBT" parameter, else it'll check if the name of the item
|
||||
@@ -192,7 +193,7 @@ public final class CorporeaHelper {
|
||||
|
||||
ItemStack stackAt = inv.getStackInSlot(i);
|
||||
if(matcher instanceof ItemStack ? stacksMatch((ItemStack) matcher, stackAt, checkNBT) : matcher instanceof String ? stacksMatch(stackAt, (String) matcher) : false) {
|
||||
int rem = Math.min(stackAt.stackSize, count);
|
||||
int rem = Math.min(stackAt.stackSize, count == -1 ? stackAt.stackSize : count);
|
||||
|
||||
if(rem > 0) {
|
||||
ItemStack copy = stackAt.copy();
|
||||
@@ -208,7 +209,8 @@ public final class CorporeaHelper {
|
||||
if(invSpark != null)
|
||||
invSpark.onItemExtracted(stackAt);
|
||||
}
|
||||
count -= rem;
|
||||
if(count != -1)
|
||||
count -= rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import vazkii.botania.api.wiki.WikiHooks;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaCrystalCube;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import vazkii.botania.common.item.ItemCraftingHalo;
|
||||
@@ -95,6 +96,8 @@ public final class HUDHandler {
|
||||
else if(tile != null && tile instanceof TilePool)
|
||||
renderPoolRecipeHUD(event.resolution, (TilePool) tile, equippedStack);
|
||||
}
|
||||
if(tile != null && tile instanceof TileCorporeaCrystalCube)
|
||||
renderCrystalCubeHUD(event.resolution, (TileCorporeaCrystalCube) tile);
|
||||
}
|
||||
|
||||
if(!TileCorporeaIndex.input.getNearbyIndexes(mc.thePlayer).isEmpty() && mc.currentScreen != null && mc.currentScreen instanceof GuiChat) {
|
||||
@@ -255,6 +258,32 @@ public final class HUDHandler {
|
||||
}
|
||||
profiler.endSection();
|
||||
}
|
||||
|
||||
private void renderCrystalCubeHUD(ScaledResolution res, TileCorporeaCrystalCube tile) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Profiler profiler = mc.mcProfiler;
|
||||
|
||||
profiler.startSection("crystalCube");
|
||||
ItemStack target = tile.getRequestTarget();
|
||||
if(target != null) {
|
||||
String s1 = target.getDisplayName();
|
||||
String s2 = tile.getItemCount() + "x";
|
||||
int strlen = Math.max(mc.fontRenderer.getStringWidth(s1), mc.fontRenderer.getStringWidth(s2));
|
||||
int w = res.getScaledWidth();
|
||||
int h = res.getScaledHeight();
|
||||
Gui.drawRect(w / 2 + 8, h / 2 - 12, w / 2 + strlen + 32, h / 2 + 10, 0x44000000);
|
||||
Gui.drawRect(w / 2 + 6, h / 2 - 14, w / 2 + strlen + 34, h / 2 + 12, 0x44000000);
|
||||
|
||||
mc.fontRenderer.drawStringWithShadow(target.getDisplayName(), w / 2 + 30, h / 2 - 10, 0x6666FF);
|
||||
mc.fontRenderer.drawStringWithShadow(tile.getItemCount() + "x", w / 2 + 30, h / 2, 0xFFFFFF);
|
||||
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, target, w / 2 + 10, h / 2 - 10);
|
||||
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
|
||||
profiler.endSection();
|
||||
}
|
||||
|
||||
private void drawLexiconHUD(ItemStack stack, Block block, MovingObjectPosition pos, ScaledResolution res) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@@ -54,6 +54,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.RenderCorporeaCrystalCube;
|
||||
import vazkii.botania.client.render.block.RenderCorporeaIndex;
|
||||
import vazkii.botania.client.render.block.RenderDoubleFlower;
|
||||
import vazkii.botania.client.render.block.RenderFloatingFlower;
|
||||
@@ -195,6 +196,7 @@ public class ClientProxy extends CommonProxy {
|
||||
RenderingRegistry.registerBlockHandler(new RenderCorporeaIndex());
|
||||
RenderingRegistry.registerBlockHandler(new RenderPump());
|
||||
RenderingRegistry.registerBlockHandler(new RenderDoubleFlower());
|
||||
RenderingRegistry.registerBlockHandler(new RenderCorporeaCrystalCube());
|
||||
|
||||
RenderTransparentItem renderTransparentItem = new RenderTransparentItem();
|
||||
RenderFloatingFlowerItem renderFloatingFlower = new RenderFloatingFlowerItem();
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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 30, 2015, 6:22:32 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.render.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.client.lib.LibRenderIDs;
|
||||
import vazkii.botania.client.render.tile.RenderTileCorporeaIndex;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaCrystalCube;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
|
||||
public class RenderCorporeaCrystalCube implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileCorporeaCrystalCube(), 0.0D, 0.0D, 0.0D, 0.0F);
|
||||
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.idCorporeaCrystalCybe;
|
||||
}
|
||||
|
||||
}
|
||||
+31
-13
@@ -10,34 +10,41 @@
|
||||
*/
|
||||
package vazkii.botania.client.render.tile;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import vazkii.botania.api.mana.IPoolOverlayProvider;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.client.model.ModelCrystalCube;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaCrystalCube;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class RenderTileCorporeaCrystalCube extends TileEntitySpecialRenderer {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_CRYSTAL_CUBE);
|
||||
ModelCrystalCube model = new ModelCrystalCube();
|
||||
|
||||
EntityItem entity = null;
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
|
||||
TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) tileentity;
|
||||
|
||||
if(entity == null)
|
||||
entity = new EntityItem(cube.getWorldObj(), cube.xCoord, cube.yCoord, cube.zCoord, new ItemStack(Blocks.stone));
|
||||
|
||||
entity.age = ClientTickHandler.ticksInGame;
|
||||
ItemStack stack = cube.getRequestTarget();
|
||||
entity.setEntityItemStack(stack);
|
||||
|
||||
double time = ClientTickHandler.ticksInGame + f;
|
||||
double worldTicks = tileentity.getWorldObj() == null ? 0 : time;
|
||||
@@ -53,6 +60,17 @@ public class RenderTileCorporeaCrystalCube extends TileEntitySpecialRenderer {
|
||||
GL11.glScalef(1F, -1F, -1F);
|
||||
model.renderBase();
|
||||
GL11.glTranslatef(0F, (float) Math.sin(worldTicks / 20.0) * 0.05F, 0F);
|
||||
if(stack != null) {
|
||||
GL11.glPushMatrix();
|
||||
float s = stack.getItem() instanceof ItemBlock ? 0.7F : 0.5F;
|
||||
GL11.glTranslatef(0F, 0.8F, 0F);
|
||||
GL11.glScalef(s, s, s);
|
||||
GL11.glRotatef(180F, 0F, 0F, 1F);
|
||||
((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender(entity, 0, 0, 0, 1F, f);
|
||||
GL11.glPopMatrix();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
}
|
||||
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.7F);
|
||||
model.renderCube();
|
||||
GL11.glColor3f(1F, 1F, 1F);
|
||||
|
||||
@@ -131,6 +131,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.TileCorporeaCrystalCube;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaFunnel;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaInterceptor;
|
||||
@@ -379,6 +380,7 @@ public final class ModBlocks {
|
||||
registerTile(TilePump.class, LibBlockNames.PUMP);
|
||||
registerTile(TileFakeAir.class, LibBlockNames.FAKE_AIR);
|
||||
registerTile(TileCorporeaInterceptor.class, LibBlockNames.CORPOREA_INTERCEPTOR);
|
||||
registerTile(TileCorporeaCrystalCube.class, LibBlockNames.CORPOREA_CRYSTAL_CUBE);
|
||||
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class);
|
||||
|
||||
@@ -10,15 +10,17 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.corporea;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
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.TileCorporeaCrystalCube;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCorporeaCrystalCube extends BlockCorporeaBase {
|
||||
|
||||
@@ -27,6 +29,25 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase {
|
||||
setHardness(5.5F);
|
||||
setStepSound(soundTypeMetal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
|
||||
if(!world.isRemote) {
|
||||
TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(x, y, z);
|
||||
cube.doRequest(player.isSneaking());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) {
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if(stack != null) {
|
||||
TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(x, y, z);
|
||||
cube.setRequestTarget(stack);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
|
||||
+102
-1
@@ -10,14 +10,115 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile.corporea;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import vazkii.botania.api.corporea.CorporeaHelper;
|
||||
import vazkii.botania.api.corporea.ICorporeaSpark;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.wand.IWandHUD;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.helper.InventoryHelper;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileCorporeaCrystalCube extends TileCorporeaBase {
|
||||
|
||||
private static final String TAG_REQUEST_TARGET = "requestTarget";
|
||||
private static final String TAG_ITEM_COUNT = "itemCount";
|
||||
|
||||
ItemStack requestTarget;
|
||||
int itemCount = 0;
|
||||
int ticks = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
++ticks;
|
||||
if(ticks % 20 == 0)
|
||||
updateCount();
|
||||
}
|
||||
|
||||
public void setRequestTarget(ItemStack stack) {
|
||||
if(stack != null) {
|
||||
ItemStack copy = stack.copy();
|
||||
copy.stackSize = 1;
|
||||
requestTarget = copy;
|
||||
updateCount();
|
||||
if(!worldObj.isRemote)
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ItemStack getRequestTarget() {
|
||||
return requestTarget;
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return itemCount;
|
||||
}
|
||||
|
||||
public void doRequest(boolean fullStack) {
|
||||
if(worldObj.isRemote)
|
||||
return;
|
||||
|
||||
ICorporeaSpark spark = getSpark();
|
||||
if(spark != null && spark.getMaster() != null && requestTarget != null) {
|
||||
List<ItemStack> stacks = CorporeaHelper.requestItem(requestTarget, fullStack ? requestTarget.getMaxStackSize() : 1, spark, true, true);
|
||||
spark.onItemsRequested(stacks);
|
||||
boolean did = false;
|
||||
for(ItemStack reqStack : stacks)
|
||||
if(requestTarget != null) {
|
||||
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, reqStack);
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
itemCount -= reqStack.stackSize;
|
||||
did = true;
|
||||
}
|
||||
if(did)
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
|
||||
}
|
||||
}
|
||||
private void updateCount() {
|
||||
if(worldObj.isRemote)
|
||||
return;
|
||||
|
||||
itemCount = 0;
|
||||
ICorporeaSpark spark = getSpark();
|
||||
if(spark != null && spark.getMaster() != null && requestTarget != null) {
|
||||
List<ItemStack> stacks = CorporeaHelper.requestItem(requestTarget, -1, spark, true, false);
|
||||
for(ItemStack stack : stacks)
|
||||
itemCount += stack.stackSize;
|
||||
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.writeCustomNBT(par1nbtTagCompound);
|
||||
NBTTagCompound cmp = new NBTTagCompound();
|
||||
if(requestTarget != null)
|
||||
requestTarget.writeToNBT(cmp);
|
||||
par1nbtTagCompound.setTag(TAG_REQUEST_TARGET, cmp);
|
||||
par1nbtTagCompound.setInteger(TAG_ITEM_COUNT, itemCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound par1nbtTagCompound) {
|
||||
super.readCustomNBT(par1nbtTagCompound);
|
||||
NBTTagCompound cmp = par1nbtTagCompound.getCompoundTag(TAG_REQUEST_TARGET);
|
||||
requestTarget = ItemStack.loadItemStackFromNBT(cmp);
|
||||
itemCount = par1nbtTagCompound.getInteger(TAG_ITEM_COUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
@@ -27,7 +128,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase {
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return LibBlockNames.CORPOREA_CRYSTAL_CUBE;
|
||||
|
||||
@@ -912,7 +912,7 @@ tile.botania:stone10Slab.name=Diorite Brick Slab
|
||||
tile.botania:stone11Slab.name=Granite Brick Slab
|
||||
tile.botania:blazeBlock.name=Blaze Lamp
|
||||
tile.botania:corporeaInterceptor.name=Corporea Interceptor
|
||||
tile.botania:corporeaCrystalCybe.name=Corporea Crystal Cube
|
||||
tile.botania:corporeaCrystalCube.name=Corporea Crystal Cube
|
||||
|
||||
# FLOWER NAMES
|
||||
tile.botania:flower..name=Botania Flower
|
||||
|
||||
Reference in new issue
Block a user