use of riskyken.armourersWorkshop.common.blocks.BlockLocation in project Armourers-Workshop by RiskyKen.
the class ItemSkin method canPlaceChildren.
private boolean canPlaceChildren(World world, EntityPlayer player, int side, ItemStack stack, int x, int y, int z, Skin skin, SkinPointer skinPointer, ArrayList<BlockLocation> relatedBlocks) {
ForgeDirection dir = UtilPlayer.getDirectionSide(player).getOpposite();
for (int ix = 0; ix < 3; ix++) {
for (int iy = 0; iy < 3; iy++) {
for (int iz = 0; iz < 3; iz++) {
float[] bounds = TileEntitySkinnable.getBlockBounds(skin, -ix + 2, iy, iz, dir);
if (bounds != null) {
int childX = x;
int childY = y;
int childZ = z;
childX += ix - 1 - dir.offsetX * 1;
childY += iy;
childZ += iz - 1 - dir.offsetZ * 1;
relatedBlocks.add(new BlockLocation(childX, childY, childZ));
Block replaceBlock = world.getBlock(childX, childY, childZ);
if (!replaceBlock.isReplaceable(world, childX, childY, childZ)) {
return false;
}
}
}
}
}
return true;
}
use of riskyken.armourersWorkshop.common.blocks.BlockLocation in project Armourers-Workshop by RiskyKen.
the class ItemBlendingTool method onDrawBlockHighlightEvent.
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event) {
EntityPlayer player = event.player;
World world = event.player.worldObj;
MovingObjectPosition target = event.target;
if (target != null && target.typeOfHit != MovingObjectType.BLOCK) {
return;
}
int x = target.blockX;
int y = target.blockY;
int z = target.blockZ;
int side = target.sideHit;
Block block = world.getBlock(x, y, z);
ItemStack stack = player.getCurrentEquippedItem();
if (stack == null || stack.getItem() != this) {
return;
}
if (!(block instanceof BlockColourable)) {
return;
}
int radiusSample = (Integer) ToolOptions.RADIUS_SAMPLE.readFromNBT(stack.getTagCompound(), 2);
int radiusEffect = (Integer) ToolOptions.RADIUS_EFFECT.readFromNBT(stack.getTagCompound(), 1);
ArrayList<BlockLocation> blockSamples = BlockUtils.findTouchingBlockFaces(world, x, y, z, side, radiusSample);
ArrayList<BlockLocation> blockEffects = BlockUtils.findTouchingBlockFaces(world, x, y, z, side, radiusEffect);
double xOff = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.partialTicks;
double yOff = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.partialTicks;
double zOff = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.partialTicks;
float f1 = 0.002F;
for (int i = 0; i < blockSamples.size(); i++) {
int colour = 0xFF0000;
BlockLocation blockLoc = blockSamples.get(i);
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(blockLoc.x, blockLoc.y, blockLoc.z, blockLoc.x + 1, blockLoc.y + 1, blockLoc.z + 1);
aabb.offset(-xOff, -yOff, -zOff);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.2F);
GL11.glLineWidth(2.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_DEPTH_TEST);
RenderGlobal.drawOutlinedBoundingBox(aabb.expand(f1, f1, f1), colour);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
}
for (int i = 0; i < blockEffects.size(); i++) {
BlockLocation blockLoc = blockEffects.get(i);
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(blockLoc.x + 0.10F, blockLoc.y + 0.10F, blockLoc.z + 0.10F, blockLoc.x + 0.90F, blockLoc.y + 0.90F, blockLoc.z + 0.90F);
aabb.offset(-xOff, -yOff, -zOff);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.2F);
GL11.glLineWidth(2.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_DEPTH_TEST);
// GL11.glDepthMask(false);
RenderGlobal.drawOutlinedBoundingBox(aabb.expand(f1, f1, f1), 0x00FF00);
// GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
}
event.setCanceled(true);
}
use of riskyken.armourersWorkshop.common.blocks.BlockLocation in project Armourers-Workshop by RiskyKen.
the class ItemBlendingTool method onItemUse.
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
Block block = world.getBlock(x, y, z);
if (block instanceof IPantableBlock) {
if (!world.isRemote) {
UndoManager.begin(player);
usedOnBlockSide(stack, player, world, new BlockLocation(x, y, z), block, side);
UndoManager.end(player);
world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, LibSounds.BURN, 1.0F, 1.0F);
}
return true;
}
if (block == ModBlocks.armourerBrain & player.isSneaking()) {
if (!world.isRemote) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileEntityArmourer) {
((TileEntityArmourer) te).toolUsedOnArmourer(this, world, stack, player);
}
}
return true;
}
return false;
}
use of riskyken.armourersWorkshop.common.blocks.BlockLocation in project Armourers-Workshop by RiskyKen.
the class ItemBurnTool method onItemUse.
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
Block block = world.getBlock(x, y, z);
if (block instanceof IPantableBlock) {
if (!world.isRemote) {
UndoManager.begin(player);
}
if ((Boolean) ToolOptions.FULL_BLOCK_MODE.readFromNBT(stack.getTagCompound())) {
for (int i = 0; i < 6; i++) {
usedOnBlockSide(stack, player, world, new BlockLocation(x, y, z), block, i);
}
} else {
usedOnBlockSide(stack, player, world, new BlockLocation(x, y, z), block, side);
}
if (!world.isRemote) {
UndoManager.end(player);
world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, LibSounds.BURN, 1.0F, 1.0F);
}
return true;
}
if (block == ModBlocks.armourerBrain & player.isSneaking()) {
if (!world.isRemote) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileEntityArmourer) {
((TileEntityArmourer) te).toolUsedOnArmourer(this, world, stack, player);
}
}
return true;
}
return false;
}
use of riskyken.armourersWorkshop.common.blocks.BlockLocation in project Armourers-Workshop by RiskyKen.
the class ItemPaintbrush method onItemUse.
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
Block block = world.getBlock(x, y, z);
if (player.isSneaking() & block == ModBlocks.colourMixer) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof IPantable) {
if (!world.isRemote) {
int colour = ((IPantable) te).getColour(0);
PaintType paintType = ((IPantable) te).getPaintType(0);
setToolColour(stack, colour);
setToolPaintType(stack, paintType);
}
}
return true;
}
if (block instanceof IPantableBlock) {
int newColour = getToolColour(stack);
if (!world.isRemote) {
UndoManager.begin(player);
if ((Boolean) ToolOptions.FULL_BLOCK_MODE.readFromNBT(stack.getTagCompound())) {
for (int i = 0; i < 6; i++) {
usedOnBlockSide(stack, player, world, new BlockLocation(x, y, z), block, i);
}
} else {
usedOnBlockSide(stack, player, world, new BlockLocation(x, y, z), block, side);
}
UndoManager.end(player);
if ((Boolean) ToolOptions.FULL_BLOCK_MODE.readFromNBT(stack.getTagCompound())) {
world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, LibSounds.PAINT, 1.0F, world.rand.nextFloat() * 0.1F + 0.9F);
} else {
world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, LibSounds.PAINT, 1.0F, world.rand.nextFloat() * 0.1F + 1.5F);
}
} else {
spawnPaintParticles(world, x, y, z, side, newColour);
}
return true;
}
if (block == ModBlocks.armourerBrain & player.isSneaking()) {
if (!world.isRemote) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileEntityArmourer) {
((TileEntityArmourer) te).toolUsedOnArmourer(this, world, stack, player);
}
}
ModLogger.log("armourer");
return true;
}
if (block == ModBlocks.mannequin) {
if (!world.isRemote) {
TileEntity te = ((BlockMannequin) block).getMannequinTileEntity(world, x, y, z);
if (te != null && te instanceof TileEntityMannequin) {
int newColour = getToolColour(stack);
if (player.isSneaking()) {
((TileEntityMannequin) te).setHairColour(newColour);
} else {
((TileEntityMannequin) te).setSkinColour(newColour);
}
}
}
return true;
}
return false;
}
Aggregations