Most of what I can do with API done.

This commit is contained in:
Vincent Lee committed 2015-11-14 00:28:00 -06:00
1 parent d293a7dcc7
commit 4d674da1b7
12 files changed
+36 -41

No files matched your search

@@ -13,7 +13,6 @@ package vazkii.botania.api.internal;
import java.util.List;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
@@ -22,7 +21,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.IIcon;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import vazkii.botania.api.boss.IBotaniaBoss;
@@ -203,7 +202,7 @@ public class DummyMethodHandler implements IInternalMethodHandler {
@Override
public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) {
public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, BlockPos pos, EnumFacing side) {
// NO-OP
}
@@ -13,7 +13,6 @@ package vazkii.botania.api.internal;
import java.util.List;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
@@ -21,7 +20,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.IIcon;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import vazkii.botania.api.boss.IBotaniaBoss;
@@ -93,7 +92,7 @@ public interface IInternalMethodHandler {
public IInventory getBaublesInventory(EntityPlayer player);
public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side);
public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, BlockPos pos, EnumFacing side);
@SideOnly(Side.CLIENT)
public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res);
@@ -14,7 +14,6 @@ import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
@@ -32,17 +32,17 @@ public class Multiblock {
public int minX, minY, minZ, maxX, maxY, maxZ, offX, offY, offZ;
public HashMap<List<Integer>, MultiblockComponent> locationCache = new HashMap<List<Integer>, MultiblockComponent>();
public HashMap<BlockPos, MultiblockComponent> locationCache = new HashMap<BlockPos, MultiblockComponent>();
/**
* Adds a multiblock component to this multiblock. The component's x y z
* coords should be pivoted to the center of the structure.
*/
public void addComponent(MultiblockComponent component) {
if(getComponentForLocation(component.relPos.posX, component.relPos.posY, component.relPos.posZ) != null)
if(getComponentForLocation(component.relPos) != null)
throw new IllegalArgumentException("Location in multiblock already occupied");
components.add(component);
changeAxisForNewComponent(component.relPos.posX, component.relPos.posY, component.relPos.posZ);
changeAxisForNewComponent(component.relPos.getX(), component.relPos.getY(), component.relPos.getZ());
calculateCostForNewComponent(component);
addComponentToLocationCache(component);
}
@@ -51,8 +51,8 @@ public class Multiblock {
* Constructs and adds a multiblock component to this multiblock. The x y z
* coords should be pivoted to the center of the structure.
*/
public void addComponent(int x, int y, int z, Block block, int meta) {
addComponent(new MultiblockComponent(new BlockPos(x, y, z), block, meta));
public void addComponent(BlockPos pos, Block block, int meta) {
addComponent(new MultiblockComponent(pos, block, meta));
}
private void changeAxisForNewComponent(int x, int y, int z) {
@@ -172,17 +172,14 @@ public class Multiblock {
*/
private void addComponentToLocationCache(MultiblockComponent comp) {
BlockPos pos = comp.getRelativePosition();
locationCache.put(Arrays.asList(
pos.posX,
pos.posY,
pos.posZ
), comp);
locationCache.put(pos, comp);
}
/**
* Gets the component for a given location
* @param pos
*/
public MultiblockComponent getComponentForLocation(int x, int y, int z) {
return locationCache.get(Arrays.asList(x, y, z));
public MultiblockComponent getComponentForLocation(BlockPos pos) {
return locationCache.get(pos);
}
}
@@ -73,7 +73,7 @@ public class SubTileFunctional extends SubTileEntity {
if(acceptsRedstone()) {
redstoneSignal = 0;
for(EnumFacing dir : EnumFacing.VALUES) {
int redstoneSide = supertile.getWorld().getIndirectPowerLevelTo(supertile.getPos().offset(dir), dir.ordinal());
int redstoneSide = supertile.getWorld().getRedstonePower(supertile.getPos().offset(dir), dir);
redstoneSignal = Math.max(redstoneSignal, redstoneSide);
}
}
@@ -82,7 +82,7 @@ public class SubTileFunctional extends SubTileEntity {
double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F;
Color color = new Color(getColor());
if(Math.random() > particleChance)
BotaniaAPI.internalHandler.sparkleFX(supertile.getWorld(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
BotaniaAPI.internalHandler.sparkleFX(supertile.getWorld(), supertile.getPos().getX() + 0.3 + Math.random() * 0.5, supertile.getPos().getY() + 0.5 + Math.random() * 0.5, supertile.getPos().getZ() + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
}
}
@@ -193,7 +193,7 @@ public class SubTileFunctional extends SubTileEntity {
int range = 10;
range *= range;
double dist = (x - supertile.xCoord) * (x - supertile.xCoord) + (y - supertile.yCoord) * (y - supertile.yCoord) + (z - supertile.zCoord) * (z - supertile.zCoord);
double dist = pos.distanceSq(supertile.getPos());
if(range >= dist) {
TileEntity tile = player.worldObj.getTileEntity(pos);
if(tile instanceof IManaPool) {
@@ -82,7 +82,7 @@ public class SubTileGenerating extends SubTileEntity {
if(acceptsRedstone()) {
redstoneSignal = 0;
for(EnumFacing dir : EnumFacing.VALUES) {
int redstoneSide = supertile.getWorld().getIndirectPowerLevelTo(supertile.getPos().offset(dir), dir.ordinal());
int redstoneSide = supertile.getWorld().getRedstonePower(supertile.getPos().offset(dir), dir);
redstoneSignal = Math.max(redstoneSignal, redstoneSide);
}
}
@@ -91,7 +91,7 @@ public class SubTileGenerating extends SubTileEntity {
double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F;
Color color = new Color(getColor());
if(Math.random() > particleChance)
BotaniaAPI.internalHandler.sparkleFX(supertile.getWorld(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
BotaniaAPI.internalHandler.sparkleFX(supertile.getWorld(), supertile.getPos().getX() + 0.3 + Math.random() * 0.5, supertile.getPos().getY() + 0.5 + Math.random() * 0.5, supertile.getPos().getZ() + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
}
boolean passive = isPassiveFlower();
@@ -99,7 +99,7 @@ public class SubTileGenerating extends SubTileEntity {
int muhBalance = BotaniaAPI.internalHandler.getPassiveFlowerDecay();
if(passive && muhBalance > 0 && passiveDecayTicks > muhBalance) {
supertile.getWorld().playAuxSFX(2001, supertile.xCoord, supertile.yCoord, supertile.zCoord, Block.getIdFromBlock(supertile.getBlockType()));
supertile.getWorld().playAuxSFX(2001, supertile.getPos(), Block.getIdFromBlock(supertile.getBlockType()));
if(supertile.getWorld().getBlockState(supertile.getPos().down()).getBlock().isSideSolid(supertile.getWorld(), supertile.getPos().down(), EnumFacing.DOWN))
supertile.getWorld().setBlockState(supertile.getPos(), Blocks.deadbush.getDefaultState());
else supertile.getWorld().setBlockToAir(supertile.getPos());
@@ -283,7 +283,7 @@ public class SubTileGenerating extends SubTileEntity {
int range = 6;
range *= range;
double dist = (x - supertile.xCoord) * (x - supertile.xCoord) + (y - supertile.yCoord) * (y - supertile.yCoord) + (z - supertile.zCoord) * (z - supertile.zCoord);
double dist = pos.distanceSq(supertile.getPos());
if(range >= dist) {
TileEntity tile = player.worldObj.getTileEntity(pos);
if(tile instanceof IManaCollector) {
@@ -126,7 +126,7 @@ public class MultiblockBlockAccess implements IBlockAccess {
* Returns the multiblock component for the coordinates, adjusted based on the anchor
*/
protected MultiblockComponent getComponent(int x, int y, int z) {
MultiblockComponent comp = multiblock.getComponentForLocation(x - anchorX, y - anchorY, z - anchorZ);
MultiblockComponent comp = multiblock.getComponentForLocation(x - anchorX);
return comp;
}
}
@@ -97,15 +97,15 @@ public class TileAlfPortal extends TileMod {
Multiblock mb = new Multiblock();
for(int[] l : LIVINGWOOD_POSITIONS)
mb.addComponent(l[0], l[1] + 1, l[2], ModBlocks.livingwood, 0);
mb.addComponent(, l[0], ModBlocks.livingwood, 0);
for(int[] g : GLIMMERING_LIVINGWOOD_POSITIONS)
mb.addComponent(g[0], g[1] + 1, g[2], ModBlocks.livingwood, 5);
mb.addComponent(, g[0], ModBlocks.livingwood, 5);
for(int[] p : PYLON_POSITIONS)
mb.addComponent(-p[0], p[1] + 1, -p[2], ModBlocks.pylon, 1);
mb.addComponent(, -p[0], ModBlocks.pylon, 1);
for(int[] p : POOL_POSITIONS)
mb.addComponent(-p[0], p[1] + 1, -p[2], ModBlocks.pool, 0);
mb.addComponent(, -p[0], ModBlocks.pool, 0);
mb.addComponent(0, 1, 0, ModBlocks.alfPortal, 0);
mb.addComponent(, 0, ModBlocks.alfPortal, 0);
mb.setRenderOffset(0, -1, 0);
return mb.makeSet();
@@ -85,15 +85,15 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
Multiblock mb = new Multiblock();
for(int[] o : OBSIDIAN_LOCATIONS)
mb.addComponent(o[0], o[1] + 1, o[2], Blocks.obsidian, 0);
mb.addComponent(, o[0], Blocks.obsidian, 0);
for(int[] p : PYLON_LOCATIONS[0]) {
mb.addComponent(p[0], p[1] + 1, p[2], ModBlocks.pylon, 0);
mb.addComponent(, p[0], ModBlocks.pylon, 0);
mb.addComponent(new FlowerComponent(new ChunkCoordinates(p[0], p[1], p[2]), ModBlocks.flower));
}
for(int[] f : FLOWER_LOCATIONS)
mb.addComponent(new FlowerComponent(new ChunkCoordinates(f[0], f[1] + 1, f[2]), ModBlocks.flower));
mb.addComponent(0, 1, 0, Blocks.lapis_block, 0);
mb.addComponent(, 0, Blocks.lapis_block, 0);
return mb.makeSet();
}
@@ -50,11 +50,11 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable {
Multiblock mb = new Multiblock();
for(int[] l : LAPIS_BLOCKS)
mb.addComponent(l[0], 0, l[1], Blocks.lapis_block, 0);
mb.addComponent(, l[0], Blocks.lapis_block, 0);
for(int[] l : LIVINGROCK_BLOCKS)
mb.addComponent(l[0], 0, l[1], ModBlocks.livingrock, 0);
mb.addComponent(, l[0], ModBlocks.livingrock, 0);
mb.addComponent(0, 1, 0, ModBlocks.terraPlate, 0);
mb.addComponent(, 0, ModBlocks.terraPlate, 0);
mb.setRenderOffset(0, 1, 0);
return mb.makeSet();
@@ -24,6 +24,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
@@ -234,7 +235,7 @@ public class InternalMethodHandler extends DummyMethodHandler {
}
@Override
public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) {
public void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, BlockPos pos, EnumFacing side) {
ItemLokiRing.breakOnAllCursors(player, item, stack, x, y, z, side);
}
@@ -127,13 +127,13 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
Multiblock mb = new Multiblock();
for(int[] p : PYLON_LOCATIONS)
mb.addComponent(p[0], p[1] + 1, p[2], ModBlocks.pylon, 2);
mb.addComponent(, p[0], ModBlocks.pylon, 2);
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
mb.addComponent(new BeaconComponent(new ChunkCoordinates(i - 1, 0, j - 1)));
mb.addComponent(0, 1, 0, Blocks.beacon, 0);
mb.addComponent(, 0, Blocks.beacon, 0);
mb.setRenderOffset(0, -1, 0);
return mb.makeSet();