Added stuffs
This commit is contained in:
parent
76f4b5b0d9
commit
bf14e3ebb1
8 changed files with 276 additions and 27 deletions
|
@ -0,0 +1,101 @@
|
|||
package WayofTime.alchemicalWizardry.client.renderer;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class RenderFakeBlocks
|
||||
{
|
||||
public static void drawFakeBlock(WayofTime.alchemicalWizardry.api.Vector3 vector3, Block block, int meta, double minX, double minY, double minZ, World world)
|
||||
{
|
||||
double maxX = minX + 1;
|
||||
double maxY = minY + 1;
|
||||
double maxZ = minZ + 1;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
float texMinU, texMaxU, texMinV, texMaxV;
|
||||
|
||||
texMinU = getMinU(block, meta, 0);
|
||||
texMaxU = getMaxU(block, meta, 0);
|
||||
texMinV = getMinV(block, meta, 0);
|
||||
texMaxV = getMaxV(block, meta, 0);
|
||||
tessellator.addVertexWithUV(minX, minY, minZ, texMinU, texMinV);
|
||||
tessellator.addVertexWithUV(maxX, minY, minZ, texMaxU, texMinV);
|
||||
tessellator.addVertexWithUV(maxX, minY, maxZ, texMaxU, texMaxV);
|
||||
tessellator.addVertexWithUV(minX, minY, maxZ, texMinU, texMaxV);
|
||||
|
||||
texMinU = getMinU(block, meta, 1);
|
||||
texMaxU = getMaxU(block, meta, 1);
|
||||
texMinV = getMinV(block, meta, 1);
|
||||
texMaxV = getMaxV(block, meta, 1);
|
||||
tessellator.addVertexWithUV(minX, maxY, maxZ, texMinU, texMaxV);
|
||||
tessellator.addVertexWithUV(maxX, maxY, maxZ, texMaxU, texMaxV);
|
||||
tessellator.addVertexWithUV(maxX, maxY, minZ, texMaxU, texMinV);
|
||||
tessellator.addVertexWithUV(minX, maxY, minZ, texMinU, texMinV);
|
||||
|
||||
texMinU = getMinU(block, meta, 2);
|
||||
texMaxU = getMaxU(block, meta, 2);
|
||||
texMinV = getMinV(block, meta, 2);
|
||||
texMaxV = getMaxV(block, meta, 2);
|
||||
tessellator.addVertexWithUV(maxX, minY, minZ, texMinU, texMaxV);
|
||||
tessellator.addVertexWithUV(minX, minY, minZ, texMaxU, texMaxV);
|
||||
tessellator.addVertexWithUV(minX, maxY, minZ, texMaxU, texMinV);
|
||||
tessellator.addVertexWithUV(maxX, maxY, minZ, texMinU, texMinV);
|
||||
|
||||
texMinU = getMinU(block, meta, 3);
|
||||
texMaxU = getMaxU(block, meta, 3);
|
||||
texMinV = getMinV(block, meta, 3);
|
||||
texMaxV = getMaxV(block, meta, 3);
|
||||
tessellator.addVertexWithUV(minX, minY, maxZ, texMinU, texMaxV);
|
||||
tessellator.addVertexWithUV(maxX, minY, maxZ, texMaxU, texMaxV);
|
||||
tessellator.addVertexWithUV(maxX, maxY, maxZ, texMaxU, texMinV);
|
||||
tessellator.addVertexWithUV(minX, maxY, maxZ, texMinU, texMinV);
|
||||
|
||||
texMinU = getMinU(block, meta, 4);
|
||||
texMaxU = getMaxU(block, meta, 4);
|
||||
texMinV = getMinV(block, meta, 4);
|
||||
texMaxV = getMaxV(block, meta, 4);
|
||||
tessellator.addVertexWithUV(minX, minY, minZ, texMinU, texMaxV);
|
||||
tessellator.addVertexWithUV(minX, minY, maxZ, texMaxU, texMaxV);
|
||||
tessellator.addVertexWithUV(minX, maxY, maxZ, texMaxU, texMinV);
|
||||
tessellator.addVertexWithUV(minX, maxY, minZ, texMinU, texMinV);
|
||||
|
||||
texMinU = getMinU(block, meta, 5);
|
||||
texMaxU = getMaxU(block, meta, 5);
|
||||
texMinV = getMinV(block, meta, 5);
|
||||
texMaxV = getMaxV(block, meta, 5);
|
||||
tessellator.addVertexWithUV(maxX, minY, maxZ, texMinU, texMaxV);
|
||||
tessellator.addVertexWithUV(maxX, minY, minZ, texMaxU, texMaxV);
|
||||
tessellator.addVertexWithUV(maxX, maxY, minZ, texMaxU, texMinV);
|
||||
tessellator.addVertexWithUV(maxX, maxY, maxZ, texMinU, texMinV);
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
private static float getMinU(Block block, int meta, int side)
|
||||
{
|
||||
IIcon icon = block.getIcon(side, meta);
|
||||
return icon.getMinU();
|
||||
}
|
||||
|
||||
private static float getMaxU(Block block, int meta, int side)
|
||||
{
|
||||
IIcon icon = block.getIcon(side, meta);
|
||||
return icon.getMaxU();
|
||||
}
|
||||
|
||||
private static float getMinV(Block block, int meta, int side)
|
||||
{
|
||||
IIcon icon = block.getIcon(side, meta);
|
||||
return icon.getMinV();
|
||||
}
|
||||
|
||||
private static float getMaxV(Block block, int meta, int side)
|
||||
{
|
||||
IIcon icon = block.getIcon(side, meta);
|
||||
return icon.getMaxV();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package WayofTime.alchemicalWizardry.client.renderer;
|
||||
|
||||
import WayofTime.alchemicalWizardry.ModBlocks;
|
||||
import WayofTime.alchemicalWizardry.api.Vector3;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.Rituals;
|
||||
import WayofTime.alchemicalWizardry.common.items.ItemRitualDiviner;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
|
||||
public class RitualDivinerRender
|
||||
{
|
||||
@SubscribeEvent
|
||||
public void render(RenderWorldLastEvent event)
|
||||
{
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
EntityClientPlayerMP player = minecraft.thePlayer;
|
||||
World world = player.worldObj;
|
||||
|
||||
if (minecraft.objectMouseOver == null || minecraft.objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = world.getTileEntity(minecraft.objectMouseOver.blockX, minecraft.objectMouseOver.blockY, minecraft.objectMouseOver.blockZ);
|
||||
|
||||
if (!(tileEntity instanceof IMasterRitualStone))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 vec3 = new Vector3(minecraft.objectMouseOver.blockX, minecraft.objectMouseOver.blockY, minecraft.objectMouseOver.blockZ);
|
||||
double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.partialTicks;
|
||||
double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.partialTicks;
|
||||
double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.partialTicks;
|
||||
|
||||
if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ItemRitualDiviner)
|
||||
{
|
||||
ItemRitualDiviner ritualDiviner = (ItemRitualDiviner) player.inventory.getCurrentItem().getItem();
|
||||
int direction = ritualDiviner.getDirection(player.inventory.getCurrentItem());
|
||||
RitualEffect ritualEffect = getEffectFromString(ritualDiviner.getCurrentRitual(player.inventory.getCurrentItem()));
|
||||
|
||||
if (ritualEffect == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (RitualComponent ritualComponent : ritualEffect.getRitualComponentList())
|
||||
{
|
||||
Vector3 vX = vec3.add(new Vector3(ritualComponent.getX(direction), ritualComponent.getY(), ritualComponent.getZ(direction)));
|
||||
double minX = vX.x - posX;
|
||||
double minY = vX.y - posY;
|
||||
double minZ = vX.z - posZ;
|
||||
|
||||
if (!world.getBlock(vX.x, vX.y, vX.z).isOpaqueCube())
|
||||
{
|
||||
RenderFakeBlocks.drawFakeBlock(vX, ModBlocks.ritualStone, ritualComponent.getStoneType(), minX, minY, minZ, world);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static RitualEffect getEffectFromString(String name)
|
||||
{
|
||||
Rituals ritual = Rituals.ritualMap.get(name);
|
||||
|
||||
if (ritual == null)
|
||||
return null;
|
||||
|
||||
return ritual.effect;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue