mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-21 12:42:50 +00:00
Terra Firma rod polish.
This commit is contained in:
1 parent
7bfb199645
commit
f10932b7cb
2 files changed
+48
-19
No files matched your search
@@ -15,40 +15,61 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFlower;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import vazkii.botania.api.ISpecialFlower;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemTerraformRod extends ItemMod {
|
||||
|
||||
private static final int COST_PER = 55;
|
||||
|
||||
public ItemTerraformRod() {
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
setUnlocalizedName(LibItemNames.TERRAFORM_ROD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
|
||||
return EnumAction.bow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
|
||||
if(count != getMaxItemUseDuration(stack) && count % 10 == 0)
|
||||
terraform(stack, player.worldObj, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
if(!par2World.isRemote)
|
||||
terraform(par1ItemStack, par2World, par3EntityPlayer);
|
||||
|
||||
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
|
||||
public void terraform(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
int range = 16;
|
||||
|
||||
int xCenter = (int) par3EntityPlayer.posX;
|
||||
int yCenter = (int) par3EntityPlayer.posY - 1;
|
||||
int yCenter = (int) par3EntityPlayer.posY - (par2World.isRemote ? 2 : 1);
|
||||
int zCenter = (int) par3EntityPlayer.posZ;
|
||||
|
||||
int yStart = yCenter + range;
|
||||
|
||||
int yStart = yCenter + range;
|
||||
|
||||
List<CoordsWithBlock> blocks = new ArrayList();
|
||||
|
||||
for(int i = -range; i < range + 1; i++)
|
||||
@@ -67,16 +88,17 @@ public class ItemTerraformRod extends ItemMod {
|
||||
boolean hasAir = false;
|
||||
List<ChunkCoordinates> airBlocks = new ArrayList();
|
||||
|
||||
ForgeDirection[] dirs = new ForgeDirection[] {
|
||||
final ForgeDirection[] dirs = new ForgeDirection[] {
|
||||
ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST
|
||||
};
|
||||
|
||||
|
||||
for(ForgeDirection dir : dirs) {
|
||||
int x_ = x + dir.offsetX;
|
||||
int y_ = y + dir.offsetY;
|
||||
int z_ = z + dir.offsetZ;
|
||||
|
||||
if(par2World.getBlock(x_, y_, z_).isAir(par2World, x_, y_, z_)) {
|
||||
Block block_ = par2World.getBlock(x_, y_, z_);
|
||||
if(block_.isAir(par2World, x_, y_, z_) || block_.isReplaceable(par2World, x_, y_, z_) || (block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower))) {
|
||||
airBlocks.add(new ChunkCoordinates(x_, y_, z_));
|
||||
hasAir = true;
|
||||
break;
|
||||
@@ -91,27 +113,33 @@ public class ItemTerraformRod extends ItemMod {
|
||||
blocks.add(new CoordsWithBlock(coords.posX, coords.posY, coords.posZ, Blocks.dirt));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
--k;
|
||||
}
|
||||
}
|
||||
|
||||
for(CoordsWithBlock block : blocks)
|
||||
par2World.setBlock(block.posX, block.posY, block.posZ, block.block);
|
||||
|
||||
int cost = COST_PER * blocks.size();
|
||||
|
||||
if(par2World.isRemote || ManaItemHandler.requestManaExact(par1ItemStack, par3EntityPlayer, cost, true)) {
|
||||
if(!par2World.isRemote)
|
||||
for(CoordsWithBlock block : blocks)
|
||||
par2World.setBlock(block.posX, block.posY, block.posZ, block.block);
|
||||
|
||||
for(int i = 0; i < 120; i++)
|
||||
Botania.proxy.sparkleFX(par2World, xCenter - range + range * 2 * Math.random(), yCenter + 2 + (Math.random() - 0.5) * 2, zCenter - range + range * 2 * Math.random(), 0.35F, 0.2F, 0.05F, 2F, 5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CoordsWithBlock extends ChunkCoordinates {
|
||||
|
||||
|
||||
final Block block;
|
||||
|
||||
|
||||
public CoordsWithBlock(int x, int y, int z, Block block) {
|
||||
super(x, y, z);
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -258,6 +258,7 @@ item.botania:grassSeeds2.name=Infection Seeds
|
||||
item.botania:livingwoodTwig.name=Livingwood Twig
|
||||
item.botania:timeRod.name=Rod of Flowing Time
|
||||
item.botania:dirtRod.name=Rod of the Lands
|
||||
item.botania:terraformRod.name=Terra Firma Rod
|
||||
|
||||
# GUI TEXT
|
||||
botania.gui.lexicon.header=Lexica Botania Index - Pick which category you would like to study:
|
||||
|
||||
Reference in new issue
Block a user