Functional Luminizers. Need some polish now.

This commit is contained in:
Lizbeth Rika committed 2015-07-16 18:39:17 +01:00
1 parent f6655f1fa1
commit 3cacb763d8
6 files changed
+239 -14

No files matched your search

@@ -96,6 +96,7 @@ import vazkii.botania.client.render.tile.RenderTileEnchanter;
import vazkii.botania.client.render.tile.RenderTileFloatingFlower;
import vazkii.botania.client.render.tile.RenderTileHourglass;
import vazkii.botania.client.render.tile.RenderTileIncensePlate;
import vazkii.botania.client.render.tile.RenderTileLightRelay;
import vazkii.botania.client.render.tile.RenderTilePool;
import vazkii.botania.client.render.tile.RenderTilePrism;
import vazkii.botania.client.render.tile.RenderTilePump;
@@ -119,6 +120,7 @@ import vazkii.botania.common.block.tile.TileFloatingFlower;
import vazkii.botania.common.block.tile.TileFloatingSpecialFlower;
import vazkii.botania.common.block.tile.TileHourglass;
import vazkii.botania.common.block.tile.TileIncensePlate;
import vazkii.botania.common.block.tile.TileLightRelay;
import vazkii.botania.common.block.tile.TilePylon;
import vazkii.botania.common.block.tile.TileRuneAltar;
import vazkii.botania.common.block.tile.TileSparkChanger;
@@ -289,6 +291,7 @@ public class ClientProxy extends CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileHourglass.class, new RenderTileHourglass());
ClientRegistry.bindTileEntitySpecialRenderer(TileSparkChanger.class, new RenderTileSparkChanger());
ClientRegistry.bindTileEntitySpecialRenderer(TileCocoon.class, new RenderTileCocoon());
ClientRegistry.bindTileEntitySpecialRenderer(TileLightRelay.class, new RenderTileLightRelay());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySkull.class, new RenderTileSkullOverride());
@@ -0,0 +1,87 @@
/**
* 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 @ [Jul 16, 2015, 5:03:57 PM (GMT)]
*/
package vazkii.botania.client.render.tile;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.common.block.BlockLightRelay;
public class RenderTileLightRelay extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float pticks) {
Minecraft mc = Minecraft.getMinecraft();
IIcon iicon = BlockLightRelay.worldIcon;
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.3, z + 0.5);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.05F);
double time = ClientTickHandler.ticksInGame + pticks;
GL11.glColor4f(1F, 1F, 1F, 1F);
float scale = 0.75F;
GL11.glScalef(scale, scale, scale);
Tessellator tessellator = Tessellator.instance;
GL11.glPushMatrix();
float r = 180.0F - RenderManager.instance.playerViewY;
GL11.glRotatef(r, 0F, 1F, 0F);
GL11.glRotatef(-RenderManager.instance.playerViewX, 1F, 0F, 0F);
float off = 0.25F;
GL11.glTranslatef(0F, off, 0F);
GL11.glRotated(time, 0F, 0F, 1F);
GL11.glTranslatef(0F, -off, 0F);
mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
func_77026_a(tessellator, iicon);
GL11.glPopMatrix();
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) {
float f = p_77026_2_.getMinU();
float f1 = p_77026_2_.getMaxU();
float f2 = p_77026_2_.getMinV();
float f3 = p_77026_2_.getMaxV();
float f4 = 1.0F;
float f5 = 0.5F;
float f6 = 0.25F;
p_77026_1_.startDrawingQuads();
p_77026_1_.setNormal(0.0F, 1.0F, 0.0F);
p_77026_1_.setBrightness(240);
p_77026_1_.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3);
p_77026_1_.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3);
p_77026_1_.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2);
p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2);
p_77026_1_.draw();
}
}
@@ -15,6 +15,7 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
@@ -37,6 +38,17 @@ public class BlockLightRelay extends BlockModContainer implements IWandable {
setBlockName(LibBlockNames.LIGHT_RELAY);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int s, float xs, float ys, float zs) {
((TileLightRelay) world.getTileEntity(x, y, z)).playerInteract(player);
return true;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) {
return null;
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
invIcon = IconHelper.forBlock(par1IconRegister, this, 0);
@@ -11,10 +11,14 @@
package vazkii.botania.common.block.tile;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import vazkii.botania.api.wand.IWandBindable;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
@@ -24,13 +28,22 @@ import vazkii.botania.common.core.helper.Vector3;
public class TileLightRelay extends TileMod implements IWandBindable {
private static final int MAX_DIST = 20;
private static final String TAG_BIND_X = "bindX";
private static final String TAG_BIND_Y = "bindY";
private static final String TAG_BIND_Z = "bindZ";
int bindX, bindY = -1, bindZ;
int ticksElapsed = 0;
public void playerInteract(EntityPlayer player) {
if(player.ridingEntity != null || worldObj.isRemote || bindY == -1)
return;
EntityPlayerMover mover = new EntityPlayerMover(worldObj, xCoord, yCoord, zCoord, bindX, bindY, bindZ);
worldObj.spawnEntityInWorld(mover);
player.mountEntity(mover);
}
@Override
public void updateEntity() {
@@ -40,24 +53,24 @@ public class TileLightRelay extends TileMod implements IWandBindable {
bindY = -1;
return;
}
ticksElapsed++;
Vector3 vec = getMovementVector();
double dist = 0.1;
int size = (int) (vec.mag() / dist);
int count = 10;
int start = ticksElapsed % size;
Vector3 vecMag = vec.copy().normalize().multiply(dist);
Vector3 vecTip = vecMag.copy().multiply(start).add(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
double radPer = Math.PI / 16.0;
float mul = 0.5F;
float mulPer = 0.4F;
float maxMul = 2;
for(int i = start; i < start + count; i++) { // <- Replace to i = 0; i < size
for(int i = start; i < start + count; i++) {
mul = Math.min(maxMul, mul + mulPer);
double rad = radPer * (i + ticksElapsed * 0.4);
Vector3 vecRot = vecMag.copy().crossProduct(Vector3.one).multiply(mul).rotate(rad, vecMag).add(vecTip);
@@ -66,14 +79,14 @@ public class TileLightRelay extends TileMod implements IWandBindable {
}
}
}
public Vector3 getMovementVector() {
return new Vector3(bindX - xCoord, bindY - yCoord, bindZ - zCoord);
}
@Override
public ChunkCoordinates getBinding() {
return new ChunkCoordinates(bindX, bindY, bindZ);
return bindY == -1 ? null : new ChunkCoordinates(bindX, bindY, bindZ);
}
@Override
@@ -85,25 +98,132 @@ public class TileLightRelay extends TileMod implements IWandBindable {
public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) {
if(player.worldObj.getBlock(x, y, z) != ModBlocks.lightRelay || MathHelper.pointDistanceSpace(x, y, z, xCoord, yCoord, zCoord) > MAX_DIST)
return false;
bindX = x;
bindY = y;
bindZ = z;
return true;
}
@Override
public void readCustomNBT(NBTTagCompound cmp) {
bindX = cmp.getInteger(TAG_BIND_X);
bindY = cmp.getInteger(TAG_BIND_Y);
bindZ = cmp.getInteger(TAG_BIND_Z);
}
@Override
public void writeCustomNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_BIND_X, bindX);
cmp.setInteger(TAG_BIND_Y, bindY);
cmp.setInteger(TAG_BIND_Z, bindZ);
}
public static class EntityPlayerMover extends Entity {
private static final String TAG_EXIT_X = "exitX";
private static final String TAG_EXIT_Y = "exitY";
private static final String TAG_EXIT_Z = "exitZ";
public EntityPlayerMover(World world) {
super(world);
}
public EntityPlayerMover(World world, int x, int y, int z, int exitX, int exitY, int exitZ) {
this(world);
setPosition(x + 0.5, y + 0.5, z + 0.5);
setExit(exitX, exitY, exitZ);
}
@Override
protected void entityInit() {
setSize(0F, 0F);
noClip = true;
dataWatcher.addObject(20, 0);
dataWatcher.addObject(21, 0);
dataWatcher.addObject(22, 0);
dataWatcher.setObjectWatched(20);
dataWatcher.setObjectWatched(21);
dataWatcher.setObjectWatched(22);
}
@Override
public void onUpdate() {
super.onUpdate();
if(riddenByEntity == null)
setDead();
int exitX = getExitX();
int exitY = getExitY();
int exitZ = getExitZ();
int x = net.minecraft.util.MathHelper.floor_double(posX);
int y = net.minecraft.util.MathHelper.floor_double(posY);
int z = net.minecraft.util.MathHelper.floor_double(posZ);
if(x == exitX && y == exitY && z == exitZ) {
TileEntity tile = worldObj.getTileEntity(x, y, z);
if(tile != null && tile instanceof TileLightRelay) {
ChunkCoordinates bind = ((TileLightRelay) tile).getBinding();
if(bind != null) {
setExit(bind.posX, bind.posY, bind.posZ);
return;
}
}
posY += 1.5;
setDead();
} else {
Vector3 thisVec = Vector3.fromEntity(this);
Vector3 motVec = thisVec.negate().add(exitX + 0.5, exitY + 0.5, exitZ + 0.5).normalize().multiply(0.5);
posX += motVec.x;
posY += motVec.y;
posZ += motVec.z;
}
}
@Override
public boolean shouldRiderSit() {
return false;
}
@Override
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) {
return false;
}
@Override
protected void readEntityFromNBT(NBTTagCompound cmp) {
setExit(cmp.getInteger(TAG_EXIT_X), cmp.getInteger(TAG_EXIT_Y), cmp.getInteger(TAG_EXIT_Z));
}
@Override
protected void writeEntityToNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_EXIT_X, getExitX());
cmp.setInteger(TAG_EXIT_Y, getExitY());
cmp.setInteger(TAG_EXIT_Z, getExitZ());
}
public int getExitX() {
return dataWatcher.getWatchableObjectInt(20);
}
public int getExitY() {
return dataWatcher.getWatchableObjectInt(21);
}
public int getExitZ() {
return dataWatcher.getWatchableObjectInt(22);
}
public void setExit(int x, int y, int z) {
dataWatcher.updateObject(20, x);
dataWatcher.updateObject(21, y);
dataWatcher.updateObject(22, z);
}
}
}
@@ -11,6 +11,7 @@
package vazkii.botania.common.entity;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.tile.TileLightRelay.EntityPlayerMover;
import vazkii.botania.common.lib.LibEntityNames;
import cpw.mods.fml.common.registry.EntityRegistry;
@@ -34,6 +35,7 @@ public final class ModEntities {
EntityRegistry.registerModEntity(EntityEnderAirBottle.class, LibEntityNames.ENDER_AIR_BOTTLE, id++, Botania.instance, 64, 10, true);
EntityRegistry.registerModEntity(EntityPoolMinecart.class, LibEntityNames.POOL_MINECART, id++, Botania.instance, 80, 3, true);
EntityRegistry.registerModEntity(EntityPinkWither.class, LibEntityNames.PINK_WITHER, id++, Botania.instance, 80, 3, false);
EntityRegistry.registerModEntity(EntityPlayerMover.class, LibEntityNames.PlAYER_MOVER, id++, Botania.instance, 16, 3, true);
}
}
@@ -29,5 +29,6 @@ public final class LibEntityNames {
public static final String ENDER_AIR_BOTTLE = LibResources.PREFIX_MOD + "enderAirBottle";
public static final String POOL_MINECART = LibResources.PREFIX_MOD + "poolMinecart";
public static final String PINK_WITHER = LibResources.PREFIX_MOD + "pinkWither";
public static final String PlAYER_MOVER = LibResources.PREFIX_MOD + "playerMover";
}