2015-04-19 12:23:24 -04:00
|
|
|
package WayofTime.alchemicalWizardry.client.renderer;
|
|
|
|
|
2015-07-29 08:23:01 -04:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
|
2015-04-19 22:24:30 -04:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2015-04-19 12:23:24 -04:00
|
|
|
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;
|
2015-07-29 08:23:01 -04:00
|
|
|
|
2015-04-19 12:23:24 -04:00
|
|
|
|
2015-04-19 12:25:54 -04:00
|
|
|
/*
|
|
|
|
* Created in Scala by Alex-Hawks
|
|
|
|
* Translated and implemented by Arcaratus
|
|
|
|
*/
|
2015-06-12 14:53:28 -04:00
|
|
|
@SideOnly(Side.CLIENT)
|
2015-04-19 12:23:24 -04:00
|
|
|
public class RitualDivinerRender
|
|
|
|
{
|
|
|
|
@SubscribeEvent
|
|
|
|
public void render(RenderWorldLastEvent event)
|
|
|
|
{
|
|
|
|
Minecraft minecraft = Minecraft.getMinecraft();
|
2015-07-29 08:23:01 -04:00
|
|
|
EntityPlayer player = minecraft.thePlayer;
|
2015-04-19 12:23:24 -04:00
|
|
|
World world = player.worldObj;
|
|
|
|
|
|
|
|
if (minecraft.objectMouseOver == null || minecraft.objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-07-29 08:23:01 -04:00
|
|
|
|
|
|
|
BlockPos pos = minecraft.objectMouseOver.func_178782_a();
|
2015-04-19 12:23:24 -04:00
|
|
|
|
2015-07-29 08:23:01 -04:00
|
|
|
TileEntity tileEntity = world.getTileEntity(pos);
|
2015-04-19 12:23:24 -04:00
|
|
|
|
|
|
|
if (!(tileEntity instanceof IMasterRitualStone))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-29 08:23:01 -04:00
|
|
|
Vector3 vec3 = new Vector3(pos.getX(), pos.getY(), pos.getZ());
|
2015-04-19 12:23:24 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-04-19 22:24:30 -04:00
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glEnable(GL11.GL_BLEND);
|
|
|
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
2015-04-19 12:23:24 -04:00
|
|
|
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;
|
|
|
|
|
2015-07-29 08:23:01 -04:00
|
|
|
if (!world.getBlockState(new BlockPos(vX.x, vX.y, vX.z)).getBlock().isOpaqueCube())
|
2015-04-19 12:23:24 -04:00
|
|
|
{
|
|
|
|
RenderFakeBlocks.drawFakeBlock(vX, ModBlocks.ritualStone, ritualComponent.getStoneType(), minX, minY, minZ, world);
|
|
|
|
}
|
|
|
|
}
|
2015-04-19 22:24:30 -04:00
|
|
|
GL11.glPopMatrix();
|
2015-04-19 12:23:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static RitualEffect getEffectFromString(String name)
|
|
|
|
{
|
|
|
|
Rituals ritual = Rituals.ritualMap.get(name);
|
|
|
|
|
|
|
|
if (ritual == null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
return ritual.effect;
|
|
|
|
}
|
|
|
|
}
|