Added basic animation and sound to block breaker

This commit is contained in:
Robert S 2014-03-22 02:10:17 -04:00
parent 170f46b3a9
commit 620848f4e7
3 changed files with 58 additions and 39 deletions

View file

@ -5,6 +5,7 @@ import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
@ -98,19 +99,28 @@ public class TileBreaker extends TileBase implements IRotatable, IPacketReceiver
int candidateMeta = world().getBlockMetadata(check.intX(), check.intY(), check.intZ());
boolean flag = true;
//Get items dropped
ArrayList<ItemStack> drops = block.getBlockDropped(getWorldObj(), check.intX(), check.intY(), check.intZ(), candidateMeta, 0);
for (ItemStack stack : drops)
{
//Insert into tile if one exists
ItemStack insert = stack.copy();
insert = getInvHandler().storeItem(insert, this.getDirection().getOpposite());
//If not spit items into world
if (insert != null)
{
getInvHandler().throwItem(this.getDirection().getOpposite(), insert);
}
}
getWorldObj().destroyBlock(check.intX(), check.intY(), check.intZ(), false);
//Destroy block
ResonantInduction.proxy.renderBlockParticle(worldObj, check.intX(), check.intY(), check.intZ(), new Vector3((Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3), world().getBlockId(check.intX(), check.intY(), check.intZ()), 1);
getWorldObj().destroyBlock(check.intX(), check.intY(), check.intZ(), false);
getWorldObj().playAuxSFX(1012, check.intX(), check.intY(), check.intZ(), 0);
}
}
}

View file

@ -11,50 +11,54 @@ import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* @author Calclavia
*
*/
/** @author Calclavia */
@SideOnly(Side.CLIENT)
public class ClientProxy extends CommonProxy
{
@Override
public void preInit()
{
MinecraftForge.EVENT_BUS.register(SoundHandler.INSTANCE);
}
@Override
public void preInit()
{
MinecraftForge.EVENT_BUS.register(SoundHandler.INSTANCE);
}
@Override
public boolean isPaused()
{
if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic())
{
GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen;
@Override
public boolean isPaused()
{
if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic())
{
GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen;
if (screen != null)
{
if (screen.doesGuiPauseGame())
{
return true;
}
}
}
if (screen != null)
{
if (screen.doesGuiPauseGame())
{
return true;
}
}
}
return false;
}
return false;
}
@Override
public boolean isGraphicsFancy()
{
return FMLClientHandler.instance().getClient().gameSettings.fancyGraphics;
}
@Override
public boolean isGraphicsFancy()
{
return FMLClientHandler.instance().getClient().gameSettings.fancyGraphics;
}
@Override
public void renderBlockParticle(World world, Vector3 position, Vector3 velocity, int blockID, float scale)
{
this.renderBlockParticle(world, position.x, position.y, position.z, velocity, blockID, scale);
}
@Override
public void renderBlockParticle(World world, double x, double y, double z, Vector3 velocity, int blockID, float scale)
{
EntityFX fx = new EntityDiggingFX(world, x, y, z, velocity.x, velocity.y, velocity.z, Block.blocksList[blockID], 0, 0);
fx.multipleParticleScaleBy(scale);
fx.noClip = true;
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
}
@Override
public void renderBlockParticle(World world, Vector3 position, Vector3 velocity, int blockID, float scale)
{
EntityFX fx = new EntityDiggingFX(world, position.x, position.y, position.z, velocity.x, velocity.y, velocity.z, Block.blocksList[blockID], 0, 0);
fx.multipleParticleScaleBy(scale);
fx.noClip = true;
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
}
}

View file

@ -23,6 +23,11 @@ public class CommonProxy extends ProxyBase
return false;
}
public void renderBlockParticle(World world, double x, double y, double z, Vector3 velocity, int blockID, float scale)
{
}
public void renderBlockParticle(World world, Vector3 position, Vector3 velocity, int blockID, float scale)
{