mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
Avatars, part 2
This commit is contained in:
1 parent
94bd4b94cb
commit
952b71d9a0
5 files changed
+147
-1
No files matched your search
@@ -59,6 +59,7 @@ import vazkii.botania.client.gui.lexicon.GuiLexiconIndex;
|
||||
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.RenderAvatar;
|
||||
import vazkii.botania.client.render.block.RenderBellows;
|
||||
import vazkii.botania.client.render.block.RenderBrewery;
|
||||
import vazkii.botania.client.render.block.RenderCocoon;
|
||||
@@ -272,6 +273,7 @@ public class ClientProxy extends CommonProxy {
|
||||
RenderingRegistry.registerBlockHandler(new RenderCocoon());
|
||||
RenderingRegistry.registerBlockHandler(new RenderBellows());
|
||||
RenderingRegistry.registerBlockHandler(new RenderTeruTeruBozu());
|
||||
RenderingRegistry.registerBlockHandler(new RenderAvatar());
|
||||
|
||||
IMultiblockRenderHook.renderHooks.put(ModBlocks.flower, specialFlowerRender);
|
||||
IMultiblockRenderHook.renderHooks.put(ModBlocks.shinyFlower, specialFlowerRender);
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 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 @ [Oct 24, 2015, 11:06:11 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.common.block.tile.TileAvatar;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
|
||||
public class RenderAvatar implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(-0.5F, -0.6F, -0.5F);
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileAvatar(), 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 int getRenderId() {
|
||||
return LibRenderIDs.idAvatar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,7 +47,6 @@ public class RenderTileAvatar extends TileEntitySpecialRenderer {
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) {
|
||||
TileAvatar avatar = (TileAvatar) tileentity;
|
||||
Block block = avatar.getBlockType();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
@@ -10,11 +10,17 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.rod;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
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.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.item.IAvatarTile;
|
||||
import vazkii.botania.api.item.IAvatarWieldable;
|
||||
@@ -34,6 +40,7 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
private static final ResourceLocation avatarOverlay = new ResourceLocation(LibResources.MODEL_AVATAR_RAINBOW);
|
||||
|
||||
private static final int MANA_COST = 750;
|
||||
private static final int MANA_COST_AVATAR = 10;
|
||||
private static final int TIME = 600;
|
||||
|
||||
public ItemRainbowRod() {
|
||||
@@ -130,6 +137,67 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
|
||||
@Override
|
||||
public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) {
|
||||
TileEntity te = (TileEntity) tile;
|
||||
World world = te.getWorldObj();
|
||||
|
||||
if(world.isRemote || tile.getCurrentMana() < MANA_COST_AVATAR * 25)
|
||||
return;
|
||||
|
||||
int x = te.xCoord;
|
||||
int y = te.yCoord;
|
||||
int z = te.zCoord;
|
||||
int w = 1;
|
||||
int h = 1;
|
||||
int l = 20;
|
||||
|
||||
AxisAlignedBB axis = null;
|
||||
switch(te.getBlockMetadata() - 2) {
|
||||
case 0 :
|
||||
axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z - l, x + w + 1, y + h, z);
|
||||
break;
|
||||
case 1 :
|
||||
axis = AxisAlignedBB.getBoundingBox(x - w, y - h, z + 1, x + w + 1, y + h, z + l + 1);
|
||||
break;
|
||||
case 2 :
|
||||
axis = AxisAlignedBB.getBoundingBox(x - l, y - h, z - w, x, y + h, z + w + 1);
|
||||
break;
|
||||
case 3 :
|
||||
axis = AxisAlignedBB.getBoundingBox(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1);
|
||||
}
|
||||
|
||||
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, axis);
|
||||
for(EntityPlayer p : players) {
|
||||
int px = (int) MathHelper.floor_double(p.posX);
|
||||
int py = (int) MathHelper.floor_double(p.posY) - 1;
|
||||
int pz = (int) MathHelper.floor_double(p.posZ);
|
||||
int dist = 5;
|
||||
int diff = dist / 2;
|
||||
|
||||
for(int i = 0; i < dist; i++)
|
||||
for(int j = 0; j < dist; j++) {
|
||||
int ex = px + i - diff;
|
||||
int ez = pz + j - diff;
|
||||
|
||||
if(!axis.isVecInside(Vec3.createVectorHelper(ex + 0.5, py + 1, ez + 0.5)))
|
||||
continue;
|
||||
|
||||
Block block = world.getBlock(ex, py, ez);
|
||||
if(block.isAir(world, ex, py, ez)) {
|
||||
world.setBlock(ex, py, ez, ModBlocks.bifrost);
|
||||
TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(ex, py, ez);
|
||||
tileBifrost.ticks = 10;
|
||||
tile.recieveMana(-MANA_COST_AVATAR);
|
||||
} else if(block == ModBlocks.bifrost) {
|
||||
TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(ex, py, ez);
|
||||
if(tileBifrost.ticks < 2) {
|
||||
tileBifrost.ticks = 10;
|
||||
tile.recieveMana(-MANA_COST_AVATAR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,11 +10,16 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.rod;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
@@ -26,6 +31,7 @@ import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.brew.ModPotions;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
@@ -148,6 +154,28 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
|
||||
@Override
|
||||
public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) {
|
||||
TileEntity te = (TileEntity) tile;
|
||||
World world = te.getWorldObj();
|
||||
if(tile.getCurrentMana() >= COST) {
|
||||
int range = 5;
|
||||
int rangeY = 3;
|
||||
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(te.xCoord + 0.5 - range, te.yCoord + 0.5 - rangeY, te.zCoord + 0.5 - range, te.xCoord + 0.5 + range, te.yCoord + 0.5 + rangeY, te.zCoord + 0.5 + range));
|
||||
for(EntityPlayer p : players) {
|
||||
if(p.motionY > 0.3 && p.motionY < 2 && !p.isSneaking()) {
|
||||
p.motionY = 2.8;
|
||||
|
||||
for(int i = 0; i < 20; i++)
|
||||
for(int j = 0; j < 5; j++)
|
||||
Botania.proxy.wispFX(p.worldObj, p.posX, p.posY + i, p.posZ, 0.25F, 0.25F, 0.25F, 0.35F + (float) Math.random() * 0.1F, 0.2F * (float) (Math.random() - 0.5), -0.01F * (float) Math.random(), 0.2F * (float) (Math.random() - 0.5));
|
||||
|
||||
if(!world.isRemote) {
|
||||
p.worldObj.playSoundAtEntity(p, "botania:dash", 1F, 1F);
|
||||
p.addPotionEffect(new PotionEffect(ModPotions.featherfeet.id, 100, 0));
|
||||
tile.recieveMana(-COST);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user