Key of the King's Law, part 2.

This commit is contained in:
Lizbeth Rika committed 2015-08-16 21:52:00 +01:00
1 parent c20db40564
commit 1256f398bb
9 files changed
+207 -17

No files matched your search

@@ -75,6 +75,7 @@ import vazkii.botania.client.render.block.RenderSpawnerClaw;
import vazkii.botania.client.render.block.RenderSpecialFlower;
import vazkii.botania.client.render.block.RenderSpreader;
import vazkii.botania.client.render.block.RenderTinyPotato;
import vazkii.botania.client.render.entity.RenderBabylonWeapon;
import vazkii.botania.client.render.entity.RenderCorporeaSpark;
import vazkii.botania.client.render.entity.RenderDoppleganger;
import vazkii.botania.client.render.entity.RenderManaStorm;
@@ -140,6 +141,7 @@ import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.core.proxy.CommonProxy;
import vazkii.botania.common.core.version.VersionChecker;
import vazkii.botania.common.entity.EntityBabylonWeapon;
import vazkii.botania.common.entity.EntityCorporeaSpark;
import vazkii.botania.common.entity.EntityDoppleganger;
import vazkii.botania.common.entity.EntityEnderAirBottle;
@@ -307,6 +309,7 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityPoolMinecart.class, new RenderPoolMinecart());
RenderingRegistry.registerEntityRenderingHandler(EntityPinkWither.class, new RenderPinkWither());
RenderingRegistry.registerEntityRenderingHandler(EntityManaStorm.class, new RenderManaStorm());
RenderingRegistry.registerEntityRenderingHandler(EntityBabylonWeapon.class, new RenderBabylonWeapon());
ShaderHelper.initShaders();
}
@@ -113,6 +113,7 @@ public final class LibResources {
public static final String MISC_HALO = PREFIX_MISC + "halo.png";
public static final String MISC_GLOW_PINK = PREFIX_MISC + "glow0.png";
public static final String MISC_GLOW_CYAN = PREFIX_MISC + "glow1.png";
public static final String MISC_BABYLON = PREFIX_MISC + "babylon.png";
public static final String OBJ_MODEL_PYLON = PREFIX_OBJ_MODEL + "pylon.obj";
@@ -0,0 +1,110 @@
/**
* 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 @ [Aug 16, 2015, 6:42:09 PM (GMT)]
*/
package vazkii.botania.client.render.entity;
import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.entity.EntityBabylonWeapon;
import vazkii.botania.common.item.relic.ItemKingKey;
public class RenderBabylonWeapon extends Render {
private static final ResourceLocation babylon = new ResourceLocation(LibResources.MISC_BABYLON);
@Override
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
EntityBabylonWeapon weapon = (EntityBabylonWeapon) par1Entity;
GL11.glPushMatrix();
GL11.glTranslatef((float)par2, (float)par4, (float)par6);
GL11.glRotatef(weapon.getRotation(), 0F, 1F, 0F);
int live = weapon.getLiveTicks();
int delay = weapon.getDelay();
float charge = Math.min(10F, Math.max(live, weapon.getChargeTicks()) + par9);
float chargeMul = charge / 10F;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
GL11.glPushMatrix();
float s = 1.5F;
GL11.glScalef(s, s, s);
GL11.glRotatef(-90F, 0F, 1F, 0F);
GL11.glRotatef(45F, 0F, 0F, 1F);
IIcon icon = ItemKingKey.weaponIcons[weapon.getVariety()];
GL11.glColor4f(1F, 1F, 1F, chargeMul);
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
GL11.glDisable(GL11.GL_LIGHTING);
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glColor4f(1F, 1F, 1F, chargeMul);
Minecraft.getMinecraft().renderEngine.bindTexture(babylon);
Tessellator tes = Tessellator.instance;
ShaderHelper.useShader(ShaderHelper.halo);
Random rand = new Random(weapon.getUniqueID().getMostSignificantBits());
GL11.glRotatef(-90F, 1F, 0F, 0F);
GL11.glTranslatef(0F, -0.3F + rand.nextFloat() * 0.1F, 1F);
s = chargeMul;
if(live > delay)
s -= Math.min(1F, (float) (live - delay + par9) * 0.2F);
s *= 2F;
GL11.glScalef(s, s, s);
GL11.glRotatef(charge * 9F + (weapon.ticksExisted + par9) * 0.5F + rand.nextFloat() * 360F, 0F, 1F, 0F);
tes.startDrawingQuads();
tes.addVertexWithUV(-1, 0, -1, 0, 0);
tes.addVertexWithUV(-1, 0, 1, 0, 1);
tes.addVertexWithUV(1, 0, 1, 1, 1);
tes.addVertexWithUV(1, 0, -1, 1, 0);
tes.draw();
ShaderHelper.releaseShader();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
}
@Override
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
return null;
}
}
@@ -15,6 +15,7 @@ import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
@@ -27,8 +28,13 @@ import vazkii.botania.common.item.relic.ItemKingKey;
public class EntityBabylonWeapon extends EntityThrowableCopy {
// TODO NBT
private static final String TAG_CHARGING = "charging";
private static final String TAG_VARIETY = "variety";
private static final String TAG_CHARGE_TICKS = "chargeTicks";
private static final String TAG_LIVE_TICKS = "liveTicks";
private static final String TAG_DELAY = "delay";
private static final String TAG_ROTATION = "rotation";
public EntityBabylonWeapon(World world) {
super(world);
}
@@ -46,12 +52,14 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
dataWatcher.addObject(22, 0);
dataWatcher.addObject(23, 0);
dataWatcher.addObject(24, 0);
dataWatcher.addObject(25, 0F);
dataWatcher.setObjectWatched(20);
dataWatcher.setObjectWatched(21);
dataWatcher.setObjectWatched(22);
dataWatcher.setObjectWatched(23);
dataWatcher.setObjectWatched(24);
dataWatcher.setObjectWatched(25);
}
@Override
@@ -79,7 +87,7 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
int liveTime = getLiveTicks();
int delay = getDelay();
charging &= liveTime == 0;
if(charging) {
motionX = 0;
motionY = 0;
@@ -87,12 +95,15 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
int chargeTime = getChargeTicks();
setChargeTicks(chargeTime + 1);
if(worldObj.rand.nextInt(20) == 0)
worldObj.playSoundAtEntity(this, "botania:babylonSpawn", 0.1F, 1F + worldObj.rand.nextFloat() * 3F);
} else {
if(liveTime < delay) {
motionX = 0;
motionY = 0;
motionZ = 0;
} else if(liveTime == delay && !worldObj.isRemote && player != null) {
} else if (liveTime == delay && player != null) {
Vector3 playerLook = null;
MovingObjectPosition lookat = ToolCommons.raytraceFromEntity(worldObj, player, true, 64);
if(lookat == null)
@@ -105,8 +116,8 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
x = motionVec.x;
y = motionVec.y;
z = motionVec.z;
worldObj.playSoundAtEntity(this, "botania:babylonAttack", 2F, 0.1F + worldObj.rand.nextFloat() * 3F);
}
setLiveTicks(liveTime + 1);
if(!worldObj.isRemote) {
@@ -118,8 +129,8 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
if(living.hurtTime == 0) {
if(player != null)
living.attackEntityFrom(DamageSource.causePlayerDamage(player), 14);
else living.attackEntityFrom(DamageSource.generic, 14);
living.attackEntityFrom(DamageSource.causePlayerDamage(player), 8);
else living.attackEntityFrom(DamageSource.generic, 8);
onImpact(new MovingObjectPosition(living));
return;
}
@@ -128,12 +139,13 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
}
super.onUpdate();
motionX = x;
motionY = y;
motionZ = z;
Botania.proxy.wispFX(worldObj, posX, posY, posZ, 1F, 1F, 0F, 0.3F, 0F);
if(liveTime > delay)
Botania.proxy.wispFX(worldObj, posX, posY, posZ, 1F, 1F, 0F, 0.3F, 0F);
if(liveTime > (200 + delay))
setDead();
@@ -147,6 +159,28 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
setDead();
}
}
@Override
public void writeEntityToNBT(NBTTagCompound cmp) {
super.writeEntityToNBT(cmp);
cmp.setBoolean(TAG_CHARGING, isCharging());
cmp.setInteger(TAG_VARIETY, getVariety());
cmp.setInteger(TAG_CHARGE_TICKS, getChargeTicks());
cmp.setInteger(TAG_LIVE_TICKS, getLiveTicks());
cmp.setInteger(TAG_DELAY, getDelay());
cmp.setFloat(TAG_ROTATION, getRotation());
}
@Override
public void readEntityFromNBT(NBTTagCompound cmp) {
super.readEntityFromNBT(cmp);
setCharging(cmp.getBoolean(TAG_CHARGING));
setVariety(cmp.getInteger(TAG_VARIETY));
setChargeTicks(cmp.getInteger(TAG_CHARGE_TICKS));
setLiveTicks(cmp.getInteger(TAG_LIVE_TICKS));
setDelay(cmp.getInteger(TAG_DELAY));
setRotation(cmp.getFloat(TAG_ROTATION));
}
public boolean isCharging() {
return dataWatcher.getWatchableObjectByte(20) == 1;
@@ -187,5 +221,13 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
public void setDelay(int delay) {
dataWatcher.updateObject(24, delay);
}
public float getRotation() {
return dataWatcher.getWatchableObjectFloat(25);
}
public void setRotation(float rot) {
dataWatcher.updateObject(25, rot);
}
}
@@ -12,11 +12,15 @@ package vazkii.botania.common.item.relic;
import java.util.Random;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import vazkii.botania.common.Botania;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.entity.EntityBabylonWeapon;
@@ -26,10 +30,22 @@ public class ItemKingKey extends ItemRelic {
private static final String TAG_WEAPONS_SPAWNED = "weaponsSpawned";
private static final String TAG_CHARGING = "charging";
private static final int WEAPON_TYPES = 12;
public static IIcon[] weaponIcons;
public ItemKingKey() {
super(LibItemNames.KING_KEY);
}
@Override
public void registerIcons(IIconRegister par1IconRegister) {
super.registerIcons(par1IconRegister);
weaponIcons = new IIcon[WEAPON_TYPES];
for(int i = 0; i < WEAPON_TYPES; i++)
weaponIcons[i] = IconHelper.forName(par1IconRegister, "gateWeapon" + i);
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
@@ -40,33 +56,49 @@ public class ItemKingKey extends ItemRelic {
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time) {
setCharging(stack, false);
setWeaponsSpawned(stack, 0); // TODO probably move this to a ticker
int spawned = getWeaponsSpawned(stack);
if(spawned == 20) {
setCharging(stack, false);
setWeaponsSpawned(stack, 0);
}
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
int spawned = getWeaponsSpawned(stack);
if(count != getMaxItemUseDuration(stack) && spawned < 20 && !player.worldObj.isRemote) {
if(ManaItemHandler.requestManaExact(stack, player, 150, true) && count != getMaxItemUseDuration(stack) && spawned < 20 && !player.worldObj.isRemote) {
Vector3 look = new Vector3(player.getLookVec());
look.y = 0;
look.normalize().negate().multiply(2);
Vector3 pl = look.copy().add(Vector3.fromEntityCenter(player));
int div = spawned / 5;
int mod = spawned % 5;
Vector3 pl = look.copy().add(Vector3.fromEntityCenter(player)).add(0, 1.6, (double) div * 0.1);
Random rand = player.worldObj.rand;
Vector3 axis = pl.copy().crossProduct(new Vector3(-1, 0, -1)).normalize();
Vector3 axis = look.copy().normalize().crossProduct(new Vector3(-1, 0, -1)).normalize();
Vector3 axis1 = axis.copy();
axis1.multiply(rand.nextDouble() * 22 + 3).rotate((rand.nextDouble() - 0.5) * Math.PI / 2.0, look);
double rot = mod * Math.PI / 4 - Math.PI / 2;
axis1.multiply(div * 3.5 + 5).rotate(rot, look);
if(axis1.y < 0)
axis1.y = -axis1.y;
Vector3 end = pl.copy().add(axis1);
EntityBabylonWeapon weapon = new EntityBabylonWeapon(player.worldObj, player);
weapon.posX = end.x;
weapon.posY = end.y;
weapon.posZ = end.z;
weapon.setVariety(rand.nextInt(12));
weapon.rotationYaw = player.rotationYaw;
weapon.setVariety(rand.nextInt(WEAPON_TYPES));
weapon.setDelay(spawned);
weapon.setRotation(MathHelper.wrapAngleTo180_float(-player.rotationYaw + 180));
player.worldObj.spawnEntityInWorld(weapon);
player.worldObj.playSoundAtEntity(weapon, "botania:babylonSpawn", 1F, 1F + player.worldObj.rand.nextFloat() * 3F);
setWeaponsSpawned(stack, spawned + 1);
}
}
@@ -2,6 +2,8 @@
"airRod": { "category": "player", "sounds":["airRod"] },
"agricarnation": { "category": "block", "sounds":["agricarnation"] },
"altarCraft": { "category": "block", "sounds":["altarCraft"] },
"babylonAttack": { "category": "player", "sounds":["babylonAttack"] },
"babylonSpawn": { "category": "player", "sounds":["babylonSpawn"] },
"bifrostRod": { "category": "player", "sounds":["bifrostRod"] },
"blackLotus": { "category": "block", "sounds":["blackLotus"] },
"ding": { "category": "block", "sounds":["ding"] },
Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 81 KiB