mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-10-26 14:24:22 +00:00
Finish rods (a bit of block leaked in, oops)
This commit is contained in:
1 parent
55bf02798d
commit
3f9d5c888f
7 files changed
+77
-70
No files matched your search
@@ -0,0 +1,20 @@
|
||||
-- API --
|
||||
* Updated to BlockPos and EnumFacing everywhere where it made sense
|
||||
* Registering repainting blocks will need to also receive a PropertyEnum with EnumDyeColor as the component type
|
||||
so Botania knows what property to set the color on (todo actually do this)
|
||||
* ICorporeaSpark.getInventory had to be changed to ICorporeaSpark.getSparkInventory because the signature clashed (IInventory vs ItemStack[], respectively)
|
||||
This can be changed to match vanilla signature, but either would break backward compat.
|
||||
|
||||
-- Other --
|
||||
* Most things left untouched to make patches from upstream easier
|
||||
* Most uses of chunkcoordinates directly convert blockpos (THANK YOU VAZKII FOR USING THEM). Remove creation of extra instances
|
||||
since BlockPos'es are immutable and thus can be reused everywhere.
|
||||
* Some really needed fields in EntityItem are private now. Reflection time :(
|
||||
|
||||
|
||||
-- Todo --
|
||||
* Fix all the block signatures (easy)
|
||||
* Fix all other low hanging errors (easy-med)
|
||||
* Find all the block metadatas and give them all meaningful block states and properties (tedious/med-hard)
|
||||
* JSON models for everything (tedious/med-hard)
|
||||
* Migrate the PlayerRender events (baubles, etc.) to LayerRenderers (med)
|
||||
@@ -14,12 +14,14 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.common.achievement.ICraftAchievement;
|
||||
import vazkii.botania.common.achievement.ModAchievements;
|
||||
@@ -39,8 +41,8 @@ public abstract class BlockCorporeaBase extends BlockModContainer<TileCorporeaBa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
|
||||
TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4);
|
||||
public void breakBlock(World par1World, BlockPos pos, IBlockState state) {
|
||||
TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(pos);
|
||||
|
||||
if (inv != null) {
|
||||
for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) {
|
||||
@@ -58,7 +60,7 @@ public abstract class BlockCorporeaBase extends BlockModContainer<TileCorporeaBa
|
||||
k1 = itemstack.stackSize;
|
||||
|
||||
itemstack.stackSize -= k1;
|
||||
entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
|
||||
entityitem = new EntityItem(par1World, pos.getX() + f, pos.getY() + f1, pos.getZ() + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (float)random.nextGaussian() * f3;
|
||||
entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
|
||||
@@ -70,10 +72,10 @@ public abstract class BlockCorporeaBase extends BlockModContainer<TileCorporeaBa
|
||||
}
|
||||
}
|
||||
|
||||
par1World.func_147453_f(par2, par3, par4, par5);
|
||||
par1World.notifyNeighborsOfStateChange(pos, state.getBlock());
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
super.breakBlock(par1World, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,9 +37,9 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
|
||||
public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) {
|
||||
if(!world.isRemote) {
|
||||
TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(x, y, z);
|
||||
TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(pos);
|
||||
cube.doRequest(player.isSneaking());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ItemCobbleRod extends ItemMod implements IManaUsingItem, IBlockProv
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
|
||||
return ItemDirtRod.place(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10, Blocks.cobblestone, COST, 0.3F, 0.3F, 0.3F);
|
||||
return ItemDirtRod.place(par1ItemStack, par2EntityPlayer, par3World, pos, side, par8, par9, par10, Blocks.cobblestone, COST, 0.3F, 0.3F, 0.3F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,10 +17,7 @@ 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.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.item.IAvatarTile;
|
||||
import vazkii.botania.api.item.IAvatarWieldable;
|
||||
@@ -58,6 +55,7 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
double x = par3EntityPlayer.posX;
|
||||
double y = par3EntityPlayer.posY;
|
||||
double z = par3EntityPlayer.posZ;
|
||||
BlockPos playerPos = new BlockPos(par3EntityPlayer);
|
||||
|
||||
double lx = 0;
|
||||
double ly = -1;
|
||||
@@ -68,18 +66,18 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
int maxlen = prof ? 160 : 100;
|
||||
int time = prof ? (int) (TIME * 1.6) : TIME;
|
||||
|
||||
while(count < maxlen && (int) lx == (int) x && (int) ly == (int) y && (int) lz == (int) z || count < 4 || par2World.getBlock((int) x, (int) y, (int) z).isAir(par2World, (int) x, (int) y, (int) z) || par2World.getBlock((int) x, (int) y, (int) z) == place) {
|
||||
while(count < maxlen && (int) lx == (int) x && (int) ly == (int) y && (int) lz == (int) z || count < 4 || par2World.getBlockState(playerPos).getBlock().isAir(par2World, playerPos) || par2World.getBlockState(playerPos).getBlock() == place) {
|
||||
if(y >= 256 || y <= 0)
|
||||
break;
|
||||
|
||||
for(int i = -2; i < 1; i++)
|
||||
for(int j = -2; j < 1; j++)
|
||||
if(par2World.getBlock((int) x + i, (int) y, (int) z + j).isAir(par2World, (int) x + i, (int) y, (int) z + j) || par2World.getBlock((int) x + i, (int) y, (int) z + j) == place) {
|
||||
par2World.setBlock((int) x + i, (int) y, (int) z + j, place);
|
||||
TileBifrost tile = (TileBifrost) par2World.getTileEntity((int) x + i, (int) y, (int) z + j);
|
||||
if(par2World.getBlockState(playerPos.add(i, 0, j)).getBlock().isAir(par2World, playerPos.add(i, 0, j)) || par2World.getBlockState(playerPos.add(i, 0, j)).getBlock() == place) {
|
||||
par2World.setBlockState(playerPos.add(i, 0, j), place.getDefaultState());
|
||||
TileBifrost tile = (TileBifrost) par2World.getTileEntity(playerPos.add(i, 0, j));
|
||||
if(tile != null) {
|
||||
for(int k = 0; k < 4; k++)
|
||||
Botania.proxy.sparkleFX(par2World, tile.xCoord + Math.random(), tile.yCoord + Math.random(), tile.zCoord + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6);
|
||||
Botania.proxy.sparkleFX(par2World, tile.getPos().getX() + Math.random(), tile.getPos().getY() + Math.random(), tile.getPos().getZ() + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6);
|
||||
tile.ticks = time;
|
||||
}
|
||||
}
|
||||
@@ -114,11 +112,6 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
return getContainerItem(stack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
|
||||
if(par1ItemStack.isItemDamaged())
|
||||
@@ -143,9 +136,7 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
if(world.isRemote || tile.getCurrentMana() < MANA_COST_AVATAR * 25 || !tile.isEnabled())
|
||||
return;
|
||||
|
||||
int x = te.xCoord;
|
||||
int y = te.yCoord;
|
||||
int z = te.zCoord;
|
||||
BlockPos tePos = te.getPos();
|
||||
int w = 1;
|
||||
int h = 1;
|
||||
int l = 20;
|
||||
@@ -153,16 +144,16 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
AxisAlignedBB axis = null;
|
||||
switch(te.getBlockMetadata() - 2) {
|
||||
case 0 :
|
||||
axis = new AxisAlignedBB(x - w, y - h, z - l, x + w + 1, y + h, z);
|
||||
axis = new AxisAlignedBB(tePos.add(-w, -h, -l), tePos.add(w + 1, h, 0));
|
||||
break;
|
||||
case 1 :
|
||||
axis = new AxisAlignedBB(x - w, y - h, z + 1, x + w + 1, y + h, z + l + 1);
|
||||
axis = new AxisAlignedBB(tePos.add(-w, -h, 1), tePos.add(w + 1, h, l + 1));
|
||||
break;
|
||||
case 2 :
|
||||
axis = new AxisAlignedBB(x - l, y - h, z - w, x, y + h, z + w + 1);
|
||||
axis = new AxisAlignedBB(tePos.add(-l, -h, -w), tePos.add(0, h, w + 1));
|
||||
break;
|
||||
case 3 :
|
||||
axis = new AxisAlignedBB(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1);
|
||||
axis = new AxisAlignedBB(tePos.add(1, -h, -w), tePos.add(l + 1, h, w + 1));
|
||||
}
|
||||
|
||||
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, axis);
|
||||
@@ -180,15 +171,15 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
|
||||
|
||||
if(!axis.isVecInside(new Vec3(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);
|
||||
BlockPos pos = new BlockPos(ex, py, ez);
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
if(block.isAir(world, pos)) {
|
||||
world.setBlockState(pos, ModBlocks.bifrost.getDefaultState());
|
||||
TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(pos);
|
||||
tileBifrost.ticks = 10;
|
||||
tile.recieveMana(-MANA_COST_AVATAR);
|
||||
} else if(block == ModBlocks.bifrost) {
|
||||
TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(ex, py, ez);
|
||||
TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(pos);
|
||||
if(tileBifrost.ticks < 2) {
|
||||
tileBifrost.ticks = 10;
|
||||
tile.recieveMana(-MANA_COST_AVATAR);
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
@@ -66,10 +67,9 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
|
||||
MovingObjectPosition pos = ToolCommons.raytraceFromEntity(p.worldObj, p, false, 32);
|
||||
|
||||
if(pos != null) {
|
||||
Block block = p.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
int meta = p.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
|
||||
IBlockState state = p.worldObj.getBlockState(pos.getBlockPos());
|
||||
|
||||
ItemStack blockStack = new ItemStack(block, 1, meta);
|
||||
ItemStack blockStack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
|
||||
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(blockStack);
|
||||
|
||||
if(result != null && result.getItem() instanceof ItemBlock) {
|
||||
@@ -83,7 +83,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
|
||||
decremented = true;
|
||||
if(data.progress <= 0) {
|
||||
if(!p.worldObj.isRemote) {
|
||||
p.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Block.getBlockFromItem(result.getItem()), result.getItemDamage(), 1 | 2);
|
||||
p.worldObj.setBlockState(pos.getBlockPos(), Block.getBlockFromItem(result.getItem()).getStateFromMeta(result.getItemDamage()), 1 | 2);
|
||||
p.worldObj.playSoundAtEntity(p, "fire.ignite", 0.6F, 1F);
|
||||
p.worldObj.playSoundAtEntity(p, "fire.fire", 1F, 1F);
|
||||
|
||||
@@ -93,9 +93,9 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
|
||||
}
|
||||
|
||||
for(int i = 0; i < 25; i++) {
|
||||
double x = pos.blockX + Math.random();
|
||||
double y = pos.blockY + Math.random();
|
||||
double z = pos.blockZ + Math.random();
|
||||
double x = pos.getBlockPos().getX() + Math.random();
|
||||
double y = pos.getBlockPos().getY() + Math.random();
|
||||
double z = pos.getBlockPos().getZ() + Math.random();
|
||||
|
||||
Botania.proxy.wispFX(p.worldObj, x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F);
|
||||
}
|
||||
@@ -107,9 +107,9 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
|
||||
playerData.put(p, new SmeltData(pos, IManaProficiencyArmor.Helper.hasProficiency(p) ? (int) (TIME * 0.6) : TIME));
|
||||
else {
|
||||
for(int i = 0; i < 2; i++) {
|
||||
double x = pos.blockX + Math.random();
|
||||
double y = pos.blockY + Math.random();
|
||||
double z = pos.blockZ + Math.random();
|
||||
double x = pos.getBlockPos().getX() + Math.random();
|
||||
double y = pos.getBlockPos().getY() + Math.random();
|
||||
double z = pos.getBlockPos().getZ() + Math.random();
|
||||
Botania.proxy.wispFX(p.worldObj, x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F);
|
||||
}
|
||||
if(time % 10 == 0)
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFlower;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -23,8 +24,8 @@ import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.item.IBlockProvider;
|
||||
import vazkii.botania.api.item.IManaProficiencyArmor;
|
||||
@@ -63,7 +64,7 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
|
||||
return EnumAction.bow;
|
||||
return EnumAction.BOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,7 +88,7 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
|
||||
int range = IManaProficiencyArmor.Helper.hasProficiency(par3EntityPlayer) ? 22 : 16;
|
||||
|
||||
int xCenter = (int) par3EntityPlayer.posX;
|
||||
int yCenter = (int) par3EntityPlayer.posY - (par2World.isRemote ? 2 : 1);
|
||||
int yCenter = (int) par3EntityPlayer.posY;
|
||||
int zCenter = (int) par3EntityPlayer.posZ;
|
||||
|
||||
if(yCenter < 62) // Not below sea level
|
||||
@@ -104,37 +105,30 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
|
||||
if(yStart + k < 0)
|
||||
break;
|
||||
|
||||
int x = xCenter + i;
|
||||
int y = yStart + k;
|
||||
int z = zCenter + j;
|
||||
BlockPos pos = new BlockPos(xCenter + i, yStart + k, zCenter + j);
|
||||
IBlockState state = par2World.getBlockState(pos);
|
||||
|
||||
Block block = par2World.getBlock(x, y, z);
|
||||
int meta = par2World.getBlockMetadata(x, y, z);
|
||||
|
||||
int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, meta));
|
||||
int[] ids = OreDictionary.getOreIDs(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)));
|
||||
for(int id : ids)
|
||||
if(validBlocks.contains(OreDictionary.getOreName(id))) {
|
||||
boolean hasAir = false;
|
||||
List<BlockPos> airBlocks = new ArrayList();
|
||||
|
||||
for(ForgeDirection dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
int x_ = x + dir.offsetX;
|
||||
int y_ = y + dir.offsetY;
|
||||
int z_ = z + dir.offsetZ;
|
||||
|
||||
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) || block_ == Blocks.double_plant) {
|
||||
airBlocks.add(new BlockPos(x_, y_, z_));
|
||||
for(EnumFacing dir : LibMisc.CARDINAL_DIRECTIONS) {
|
||||
BlockPos pos_ = pos.offset(dir);
|
||||
Block block_ = par2World.getBlockState(pos_).getBlock();
|
||||
if(block_.isAir(par2World, pos_) || block_.isReplaceable(par2World, pos_) || block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower) || block_ == Blocks.double_plant) {
|
||||
airBlocks.add(pos_);
|
||||
hasAir = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(hasAir) {
|
||||
if(y > yCenter)
|
||||
blocks.add(new CoordsWithBlock(x, y, z, Blocks.air));
|
||||
if(pos.getY() > yCenter)
|
||||
blocks.add(new CoordsWithBlock(pos, Blocks.air));
|
||||
else for(BlockPos coords : airBlocks) {
|
||||
if(par2World.getBlock(coords.posX, coords.posY - 1, coords.posZ) != Blocks.air)
|
||||
blocks.add(new CoordsWithBlock(coords.posX, coords.posY, coords.posZ, Blocks.dirt));
|
||||
if(par2World.getBlockState(coords.down()).getBlock() != Blocks.air)
|
||||
blocks.add(new CoordsWithBlock(coords, Blocks.dirt));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -148,7 +142,7 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
|
||||
if(par2World.isRemote || ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, cost, true)) {
|
||||
if(!par2World.isRemote)
|
||||
for(CoordsWithBlock block : blocks)
|
||||
par2World.setBlock(block.posX, block.posY, block.posZ, block.block);
|
||||
par2World.setBlockState(block, block.block.getDefaultState());
|
||||
|
||||
if(!blocks.isEmpty()) {
|
||||
for(int i = 0; i < 10; i++)
|
||||
@@ -168,8 +162,8 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
|
||||
|
||||
final Block block;
|
||||
|
||||
public CoordsWithBlock(int x, int y, int z, Block block) {
|
||||
super(x, y, z);
|
||||
public CoordsWithBlock(BlockPos pos, Block block) {
|
||||
super(pos.getX(), pos.getY(), pos.getZ());
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user