mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-13 08:44:02 +00:00
Added the effect of the Bottle of Ender Air.
This commit is contained in:
1 parent
02a5ca8de7
commit
78fe56ea15
6 files changed
+110
-11
No files matched your search
@@ -109,6 +109,7 @@ import vazkii.botania.common.core.proxy.CommonProxy;
|
||||
import vazkii.botania.common.core.version.VersionChecker;
|
||||
import vazkii.botania.common.entity.EntityCorporeaSpark;
|
||||
import vazkii.botania.common.entity.EntityDoppleganger;
|
||||
import vazkii.botania.common.entity.EntityEnderAirBottle;
|
||||
import vazkii.botania.common.entity.EntityPixie;
|
||||
import vazkii.botania.common.entity.EntitySpark;
|
||||
import vazkii.botania.common.entity.EntityThornChakram;
|
||||
@@ -216,6 +217,7 @@ public class ClientProxy extends CommonProxy {
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntitySpark.class, new RenderSpark());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityThornChakram.class, new RenderSnowball(ModItems.thornChakram));
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityCorporeaSpark.class, new RenderCorporeaSpark());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityEnderAirBottle.class, new RenderSnowball(ModItems.manaResource, 15));
|
||||
|
||||
ShaderHelper.initShaders();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* 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 @ [Feb 16, 2015, 5:15:31 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityEnderAirBottle extends EntityThrowable {
|
||||
|
||||
public EntityEnderAirBottle(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityEnderAirBottle(World world, EntityLivingBase entity) {
|
||||
super(world, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition pos) {
|
||||
if(pos.entityHit == null && !worldObj.isRemote) {
|
||||
List<ChunkCoordinates> coordsList = getCoordsToPut(pos.blockX, pos.blockY, pos.blockZ);
|
||||
this.worldObj.playAuxSFX(2002, (int)Math.round(this.posX), (int)Math.round(this.posY), (int)Math.round(this.posZ), 8);
|
||||
|
||||
for(ChunkCoordinates coords : coordsList) {
|
||||
worldObj.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.end_stone);
|
||||
if(Math.random() < 0.1)
|
||||
worldObj.playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(Blocks.end_stone));
|
||||
}
|
||||
setDead();
|
||||
}
|
||||
}
|
||||
|
||||
public List<ChunkCoordinates> getCoordsToPut(int xCoord, int yCoord, int zCoord) {
|
||||
List<ChunkCoordinates> possibleCoords = new ArrayList();
|
||||
List<ChunkCoordinates> selectedCoords = new ArrayList();
|
||||
int range = 4;
|
||||
int rangeY = 4;
|
||||
|
||||
for(int i = -range; i < range + 1; i++)
|
||||
for(int j = -rangeY; j < rangeY; j++)
|
||||
for(int k = -range; k < range + 1; k++) {
|
||||
int x = xCoord + i;
|
||||
int y = yCoord + j;
|
||||
int z = zCoord + k;
|
||||
Block block = worldObj.getBlock(x, y, z);
|
||||
if(block != null && block.isReplaceableOreGen(worldObj, x, y, z, Blocks.stone))
|
||||
possibleCoords.add(new ChunkCoordinates(x, y, z));
|
||||
}
|
||||
|
||||
int count = 64;
|
||||
while(!possibleCoords.isEmpty() && count > 0) {
|
||||
ChunkCoordinates coords = possibleCoords.get(worldObj.rand.nextInt(possibleCoords.size()));
|
||||
possibleCoords.remove(coords);
|
||||
selectedCoords.add(coords);
|
||||
count--;
|
||||
}
|
||||
return selectedCoords;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,6 +31,7 @@ public final class ModEntities {
|
||||
EntityRegistry.registerModEntity(EntityMagicMissile.class, LibEntityNames.MAGIC_MISSILE, id++, Botania.instance, 64, 10, true);
|
||||
EntityRegistry.registerModEntity(EntityThornChakram.class, LibEntityNames.THORN_CHAKRAM, id++, Botania.instance, 64, 10, true);
|
||||
EntityRegistry.registerModEntity(EntityCorporeaSpark.class, LibEntityNames.CORPOREA_SPARK, id++, Botania.instance, 64, 10, false);
|
||||
EntityRegistry.registerModEntity(EntityEnderAirBottle.class, LibEntityNames.ENDER_AIR_BOTTLE, id++, Botania.instance, 64, 10, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.item.EntityExpBottle;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -34,6 +35,7 @@ import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.achievement.IPickupAchievement;
|
||||
import vazkii.botania.common.achievement.ModAchievements;
|
||||
import vazkii.botania.common.entity.EntityDoppleganger;
|
||||
import vazkii.botania.common.entity.EntityEnderAirBottle;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
@@ -61,17 +63,17 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
|
||||
boolean ender = event.world.provider.dimensionId == 1;
|
||||
|
||||
if(rightEvent && correctStack && ender) {
|
||||
ItemStack stack1 = new ItemStack(this, 1, 15);
|
||||
if(!event.entityPlayer.inventory.addItemStackToInventory(stack1))
|
||||
event.entityPlayer.dropPlayerItemWithRandomChoice(stack1, true);
|
||||
ItemStack stack1 = new ItemStack(this, 1, 15);
|
||||
if(!event.entityPlayer.inventory.addItemStackToInventory(stack1))
|
||||
event.entityPlayer.dropPlayerItemWithRandomChoice(stack1, true);
|
||||
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize == 0)
|
||||
event.entityPlayer.inventory.setInventorySlotContents(event.entityPlayer.inventory.currentItem, null);
|
||||
|
||||
if(event.world.isRemote)
|
||||
event.entityPlayer.swingItem();
|
||||
else event.world.playSoundAtEntity(event.entityPlayer, "random.pop", 0.5F, 1F);
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize == 0)
|
||||
event.entityPlayer.inventory.setInventorySlotContents(event.entityPlayer.inventory.currentItem, null);
|
||||
|
||||
if(event.world.isRemote)
|
||||
event.entityPlayer.swingItem();
|
||||
else event.world.playSoundAtEntity(event.entityPlayer, "random.pop", 0.5F, 1F);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +81,25 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
|
||||
if(par1ItemStack.getItemDamage() == 4 || par1ItemStack.getItemDamage() == 14)
|
||||
return EntityDoppleganger.spawn(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6, par1ItemStack.getItemDamage() == 14);
|
||||
|
||||
|
||||
return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par3World, EntityPlayer par2EntityPlayer) {
|
||||
if(par1ItemStack.getItemDamage() == 15) {
|
||||
if(!par2EntityPlayer.capabilities.isCreativeMode)
|
||||
--par1ItemStack.stackSize;
|
||||
|
||||
par3World.playSoundAtEntity(par2EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if(!par3World.isRemote)
|
||||
par3World.spawnEntityInWorld(new EntityEnderAirBottle(par3World, par2EntityPlayer));
|
||||
else par2EntityPlayer.swingItem();
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -26,5 +26,6 @@ public final class LibEntityNames {
|
||||
public static final String MAGIC_MISSILE = LibResources.PREFIX_MOD + "magicMissile";
|
||||
public static final String THORN_CHAKRAM = LibResources.PREFIX_MOD + "thornChakram";
|
||||
public static final String CORPOREA_SPARK = LibResources.PREFIX_MOD + "corporeaSpark";
|
||||
public static final String ENDER_AIR_BOTTLE = LibResources.PREFIX_MOD + "enderAirBottle";
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user