Atomic Reconstructor Particles & Damage

This commit is contained in:
Ellpeck 2015-11-15 14:25:12 +01:00
parent 8834815c25
commit 623a8594e1
5 changed files with 157 additions and 3 deletions

View file

@ -0,0 +1,36 @@
/*
* This file ("DamageSources.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.misc;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.DamageSource;
import net.minecraft.util.IChatComponent;
public class DamageSources extends DamageSource{
public static final DamageSource DAMAGE_ATOMIC_RECONSTRUCTOR = new DamageSources("atomicReconstructor", 3).setDamageBypassesArmor();
private int messageCount;
public DamageSources(String name, int messageCount){
super(name);
this.messageCount = messageCount;
}
@Override
public IChatComponent func_151519_b(EntityLivingBase entity){
String locTag = "death."+ModUtil.MOD_ID_LOWER+"."+this.damageType+"."+(entity.worldObj.rand.nextInt(this.messageCount)+1);
return new ChatComponentText(StringUtil.localizeFormatted(locTag, entity.getCommandSenderName()));
}
}

View file

@ -0,0 +1,90 @@
/*
* This file ("PacketAtomicReconstructor.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.network;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityReddustFX;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class PacketAtomicReconstructor implements IMessage{
private int startX;
private int startY;
private int startZ;
private int endX;
private int endY;
private int endZ;
@SuppressWarnings("unused")
public PacketAtomicReconstructor(){
}
public PacketAtomicReconstructor(int startX, int startY, int startZ, int endX, int endY, int endZ){
this.startX = startX;
this.startY = startY;
this.startZ = startZ;
this.endX = endX;
this.endY = endY;
this.endZ = endZ;
}
@Override
public void fromBytes(ByteBuf buf){
this.startX = buf.readInt();
this.startY = buf.readInt();
this.startZ = buf.readInt();
this.endX = buf.readInt();
this.endY = buf.readInt();
this.endZ = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf){
buf.writeInt(this.startX);
buf.writeInt(this.startY);
buf.writeInt(this.startZ);
buf.writeInt(this.endX);
buf.writeInt(this.endY);
buf.writeInt(this.endZ);
}
public static class Handler implements IMessageHandler<PacketAtomicReconstructor, IMessage>{
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(PacketAtomicReconstructor message, MessageContext ctx){
World world = Minecraft.getMinecraft().theWorld;
if(Minecraft.getMinecraft().thePlayer.getDistance(message.startX, message.startY, message.startZ) <= 64){
int difX = message.startX-message.endX;
int difY = message.startY-message.endY;
int difZ = message.startZ-message.endZ;
double distance = Vec3.createVectorHelper(message.startX, message.startY, message.startZ).distanceTo(Vec3.createVectorHelper(message.endX, message.endY, message.endZ));
for(int times = 0; times < 5; times++){
for(double i = 0; i <= 1; i += 1/(distance*8)){
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityReddustFX(world, (difX*i)+message.endX+0.5, (difY*i)+message.endY+0.5, (difZ*i)+message.endZ+0.5, 2F, 0, 0, 0));
}
}
}
return null;
}
}
}

View file

@ -28,5 +28,6 @@ public class PacketHandler{
theNetwork.registerMessage(PacketGuiButton.Handler.class, PacketGuiButton.class, 0, Side.SERVER); theNetwork.registerMessage(PacketGuiButton.Handler.class, PacketGuiButton.class, 0, Side.SERVER);
theNetwork.registerMessage(PacketGuiNumber.Handler.class, PacketGuiNumber.class, 1, Side.SERVER); theNetwork.registerMessage(PacketGuiNumber.Handler.class, PacketGuiNumber.class, 1, Side.SERVER);
theNetwork.registerMessage(PacketGuiString.Handler.class, PacketGuiString.class, 2, Side.SERVER); theNetwork.registerMessage(PacketGuiString.Handler.class, PacketGuiString.class, 2, Side.SERVER);
theNetwork.registerMessage(PacketAtomicReconstructor.Handler.class, PacketAtomicReconstructor.class, 3, Side.CLIENT);
} }
} }

View file

@ -12,10 +12,15 @@ package ellpeck.actuallyadditions.tile;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyReceiver; import cofh.api.energy.IEnergyReceiver;
import cpw.mods.fml.common.network.NetworkRegistry;
import ellpeck.actuallyadditions.misc.DamageSources;
import ellpeck.actuallyadditions.network.PacketAtomicReconstructor;
import ellpeck.actuallyadditions.network.PacketHandler;
import ellpeck.actuallyadditions.recipe.AtomicReconstructorRecipeHandler; import ellpeck.actuallyadditions.recipe.AtomicReconstructorRecipeHandler;
import ellpeck.actuallyadditions.util.WorldPos; import ellpeck.actuallyadditions.util.WorldPos;
import ellpeck.actuallyadditions.util.WorldUtil; import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -41,11 +46,18 @@ public class TileEntityAtomicReconstructor extends TileEntityBase implements IEn
this.currentTime--; this.currentTime--;
if(this.currentTime <= 0){ if(this.currentTime <= 0){
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
//Extract energy for shooting the laser itself too!
this.storage.extractEnergy(usePerBlock*3, false);
for(int i = 0; i < 10; i++){ int distance = 10; //TODO Config
for(int i = 0; i < distance; i++){
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i); WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i);
this.damagePlayer(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
if(coordsBlock != null){ if(coordsBlock != null){
if(!coordsBlock.getBlock().isAir(coordsBlock.getWorld(), coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ())){ if(!coordsBlock.getBlock().isAir(coordsBlock.getWorld(), coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ())){
PacketHandler.theNetwork.sendToAllAround(new PacketAtomicReconstructor(xCoord, yCoord, zCoord, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 64));
int range = 2; //TODO Config int range = 2; //TODO Config
//Converting the Blocks //Converting the Blocks
@ -94,20 +106,30 @@ public class TileEntityAtomicReconstructor extends TileEntityBase implements IEn
} }
} }
} }
break; break;
} }
if(i >= distance-1){
PacketHandler.theNetwork.sendToAllAround(new PacketAtomicReconstructor(xCoord, yCoord, zCoord, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 64));
}
} }
} }
} }
} }
else{ else{
this.currentTime = 40; //TODO Config this.currentTime = 80; //TODO Config
} }
} }
} }
} }
@SuppressWarnings("unchecked")
public void damagePlayer(int x, int y, int z){
ArrayList<EntityLivingBase> entities = (ArrayList<EntityLivingBase>)worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(x, y, z, x+1, y+1, z+1));
for(EntityLivingBase entity : entities){
entity.attackEntityFrom(DamageSources.DAMAGE_ATOMIC_RECONSTRUCTOR, 16F);
}
}
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);

View file

@ -24,6 +24,11 @@ container.nei.actuallyadditions.booklet.name=ActAdd Manual
container.nei.actuallyadditions.booklet.header=The <item>Actually Additions Manual<r> reads: container.nei.actuallyadditions.booklet.header=The <item>Actually Additions Manual<r> reads:
container.nei.actuallyadditions.booklet.noText=Nothing, apparently! But that doesn't matter. Just click the button on the bottom to see the item inside the booklet and look through its pages to find some fancy stuff! container.nei.actuallyadditions.booklet.noText=Nothing, apparently! But that doesn't matter. Just click the button on the bottom to see the item inside the booklet and look through its pages to find some fancy stuff!
#Damage Sources
death.actuallyadditions.atomicReconstructor.1=The Atomic Reconstructor thought %s were a block and accidentally converted them into ashes
death.actuallyadditions.atomicReconstructor.2=%s stood in an Atomic Reconstructor's sight for too long. The laser killed them.
death.actuallyadditions.atomicReconstructor.3=This Atomic Reconstructor is now more valuable than the orangs and combined incoms of %s in *subject hometown here*.
#Blocks #Blocks
tile.actuallyadditions.blockCompost.name=Compost tile.actuallyadditions.blockCompost.name=Compost
tile.actuallyadditions.blockMiscOreBlackQuartz.name=Black Quartz Ore tile.actuallyadditions.blockMiscOreBlackQuartz.name=Black Quartz Ore