use of riskyken.armourersWorkshop.common.blocks.BlockLocation in project Armourers-Workshop by RiskyKen.
the class ItemBlendingTool method usedOnBlockSide.
@SuppressWarnings("deprecation")
@Override
public void usedOnBlockSide(ItemStack stack, EntityPlayer player, World world, BlockLocation bl, Block block, int side) {
int intensity = UtilItems.getIntensityFromStack(stack, 16);
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, bl.x, bl.y, bl.z, side, radiusSample);
ArrayList<BlockLocation> blockEffects = BlockUtils.findTouchingBlockFaces(world, bl.x, bl.y, bl.z, side, radiusEffect);
if (blockSamples.size() == 0 | blockEffects.size() == 0) {
return;
}
int r = 0;
int g = 0;
int b = 0;
for (int i = 0; i < blockSamples.size(); i++) {
BlockLocation loc = blockSamples.get(i);
Block tarBlock = world.getBlock(loc.x, loc.y, loc.z);
if (tarBlock instanceof IPantableBlock) {
IPantableBlock pBlock = (IPantableBlock) tarBlock;
ICubeColour c = pBlock.getColour(world, loc.x, loc.y, loc.z);
r += c.getRed(side) & 0xFF;
g += c.getGreen(side) & 0xFF;
b += c.getBlue(side) & 0xFF;
}
}
r = r / blockSamples.size();
g = g / blockSamples.size();
b = b / blockSamples.size();
for (int i = 0; i < blockEffects.size(); i++) {
BlockLocation loc = blockEffects.get(i);
Block tarBlock = world.getBlock(loc.x, loc.y, loc.z);
if (tarBlock instanceof IPantableBlock) {
IPantableBlock worldColourable = (IPantableBlock) tarBlock;
int oldColour = worldColourable.getColour(world, loc.x, loc.y, loc.z, side);
byte oldPaintType = (byte) worldColourable.getPaintType(world, loc.x, loc.y, loc.z, side).getKey();
Color oldC = new Color(oldColour);
int oldR = oldC.getRed();
int oldG = oldC.getGreen();
int oldB = oldC.getBlue();
float newR = r / 100F * intensity;
newR += oldR / 100F * (100 - intensity);
newR = MathHelper.clamp_int((int) newR, 0, 255);
float newG = g / 100F * intensity;
newG += oldG / 100F * (100 - intensity);
newG = MathHelper.clamp_int((int) newG, 0, 255);
float newB = b / 100F * intensity;
newB += oldB / 100F * (100 - intensity);
newB = MathHelper.clamp_int((int) newB, 0, 255);
Color newC = new Color((int) newR, (int) newG, (int) newB);
UndoManager.blockPainted(player, world, loc.x, loc.y, loc.z, oldColour, oldPaintType, side);
((IPantableBlock) block).setColour(world, loc.x, loc.y, loc.z, newC.getRGB(), side);
}
}
}
use of riskyken.armourersWorkshop.common.blocks.BlockLocation in project Armourers-Workshop by RiskyKen.
the class ItemColourNoiseTool 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 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 ItemDodgeTool 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.DODGE, 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 ItemHueTool 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) {
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 TileEntitySkinnable method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
compound.setBoolean(TAG_HAS_SKIN, hasSkin());
compound.setInteger(ModConstants.Tags.TAG_NBT_VERSION, NBT_VERSION);
if (hasLinkedBlock()) {
compound.setIntArray(TAG_LINKED_BLOCK, new int[] { linkedBlock.x, linkedBlock.y, linkedBlock.z });
}
if (hasSkin()) {
skinPointer.writeToCompound(compound);
if (relatedBlocks != null) {
NBTTagList list = new NBTTagList();
for (int i = 0; i < relatedBlocks.size(); i++) {
NBTTagCompound blockCompound = new NBTTagCompound();
BlockLocation blockLoc = relatedBlocks.get(i);
blockCompound.setInteger(TAG_X, blockLoc.x);
blockCompound.setInteger(TAG_Y, blockLoc.y);
blockCompound.setInteger(TAG_Z, blockLoc.z);
list.appendTag(blockCompound);
}
compound.setTag(TAG_RELATED_BLOCKS, list);
}
if (isParent() & blockInventory & inventory != null) {
compound.setBoolean(TAG_BLOCK_INVENTORY, true);
compound.setInteger(TAG_BLOCK_INVENTORY_SIZE, inventory.getSizeInventory());
inventory.saveItemsToNBT(compound);
} else {
compound.setBoolean(TAG_BLOCK_INVENTORY, false);
}
}
}
Aggregations