use of me.desht.pneumaticcraft.common.tileentity.ICamouflageableTE in project pnc-repressurized by TeamPneumatic.
the class WailaCamoHandler method getWailaBody.
@Nonnull
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
TileEntity te = accessor.getTileEntity();
if (te instanceof ICamouflageableTE && ((ICamouflageableTE) te).getCamouflage() != null) {
String str = ItemCamoApplicator.getCamoStateDisplayName(((ICamouflageableTE) te).getCamouflage());
currenttip.add(TextFormatting.YELLOW + "[ Camo: " + str + "]");
}
return currenttip;
}
use of me.desht.pneumaticcraft.common.tileentity.ICamouflageableTE in project pnc-repressurized by TeamPneumatic.
the class ItemCamoApplicator method onItemUseFirst.
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (!world.isRemote) {
if (player.isSneaking()) {
// copy blockstate of clicked block
IBlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockPneumaticCraftCamo) {
NetworkHandler.sendToAllAround(new PacketPlaySound(SoundEvents.BLOCK_COMPARATOR_CLICK, SoundCategory.PLAYERS, pos, 1.0F, 2.0F, false), world);
player.sendStatusMessage(new TextComponentTranslation("message.camo.invalidBlock", getCamoStateDisplayName(state)), true);
} else {
setCamoState(stack, state);
}
} else {
// either apply saved camo, or remove current camo from block
TileEntity te = world.getTileEntity(pos);
if (!(te instanceof ICamouflageableTE)) {
return EnumActionResult.PASS;
}
IBlockState camoState = getCamoState(stack);
float pressure = getPressure(stack);
if (pressure < 0.1 && !player.capabilities.isCreativeMode) {
// not enough pressure
return EnumActionResult.FAIL;
}
// make sure player has enough of the camo item
if (camoState != null && !player.capabilities.isCreativeMode) {
ItemStack camoStack = ICamouflageableTE.getStackForState(camoState);
if (!PneumaticCraftUtils.consumeInventoryItem(player.inventory, camoStack)) {
String name = camoStack.getDisplayName();
player.sendStatusMessage(new TextComponentTranslation("message.camo.notEnoughBlocks", name), true);
NetworkHandler.sendToAllAround(new PacketPlaySound(SoundEvents.BLOCK_COMPARATOR_CLICK, SoundCategory.PLAYERS, pos, 1.0F, 2.0F, false), world);
return EnumActionResult.FAIL;
}
}
// return any existing camouflage on the block/TE
IBlockState existingCamo = ((ICamouflageableTE) te).getCamouflage();
if (existingCamo != null && !player.capabilities.isCreativeMode) {
ItemStack camoStack = ICamouflageableTE.getStackForState(existingCamo);
EntityItem entity = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, camoStack);
world.spawnEntity(entity);
entity.onCollideWithPlayer(player);
}
// and apply the new camouflage
addAir(stack, -PneumaticValues.USAGE_CAMO_APPLICATOR);
((ICamouflageableTE) te).setCamouflage(camoState);
NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.SHORT_HISS, SoundCategory.PLAYERS, pos, 1.0F, 1.0F, false), world);
return EnumActionResult.SUCCESS;
}
} else {
return EnumActionResult.SUCCESS;
}
return super.onItemUseFirst(player, world, pos, side, hitX, hitY, hitZ, hand);
}
use of me.desht.pneumaticcraft.common.tileentity.ICamouflageableTE in project pnc-repressurized by TeamPneumatic.
the class BlockPneumaticCraftCamo method getCamoState.
protected IBlockState getCamoState(IBlockAccess blockAccess, BlockPos pos) {
TileEntity te = PneumaticCraftUtils.getTileEntitySafely(blockAccess, pos);
if (!(te instanceof ICamouflageableTE))
return null;
// must not use a camouflageable block as camouflage!
IBlockState camoState = ((ICamouflageableTE) te).getCamouflage();
return camoState == null || camoState.getBlock() instanceof BlockPneumaticCraftCamo ? null : camoState;
}
use of me.desht.pneumaticcraft.common.tileentity.ICamouflageableTE in project pnc-repressurized by TeamPneumatic.
the class BlockColorHandler method registerColorHandlers.
public static void registerColorHandlers() {
final IBlockColor heatColor = (state, blockAccess, pos, tintIndex) -> {
if (blockAccess != null && pos != null) {
TileEntity te = blockAccess.getTileEntity(pos);
int heatLevel = 10;
if (te instanceof TileEntityCompressedIronBlock) {
heatLevel = ((TileEntityCompressedIronBlock) te).getHeatLevel();
} else if (te instanceof TileEntityVortexTube) {
switch(tintIndex) {
case 0:
heatLevel = ((TileEntityVortexTube) te).getHotHeatLevel();
break;
case 1:
heatLevel = ((TileEntityVortexTube) te).getColdHeatLevel();
break;
}
}
double[] color = TileEntityCompressedIronBlock.getColorForHeatLevel(heatLevel);
return 0xFF000000 + ((int) (color[0] * 255) << 16) + ((int) (color[1] * 255) << 8) + (int) (color[2] * 255);
}
return 0xFFFFFFFF;
};
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(heatColor, Blockss.COMPRESSED_IRON, Blockss.HEAT_SINK, Blockss.VORTEX_TUBE);
final IBlockColor uvLightBoxLampColor = (state, blockAccess, pos, tintIndex) -> {
if (blockAccess != null && pos != null) {
TileEntity te = blockAccess.getTileEntity(pos);
if (te instanceof TileEntityUVLightBox) {
return ((TileEntityUVLightBox) te).areLightsOn ? 0xFF4000FF : 0xFFAFAFE4;
}
}
return 0xFFAFAFE4;
};
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(uvLightBoxLampColor, Blockss.UV_LIGHT_BOX);
final IBlockColor camoColor = (state, worldIn, pos, tintIndex) -> {
if (pos == null || worldIn == null)
return 0xffffff;
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof ICamouflageableTE && ((ICamouflageableTE) te).getCamouflage() != null) {
return Minecraft.getMinecraft().getBlockColors().colorMultiplier(((ICamouflageableTE) te).getCamouflage(), te.getWorld(), pos, tintIndex);
} else {
return 0xffffff;
}
};
for (Block b : Blockss.blocks) {
if (b instanceof BlockPneumaticCraftCamo) {
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(camoColor, b);
}
}
}
Aggregations